diff --git a/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/EditServiceScreenRoute.kt b/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/EditServiceScreenRoute.kt index 28f3d8e9..dee8e5cc 100644 --- a/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/EditServiceScreenRoute.kt +++ b/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/EditServiceScreenRoute.kt @@ -82,6 +82,7 @@ internal fun EditServiceScreenRoute( composable(EditServiceScreen.ChangeBrand.route) { ChangeBrandScreen( + close = { navHostController.popBackStack() }, onRequestIconClick = { navHostController.navigate(EditServiceScreen.RequestIcon.route) }, viewModel = serviceViewModel, ) diff --git a/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/changebrand/ChangeBrandScreen.kt b/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/changebrand/ChangeBrandScreen.kt index 74aa8264..a3c9fe6e 100644 --- a/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/changebrand/ChangeBrandScreen.kt +++ b/feature/home/src/main/java/com/twofasapp/feature/home/ui/editservice/changebrand/ChangeBrandScreen.kt @@ -24,9 +24,11 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment.Companion.CenterHorizontally import androidx.compose.ui.Alignment.Companion.CenterVertically import androidx.compose.ui.Modifier @@ -52,6 +54,7 @@ import timber.log.Timber @Composable internal fun ChangeBrandScreen( + close: () -> Unit, onRequestIconClick: () -> Unit, viewModel: EditServiceViewModel = getViewModel(), brandViewModel: ChangeBrandViewModel = koinViewModel(), @@ -59,11 +62,19 @@ internal fun ChangeBrandScreen( val service = viewModel.uiState.collectAsState().value.service val state = brandViewModel.uiState.collectAsState().value val listState = rememberLazyListState() - val coroutineScope = rememberCoroutineScope() + val scope = rememberCoroutineScope() var showBrandingDialog = remember { mutableStateOf(false) } + var finish by remember { mutableStateOf(false) } val backDispatcher = LocalBackDispatcher val uriHandler = LocalUriHandler.current + + LaunchedEffect(finish) { + if (finish) { + close() + } + } + Scaffold( topBar = { TopAppBarWithSearch( @@ -165,7 +176,7 @@ internal fun ChangeBrandScreen( .clip(CircleShape) .clickable { viewModel.updateBrand(it) - backDispatcher.onBackPressed() + finish = true } .padding(16.dp) ) @@ -211,7 +222,7 @@ internal fun ChangeBrandScreen( LaunchedEffect(Unit) { if (state.scrollTo.not()) return@LaunchedEffect - coroutineScope.launch { + scope.launch { var selectedIndex = -1 var i = 0 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 725bbe39..9bbe4070 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] accompanist = "0.33.2-alpha" -agp = "8.3.0-beta01" +agp = "8.3.0-beta02" cameraX = "1.3.1" coil = "2.5.0" commonmark = "0.21.0"