Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dependencies {

implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.1'
implementation 'androidx.activity:activity-compose:1.5.1'
implementation 'androidx.activity:activity-compose:1.6.0'
implementation "androidx.compose.ui:ui:$compose_ui_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_ui_version"
implementation "androidx.compose.material:material:$compose_ui_version"
Expand Down Expand Up @@ -87,4 +87,11 @@ dependencies {

//DataStore
implementation "androidx.datastore:datastore-preferences:1.0.0"

//GoogleMap
implementation "com.google.maps.android:maps-compose:1.1.0"
implementation 'com.google.android.gms:play-services-maps:18.1.0'

// Location
implementation "com.google.android.gms:play-services-location:21.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,20 @@ fun AppList(navController: NavController) {
}
)
ItemList(
"Data Store Timer",
"Timer",
onClick = {
navController.navigate(AppScreens.TimerScreen.route)
}
)
ItemList(
"Google Map",
onClick = {
navController.navigate(AppScreens.MapScreen.route)
}
)
}
}



@Preview(showSystemUi = true, showBackground = true)
@Composable
fun DefaultPreviewAppList() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package com.ahgitdevelopment.course.customexamples.features.screens.googlemap

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material.CircularProgressIndicator
import androidx.compose.material.Scaffold
import androidx.compose.material.rememberScaffoldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.navigation.NavController
import com.ahgitdevelopment.course.customexamples.features.components.TopAppBar
import com.ahgitdevelopment.course.customexamples.navigation.AppScreens
import com.google.android.gms.maps.model.CameraPosition
import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.compose.GoogleMap
import com.google.maps.android.compose.Marker
import com.google.maps.android.compose.rememberCameraPositionState

private val MADRID = LatLng(40.416729, -3.703339)

@Composable
fun MapScreen(
navController: NavController
) {
val scaffoldState = rememberScaffoldState()

Scaffold(
scaffoldState = scaffoldState,
topBar = {
TopAppBar(
title = AppScreens.LazyListScreen.route,
navController = navController
)
},
content = { paddingVal ->
Box(
modifier = Modifier
.fillMaxSize()
.padding(paddingVal)
) {
Column(
modifier = Modifier
.fillMaxSize()
) {
MapContent()
}
}
}
)
}

@Composable
fun MapContent() {
var isMapLoading by remember { mutableStateOf(true) }
val cameraPositionState = rememberCameraPositionState {
position = CameraPosition.fromLatLngZoom(MADRID, 15f)
}

GoogleMap(
cameraPositionState = cameraPositionState,
onMapLoaded = { isMapLoading = false }) {
Marker(
position = cameraPositionState.position.target,
title = cameraPositionState.position.target.toString()
)
}
if (isMapLoading) {
CircularProgressIndicator()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.ahgitdevelopment.course.customexamples.features.screens.ScreenA
import com.ahgitdevelopment.course.customexamples.features.screens.ScreenB
import com.ahgitdevelopment.course.customexamples.features.screens.datastore.DataStoreResultScreen
import com.ahgitdevelopment.course.customexamples.features.screens.datastore.DataStoreScreen
import com.ahgitdevelopment.course.customexamples.features.screens.googlemap.MapScreen
import com.ahgitdevelopment.course.customexamples.features.screens.splash.SplashScreen
import com.ahgitdevelopment.course.customexamples.features.screens.timer.TimerScreen

Expand Down Expand Up @@ -49,5 +50,8 @@ fun AppNavigation() {
composable(route = AppScreens.TimerScreen.route) {
TimerScreen()
}
composable(route = AppScreens.MapScreen.route) {
MapScreen(navController)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ sealed class AppScreens(val route: String) {
object DataStoreResultScreen : AppScreens("DataStoreResultScreen")

object TimerScreen : AppScreens("TimerScreen")
object MapScreen : AppScreens("MapScreen")
}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
compose_ui_version = '1.3.0-beta02'
compose_ui_version = '1.3.0-rc01'
composeNavigationVersion = '2.5.2'
}

Expand All @@ -14,7 +14,7 @@ buildscript {

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}