Skip to content

Commit

Permalink
Fixed map zoom animation when the user comes from the permission scre…
Browse files Browse the repository at this point in the history
…en to the map.
  • Loading branch information
andre-j3sus committed May 14, 2024
1 parent 2c76c75 commit 901c523
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class PharmacistApplication : DependenciesContainer, Application() {
companion object {
const val MEDICINE_NOTIFICATION_CHANNEL = "MedicineNotifications"

private const val API_ENDPOINT_TYPE = "localhost"
private const val API_ENDPOINT_TYPE = "render"
val API_ENDPOINT = when (API_ENDPOINT_TYPE) {
"localhost" -> "http://10.0.2.2:8080"
"ngrok" -> "https://2b02-2001-818-e871-b700-c937-8172-33bf-a88.ngrok-free.app"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.result.ActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.LaunchedEffect
import androidx.lifecycle.lifecycleScope
import com.google.android.libraries.places.api.Places
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -61,16 +62,17 @@ class PharmacyMapActivity : PharmacistActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

lifecycleScope.launch {
viewModel.getCurrentLocation(this@PharmacyMapActivity)
}

viewModel.hasLocationPermission = hasLocationPermission()
viewModel.hasCameraPermission = hasCameraPermission()
viewModel.listenForRealTimeUpdates()
viewModel.loadPharmacyList()

setContent {
LaunchedEffect(key1 = viewModel.hasLocationPermission) {
if (viewModel.hasLocationPermission)
viewModel.getCurrentLocation(this@PharmacyMapActivity)
}

PharmacyMapScreen(
followMyLocation = viewModel.followMyLocation,
zoomedInMyLocation = viewModel.zoomedInMyLocation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
Expand All @@ -26,6 +27,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import pt.ulisboa.ist.pharmacist.R
import pt.ulisboa.ist.pharmacist.ui.screens.shared.components.IconTextButton

/**
* Screen to request permissions
Expand Down Expand Up @@ -82,23 +84,25 @@ fun PermissionScreen(
fontSize = 16.sp
)
Spacer(modifier = Modifier.height(16.dp))
Button(
IconTextButton(
text = settingsPermissionNoteButtonText,
imageVector = Icons.Rounded.Settings,
contentDescription = settingsPermissionNoteButtonText,
onClick = {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", context.packageName, null)
intent.data = uri
context.startActivity(intent)
}
) {
Text(text = settingsPermissionNoteButtonText)
}
)
} else
Button(
IconTextButton(
onClick = {
permissionLauncher.launch(permissionRequests.toTypedArray())
}
) {
Text(text = stringResource(R.string.grant_permission_button))
}
},
text = stringResource(R.string.grant_permission_button),
imageVector = Icons.Rounded.Settings,
contentDescription = stringResource(R.string.grant_permission_button)
)
}
}

0 comments on commit 901c523

Please sign in to comment.