Skip to content

Feat: Added 2 drawer screens #200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 12, 2022
Merged
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
24 changes: 12 additions & 12 deletions app/src/main/java/com/goldenraven/padawanwallet/HomeNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ fun HomeNavigation() {
// Home
composable(
route = Screen.HomeScreen.route,
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Start, animationSpec = tween(animationDuration))
},
popEnterTransition = {
slideIntoContainer(AnimatedContentScope.SlideDirection.End, animationSpec = tween(animationDuration))
},
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Start, animationSpec = tween(animationDuration))
},
) { HomeScreen(navController = navController) }


Expand All @@ -60,36 +60,36 @@ fun HomeNavigation() {
// Settings
composable(
route = Screen.SettingsScreen.route,
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Start, animationSpec = tween(animationDuration))
},
popEnterTransition = {
slideIntoContainer(AnimatedContentScope.SlideDirection.End, animationSpec = tween(animationDuration))
},
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Down, animationSpec = tween(animationDuration))
},
) { SettingsScreen(navController = navController) }


// Recovery Phrase
composable(
route = Screen.RecoveryPhrase.route,
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Start, animationSpec = tween(animationDuration))
},
popEnterTransition = {
slideIntoContainer(AnimatedContentScope.SlideDirection.End, animationSpec = tween(animationDuration))
},
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Down, animationSpec = tween(animationDuration))
},
) { RecoveryPhraseScreen(navController = navController) }


// Send your coins back
composable(
route = Screen.SendCoinsBackScreen.route,
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Start, animationSpec = tween(animationDuration))
},
popEnterTransition = {
slideIntoContainer(AnimatedContentScope.SlideDirection.End, animationSpec = tween(animationDuration))
},
exitTransition = {
slideOutOfContainer(AnimatedContentScope.SlideDirection.Down, animationSpec = tween(animationDuration))
},
) { SendCoinsBackScreen(navController = navController) }
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,37 @@
package com.goldenraven.padawanwallet.ui.wallet

import androidx.compose.material3.*
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.goldenraven.padawanwallet.data.Repository
import com.goldenraven.padawanwallet.ui.DrawerAppBar


@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun RecoveryPhraseScreen(navController: NavController) {

val seedPhrase: String = Repository.getMnemonic()
val wordList: List<String> = seedPhrase.split(" ")

Scaffold(
topBar = { DrawerAppBar(navController, title = "Wallet Recovery Phrase") },
) { }
) {
Column (
modifier = Modifier.padding(all = 32.dp)
){
wordList.forEachIndexed { index, item ->
Text(
text = "${index + 1}: $item",
modifier = Modifier.weight(weight = 1F)
)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,104 @@
package com.goldenraven.padawanwallet.ui.wallet

import androidx.compose.material3.*
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.InlineTextContent
import androidx.compose.foundation.text.appendInlineContent
import androidx.compose.material.SnackbarHost
import androidx.compose.material.SnackbarHostState
import androidx.compose.material3.Divider
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.Placeholder
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.NavController
import com.goldenraven.padawanwallet.R
import com.goldenraven.padawanwallet.ui.DrawerAppBar
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch


@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun SendCoinsBackScreen(navController: NavController) {

val context = LocalContext.current
val scope = rememberCoroutineScope()
val snackbarHostState = remember { SnackbarHostState() }

val copyAddrString = buildAnnotatedString {
appendInlineContent(id = "copyAddrImageId")
append(stringResource(id = R.string.copyAddrStr))
}

val inlineContentMap = mapOf(
"copyAddrImageId" to InlineTextContent(
Placeholder(17.sp, 17.sp, PlaceholderVerticalAlign.TextCenter)
) {
Image(
painterResource(R.drawable.ic_copy_outline),
contentDescription = "Copy to clipboard image",
)
}
)

Scaffold(
topBar = { DrawerAppBar(navController, title = "Send Coins Back") },
) { }
) {
Column(
Modifier.padding(all = 32.dp)
) {
Image(
painterResource(R.drawable.return_sats_faucet_address),
contentDescription = "Return sats faucet address image",
modifier = Modifier.padding(start = 50.dp, end = 50.dp, bottom = 20.dp)
)
Column(
Modifier
.align(Alignment.CenterHorizontally)
.clickable(onClick = { copyToClipboard(context, scope, snackbarHostState) })
.padding(bottom = 20.dp)
) {
Text(text = stringResource(id = R.string.send_coins_back_address))
Divider(
color = colorResource(id = R.color.fg1),
thickness = 1.dp,
modifier = Modifier.padding(all = 3.dp)
)
Text(
text = copyAddrString,
inlineContent = inlineContentMap,
modifier = Modifier.align(Alignment.End)
)
}
Text(text = stringResource(id = R.string.send_coins_back))
SnackbarHost(hostState = snackbarHostState)
}
}
}

fun copyToClipboard(context: Context, scope: CoroutineScope, snackbarHostState: SnackbarHostState) {
val clipboard: ClipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clip: ClipData = ClipData.newPlainText("", context.getString(R.string.send_coins_back_address))
clipboard.setPrimaryClip(clip)

scope.launch { snackbarHostState.showSnackbar("Copied address to clipboard!") }
}
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@
<string name="privacyText">Padawan Wallet does not collect any information on its users, and does not use Firebase Crashlytics. This, however, means it\'s much harder for us to hear about the bugs from our users. If you have feedback, feel free to send a message to the Padawan Twitter account or to write us an email. You can read our full privacy policy here:</string>
<string name="privacyLink">https://github.com/thunderbiscuit/padawan-wallet/blob/dev/PRIVACY</string>
<string name="send_coins_back_address">tb1qk5238eluqllq2wps67lkxme3x43wll4k282s8q</string>
<string name="copyAddrStr">Copy</string>
</resources>