From b473c22722ede681352cc0ffa05e554f6be0befc Mon Sep 17 00:00:00 2001 From: prakharagarwal Date: Thu, 9 Mar 2023 15:31:03 +0530 Subject: [PATCH 1/2] Fix: Back navigation from settings screens --- .../ui/settings/SettingsRootScreen.kt | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SettingsRootScreen.kt b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SettingsRootScreen.kt index 8a1dc5af..ddede0a3 100644 --- a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SettingsRootScreen.kt +++ b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SettingsRootScreen.kt @@ -65,12 +65,7 @@ internal fun SettingsRootScreen( Button( onClick = { - navController.navigate(Screen.RecoveryPhraseScreen.route) { - navController.graph.startDestinationRoute?.let { route -> - popUpTo(route) - } - launchSingleTop = true - } + navController.navigate(Screen.RecoveryPhraseScreen.route) }, colors = ButtonDefaults.buttonColors(containerColor = Color(0xffffffff)), shape = RoundedCornerShape(8.dp), @@ -95,12 +90,7 @@ internal fun SettingsRootScreen( Button( onClick = { - navController.navigate(Screen.SendCoinsBackScreen.route) { - navController.graph.startDestinationRoute?.let { route -> - popUpTo(route) - } - launchSingleTop = true - } + navController.navigate(Screen.SendCoinsBackScreen.route) }, colors = ButtonDefaults.buttonColors(containerColor = Color(0xffffffff)), shape = RoundedCornerShape(8.dp), @@ -125,12 +115,7 @@ internal fun SettingsRootScreen( Button( onClick = { - navController.navigate(Screen.AboutScreen.route) { - navController.graph.startDestinationRoute?.let { route -> - popUpTo(route) - } - launchSingleTop = true - } + navController.navigate(Screen.AboutScreen.route) }, colors = ButtonDefaults.buttonColors(containerColor = Color(0xffffffff)), shape = RoundedCornerShape(8.dp), From 81e1067f68ed28dd68acb8bbabf3832fdc09ee1b Mon Sep 17 00:00:00 2001 From: prakharagarwal Date: Thu, 9 Mar 2023 15:31:50 +0530 Subject: [PATCH 2/2] Feat: Add back button in settings screens --- .../padawanwallet/ui/settings/AboutScreen.kt | 19 +++++++------------ .../ui/settings/RecoveryPhraseScreen.kt | 16 ++++++---------- .../ui/settings/SendCoinsBackScreen.kt | 14 ++++++-------- .../ui/wallet/WalletNavigation.kt | 6 +++--- 4 files changed, 22 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/AboutScreen.kt b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/AboutScreen.kt index 3c8e76e8..b56cedf1 100644 --- a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/AboutScreen.kt +++ b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/AboutScreen.kt @@ -7,10 +7,7 @@ package com.goldenraven.padawanwallet.ui.settings import androidx.compose.foundation.background import androidx.compose.foundation.clickable -import androidx.compose.foundation.layout.Column -import androidx.compose.foundation.layout.Spacer -import androidx.compose.foundation.layout.height -import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.* import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material3.* @@ -20,11 +17,15 @@ import androidx.compose.ui.platform.LocalUriHandler import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.style.TextDecoration import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController import com.goldenraven.padawanwallet.R import com.goldenraven.padawanwallet.theme.* +import com.goldenraven.padawanwallet.ui.PadawanAppBar @Composable -internal fun AboutScreen() { +internal fun AboutScreen( + navController: NavHostController +) { val scrollState = rememberScrollState() Column( Modifier @@ -32,13 +33,7 @@ internal fun AboutScreen() { .background(padawan_theme_background_secondary) .padding(bottom = 12.dp) ) { - Text( - text = "About Padawan", - style = PadawanTypography.headlineSmall, - color = padawan_theme_text_headline, - modifier = Modifier - .padding(top = 48.dp, start = 24.dp, end = 24.dp, bottom = 32.dp) - ) + PadawanAppBar(navController = navController, title = "About Padawan") Text( text = stringResource(R.string.about_text), modifier = Modifier.padding(start = 24.dp, end = 24.dp), diff --git a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/RecoveryPhraseScreen.kt b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/RecoveryPhraseScreen.kt index fd38bd0c..6b80df07 100644 --- a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/RecoveryPhraseScreen.kt +++ b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/RecoveryPhraseScreen.kt @@ -16,15 +16,17 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.unit.dp +import androidx.navigation.NavHostController import com.goldenraven.padawanwallet.data.WalletRepository -import com.goldenraven.padawanwallet.theme.PadawanTypography import com.goldenraven.padawanwallet.theme.padawan_theme_background_secondary -import com.goldenraven.padawanwallet.theme.padawan_theme_text_headline +import com.goldenraven.padawanwallet.ui.PadawanAppBar import com.goldenraven.padawanwallet.ui.standardBorder @OptIn(ExperimentalMaterial3Api::class) @Composable -internal fun RecoveryPhraseScreen() { +internal fun RecoveryPhraseScreen( + navController: NavHostController +) { val scrollState = rememberScrollState() val seedPhrase: String = WalletRepository.getMnemonic() val wordList: List = seedPhrase.split(" ") @@ -35,13 +37,7 @@ internal fun RecoveryPhraseScreen() { .fillMaxSize() .verticalScroll(state = scrollState) ){ - Text( - text = "Your wallet recovery phrase", - style = PadawanTypography.headlineSmall, - color = padawan_theme_text_headline, - modifier = Modifier - .padding(top = 48.dp, start = 24.dp, end = 24.dp, bottom = 32.dp) - ) + PadawanAppBar(navController = navController, title = "Your wallet recovery phrase") wordList.forEachIndexed { index, item -> Row( horizontalArrangement = Arrangement.Center, diff --git a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SendCoinsBackScreen.kt b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SendCoinsBackScreen.kt index 62a231f0..ac1916dc 100644 --- a/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SendCoinsBackScreen.kt +++ b/app/src/main/java/com/goldenraven/padawanwallet/ui/settings/SendCoinsBackScreen.kt @@ -31,13 +31,17 @@ import androidx.compose.ui.text.PlaceholderVerticalAlign import androidx.compose.ui.text.buildAnnotatedString import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp +import androidx.navigation.NavHostController import com.goldenraven.padawanwallet.R import com.goldenraven.padawanwallet.theme.* +import com.goldenraven.padawanwallet.ui.PadawanAppBar import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch @Composable -internal fun SendCoinsBackScreen() { +internal fun SendCoinsBackScreen( + navController: NavHostController +) { val scrollState = rememberScrollState() val context = LocalContext.current val scope = rememberCoroutineScope() @@ -68,13 +72,7 @@ internal fun SendCoinsBackScreen() { .background(padawan_theme_background_secondary) .padding(padding) ) { - Text( - text = "Send your coins back to us!", - style = PadawanTypography.headlineSmall, - color = padawan_theme_text_headline, - modifier = Modifier - .padding(top = 48.dp, start = 24.dp, end = 24.dp, bottom = 32.dp) - ) + PadawanAppBar(navController = navController, title = "Send your coins back to us!") Image( painterResource(R.drawable.return_sats_faucet_address), contentDescription = "Return sats faucet address image", diff --git a/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletNavigation.kt b/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletNavigation.kt index cc21562c..819fa28e 100644 --- a/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletNavigation.kt +++ b/app/src/main/java/com/goldenraven/padawanwallet/ui/wallet/WalletNavigation.kt @@ -269,7 +269,7 @@ fun WalletNavigation( popExitTransition = { slideOutOfContainer(AnimatedContentScope.SlideDirection.Down, animationSpec = tween(animationDuration)) } - ) { AboutScreen() } + ) { AboutScreen(navController = navControllerWalletNavigation) } // Recovery phrase @@ -287,7 +287,7 @@ fun WalletNavigation( popExitTransition = { slideOutOfContainer(AnimatedContentScope.SlideDirection.Down, animationSpec = tween(animationDuration)) } - ) { RecoveryPhraseScreen() } + ) { RecoveryPhraseScreen(navController = navControllerWalletNavigation) } // Send coins back @@ -305,6 +305,6 @@ fun WalletNavigation( popExitTransition = { slideOutOfContainer(AnimatedContentScope.SlideDirection.Down, animationSpec = tween(animationDuration)) } - ) { SendCoinsBackScreen() } + ) { SendCoinsBackScreen(navController = navControllerWalletNavigation) } } }