Skip to content

Commit

Permalink
Add comments to ui/components/
Browse files Browse the repository at this point in the history
  • Loading branch information
A-Yerkeshev committed Nov 30, 2024
1 parent 46d271a commit 817ae6c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ import androidx.camera.core.CameraSelector
import androidx.camera.view.LifecycleCameraController
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -20,7 +16,7 @@ import androidx.compose.ui.unit.dp
import com.example.androidproject.R

// This toolbar is used in conjunction with CameraPreviw and contains row with camera controls,
// like photo capture button and close button.
// like photo capture button, switch camera button and close button.
@Composable
fun CameraControls(
controller: LifecycleCameraController,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,10 @@ package com.example.androidproject.ui.components

import androidx.camera.view.LifecycleCameraController
import androidx.camera.view.PreviewView
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.viewinterop.AndroidView
import androidx.lifecycle.compose.LocalLifecycleOwner
import com.example.androidproject.R


// This view displays content, visible through the camera at any given moment when camera is active.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import nl.dionsegijn.konfetti.core.emitter.Emitter
import nl.dionsegijn.konfetti.core.models.Shape
import java.util.concurrent.TimeUnit

// is component is used to display the confetti animation when the user completes a quest
@Composable
fun ConfettiAnimation() {
val party = remember {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import com.utsman.osmandcompose.rememberMarkerState
import org.osmdroid.tileprovider.tilesource.TileSourceFactory
import org.osmdroid.util.GeoPoint

// This composable contains map with markers for checkpoints and user location.
// Additionally, it has controls for zooming the map and scrolling camera to the current location.
@Composable
fun ShowMap(
checkpoints: List<CheckpointEntity>,
Expand All @@ -34,21 +36,17 @@ fun ShowMap(
onMapCameraMove: () -> Unit,
onCheckpointClick: (CheckpointEntity?) -> Unit
) {
// val context = LocalContext.current
val context = App.appContext

val cameraState = rememberCameraState{
geoPoint = GeoPoint(60.17057, 24.941521) // Central Railway Station
zoom = 20.0
}

var isCameraInitialized by remember { mutableStateOf(false) }

LaunchedEffect(isCameraInitialized, isLiveTracking, myLocation) {
// camera center to the current location on 1st load
if (!isCameraInitialized && myLocation != null) {
cameraState.geoPoint = GeoPoint(myLocation.latitude, myLocation.longitude)

isCameraInitialized = true
}

Expand Down

0 comments on commit 817ae6c

Please sign in to comment.