secant-android-wallet/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/backup/view/LongNewWalletBackupView.kt

462 lines
16 KiB
Kotlin
Raw Normal View History

[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
@file:Suppress("TooManyFunctions")
package co.electriccoin.zcash.ui.screen.backup.view
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.MoreVert
2022-02-21 06:33:40 -08:00
import androidx.compose.material3.Card
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
2022-02-21 06:33:40 -08:00
import androidx.compose.material3.ExperimentalMaterial3Api
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Devices
import androidx.compose.ui.tooling.preview.Preview
import androidx.lifecycle.compose.collectAsStateWithLifecycle
2023-02-17 03:05:23 -08:00
import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.sdk.fixture.PersistableWalletFixture
import co.electriccoin.zcash.spackle.model.Index
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.common.SecureScreen
import co.electriccoin.zcash.ui.design.MINIMAL_WEIGHT
import co.electriccoin.zcash.ui.design.component.Body
import co.electriccoin.zcash.ui.design.component.CHIP_GRID_ROW_SIZE
import co.electriccoin.zcash.ui.design.component.Chip
import co.electriccoin.zcash.ui.design.component.ChipGrid
import co.electriccoin.zcash.ui.design.component.GradientSurface
import co.electriccoin.zcash.ui.design.component.PrimaryButton
import co.electriccoin.zcash.ui.design.component.TertiaryButton
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.fixture.TestChoicesFixture
import co.electriccoin.zcash.ui.screen.backup.BackupTag
import co.electriccoin.zcash.ui.screen.backup.model.BackupStage
import co.electriccoin.zcash.ui.screen.backup.state.BackupState
import co.electriccoin.zcash.ui.screen.backup.state.TestChoices
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.toPersistentList
@Preview(device = Devices.PIXEL_4)
@Composable
fun ComposablePreview() {
2021-12-09 12:18:18 -08:00
ZcashTheme(darkTheme = false) {
GradientSurface {
LongNewWalletBackup(
2021-12-09 12:18:18 -08:00
PersistableWalletFixture.new(),
BackupState(BackupStage.EducationOverview),
TestChoicesFixture.new(mutableMapOf()),
2021-12-09 12:18:18 -08:00
onCopyToClipboard = {},
onComplete = {},
onChoicesChanged = {}
2021-12-09 12:18:18 -08:00
)
}
}
}
/**
* @param onComplete Callback when the user has completed the backup test.
*/
2023-01-17 11:13:46 -08:00
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@Suppress("LongParameterList")
fun LongNewWalletBackup(
wallet: PersistableWallet,
backupState: BackupState,
choices: TestChoices,
2021-12-02 12:33:55 -08:00
onCopyToClipboard: () -> Unit,
onComplete: () -> Unit,
2022-06-22 02:48:19 -07:00
onChoicesChanged: ((choicesCount: Int) -> Unit)?
) {
val currentBackupStage = backupState.current.collectAsStateWithLifecycle().value
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
Scaffold(
topBar = {
BackupTopAppBar(
backupStage = currentBackupStage,
onCopyToClipboard = onCopyToClipboard,
onBack = backupState::goPrevious,
selectedTestChoices = choices
)
},
bottomBar = {
BackupBottomNav(
backupStage = currentBackupStage,
onNext = backupState::goNext,
onBack = backupState::goPrevious,
selectedTestChoices = choices,
onComplete = onComplete,
onBackToSeedPhrase = {
backupState.goToStage(BackupStage.ReviewSeed)
}
)
}
) { paddingValues ->
BackupMainContent(
paddingValues = paddingValues,
backupState = backupState,
wallet = wallet,
choices = choices,
onChoicesChanged = onChoicesChanged
)
}
}
@Composable
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
fun BackupMainContent(
paddingValues: PaddingValues,
backupState: BackupState,
wallet: PersistableWallet,
choices: TestChoices,
onChoicesChanged: ((choicesCount: Int) -> Unit)?
) {
Column(
Modifier
.padding(
top = paddingValues.calculateTopPadding(),
bottom = paddingValues.calculateBottomPadding()
)
) {
when (backupState.current.collectAsStateWithLifecycle().value) {
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
is BackupStage.EducationOverview -> EducationOverview()
is BackupStage.EducationRecoveryPhrase -> EducationRecoveryPhrase()
is BackupStage.Seed -> SeedPhrase(wallet)
is BackupStage.Test -> TestInProgress(
selectedTestChoices = choices,
onChoicesChanged = onChoicesChanged,
splitSeedPhrase = wallet.seedPhrase.split.toPersistentList(),
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
backupState = backupState
)
is BackupStage.Failure -> TestFailure()
is BackupStage.Complete -> TestComplete()
is BackupStage.ReviewSeed -> SeedPhrase(wallet)
}
}
}
@Composable
private fun EducationOverview() {
Column(
Modifier
.verticalScroll(rememberScrollState())
) {
Body(stringResource(R.string.new_wallet_1_body_1))
Image(
painter = painterResource(id = R.drawable.backup_1),
contentDescription = stringResource(id = R.string.backup_1_content_description)
)
Spacer(
Modifier
.fillMaxWidth()
.weight(MINIMAL_WEIGHT, true)
)
Body(stringResource(R.string.new_wallet_1_body_2))
}
}
@Composable
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
private fun EducationRecoveryPhrase() {
Column(
Modifier
.verticalScroll(rememberScrollState())
) {
Body(stringResource(R.string.new_wallet_2_body_1))
Image(
painter = painterResource(id = R.drawable.backup_2),
contentDescription = stringResource(id = R.string.backup_2_content_description)
)
Body(stringResource(R.string.new_wallet_2_body_2))
Card {
Body(stringResource(R.string.new_wallet_2_body_3))
}
}
}
@Composable
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
private fun SeedPhrase(persistableWallet: PersistableWallet) {
SecureScreen()
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
Column(
Modifier
.verticalScroll(rememberScrollState())
.padding(vertical = ZcashTheme.paddings.padding)
) {
Body(stringResource(R.string.new_wallet_3_body_1))
ChipGrid(persistableWallet.seedPhrase.split.toPersistentList())
}
}
@Suppress("MagicNumber")
private val testIndices = listOf(Index(4), Index(9), Index(16), Index(20))
private data class TestChoice(val originalIndex: Index, val word: String)
/*
* A few implementation notes on the test:
* - It is possible for the same word to appear twice in the word choices
* - The test answer ordering is not randomized, to ensure it can never be in the correct order to start with
*/
2023-01-17 11:13:46 -08:00
@Composable
private fun TestInProgress(
splitSeedPhrase: ImmutableList<String>,
selectedTestChoices: TestChoices,
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
onChoicesChanged: ((choicesCount: Int) -> Unit)?,
backupState: BackupState
) {
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
SecureScreen()
val testChoices = splitSeedPhrase
.mapIndexed { index, word -> TestChoice(Index(index), word) }
.filter { testIndices.contains(it.originalIndex) }
.let {
// Don't randomize; otherwise there's a chance they'll be in the right order to start with.
@Suppress("MagicNumber")
listOf(it[1], it[0], it[3], it[2])
}
val currentSelectedTestChoice = selectedTestChoices.current.collectAsStateWithLifecycle().value
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
if (currentSelectedTestChoice.size == testIndices.size) {
if (currentSelectedTestChoice.all { splitSeedPhrase[it.key.value] == it.value }) {
// the user got the test correct
backupState.goNext()
} else {
backupState.goToStage(BackupStage.Failure)
}
}
Column(
Modifier
.verticalScroll(rememberScrollState())
.padding(vertical = ZcashTheme.paddings.padding)
) {
splitSeedPhrase.chunked(CHIP_GRID_ROW_SIZE).forEachIndexed { chunkIndex, chunk ->
Row(Modifier.fillMaxWidth()) {
chunk.forEachIndexed { subIndex, word ->
val currentIndex = Index(chunkIndex * CHIP_GRID_ROW_SIZE + subIndex)
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
if (testIndices.contains(currentIndex)) {
ChipDropDown(
currentIndex,
dropdownText = currentSelectedTestChoice[currentIndex]
?: "",
choices = testChoices.map { it.word }.toPersistentList(),
{
selectedTestChoices.set(
HashMap(currentSelectedTestChoice).apply {
this[currentIndex] = testChoices[it.value].word
}
)
if (onChoicesChanged != null) {
onChoicesChanged(selectedTestChoices.current.value.size)
}
},
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
modifier = Modifier
.weight(MINIMAL_WEIGHT)
.testTag(BackupTag.DROPDOWN_CHIP)
)
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
} else {
Chip(
index = Index(chunkIndex * CHIP_GRID_ROW_SIZE + subIndex),
text = word,
modifier = Modifier.weight(MINIMAL_WEIGHT)
)
}
}
}
}
}
}
@Composable
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
private fun TestFailure() {
Column(
Modifier
.verticalScroll(rememberScrollState())
) {
Image(
painter = painterResource(id = R.drawable.backup_failure),
contentDescription = stringResource(id = R.string.backup_failure_content_description)
)
Box(Modifier.fillMaxHeight(MINIMAL_WEIGHT))
Body(stringResource(R.string.new_wallet_4_body_ouch_retry))
}
}
@Composable
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
private fun TestComplete() {
Column(
Modifier
.verticalScroll(rememberScrollState())
) {
Body(stringResource(R.string.new_wallet_5_body))
Image(
painter = painterResource(id = R.drawable.backup_success),
contentDescription = stringResource(id = R.string.backup_success_content_description)
)
Spacer(
Modifier
.fillMaxWidth()
.weight(MINIMAL_WEIGHT, true)
)
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
}
}
@Composable
@OptIn(ExperimentalMaterial3Api::class)
private fun BackupTopAppBar(
backupStage: BackupStage,
onCopyToClipboard: () -> Unit,
onBack: () -> Unit,
selectedTestChoices: TestChoices
) {
var showCopySeedMenu = false
val screenTitleResId = when (backupStage) {
is BackupStage.EducationOverview -> {
R.string.new_wallet_1_header
}
is BackupStage.EducationRecoveryPhrase -> {
R.string.new_wallet_2_header
}
is BackupStage.Seed -> {
showCopySeedMenu = true
R.string.new_wallet_3_header
}
is BackupStage.Test -> {
R.string.new_wallet_4_header
}
is BackupStage.Failure -> {
R.string.new_wallet_4_header_ouch
}
is BackupStage.Complete -> {
R.string.new_wallet_5_header
}
is BackupStage.ReviewSeed -> {
showCopySeedMenu = true
R.string.new_wallet_3_header
}
}
TopAppBar(
title = { Text(text = stringResource(id = screenTitleResId)) },
navigationIcon = {
// hide back navigation button for the first and Complete stages
if (backupStage.hasPrevious() && backupStage != BackupStage.Complete) {
val onBackClickListener = {
if (backupStage is BackupStage.Failure) {
// Clear the user's prior test inputs for the retest
selectedTestChoices.set(emptyMap())
}
onBack()
}
BackHandler(enabled = true) { onBackClickListener() }
IconButton(onBackClickListener) {
Icon(
imageVector = Icons.Filled.ArrowBack,
contentDescription = stringResource(
R.string.new_wallet_navigation_back_button_content_description
)
)
}
}
},
actions = {
if (showCopySeedMenu) {
CopySeedMenu(onCopyToClipboard)
}
}
)
}
@Composable
private fun CopySeedMenu(onCopyToClipboard: () -> Unit) {
Column {
var expanded by rememberSaveable { mutableStateOf(false) }
IconButton(onClick = { expanded = true }) {
Icon(
Icons.Default.MoreVert,
contentDescription = stringResource(R.string.new_wallet_toolbar_more_button_content_description)
)
}
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
DropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false }
) {
DropdownMenuItem(
text = { Text(stringResource(R.string.new_wallet_3_button_copy)) },
onClick = {
expanded = false
onCopyToClipboard()
}
)
}
[#653] Refactor Backup flow screens * [#653] Move copy to buffer action - Trigger this action after seed phrase panel click and confirm via dialog window - Added basic ui tests - Added also dialog integration test - Added related strings * Revert "[#653] Move copy to buffer action" This reverts commit 813eab00b747a779be5ef652745002f65c04572c. * [#150] Refactoring the Backup flow to use Compose Scaffold * Fix Backup flow screenshot test - Removed scroll actions above nodes, which are no longer part of scroll behaviour - bottom navigation buttons are now part of Compose Scaffold component. * Added scroll actions in screenshot test of Profile screen - After tested the whole app with screenshot test on smaller screen device 4WVGA Nexus S * Remove unnecessary screenshot test click action - This click action on the Profile screen title seems to be unnecessary for the test and creates confusion * ScreenshotTest module auto components init - Changed the way we auto-initialize components in ScreenshotTest module - Now we use androidx-startup library for it - And we disabled the default way * Add system back button navigation support * Enable scrolling for Backup Test screen * Fix Screenshot test on small screen in landscape - Tested and fixed cases in which our screenshot test wasn't successful - Tested on 4 WVGA Nexus S in landscpae mode * Code clean * Address review comments + stages refactoring - Flattened BackupStage sealed class. Test and Failure are now regular stages. - Introduced CheckSeed stage, instead of reusing Seed phrase for re-viewing. - Simplified BackupView and custom Saver implementations. - List of possible screen state stages is now lazy loaded value, instead of method. - Some of the stages now override stage moving methods to enhance Backup screen state machine, as it's not linear. - Existing tests updated to align with the new implementation of stages. * Remove `run` block * Rename CheckSeed -> ReviewSeed Check might imply to another reader of the code that there is some going back to the test. I went with the word Review which seems to better convey how that screen is passive for the user. * Simplify list construction This should have better performance. * Crash instead of allowing back navigation * Add documentation * Fix initialization error * Add non-localized string tag Co-authored-by: Carter Jernigan <git@carterjernigan.com>
2022-11-22 23:17:06 -08:00
}
}
@Suppress("LongParameterList")
@Composable
private fun BackupBottomNav(
backupStage: BackupStage,
onNext: () -> Unit,
onBack: () -> Unit,
selectedTestChoices: TestChoices,
onComplete: () -> Unit,
onBackToSeedPhrase: () -> Unit
) {
Column {
when (backupStage) {
is BackupStage.EducationOverview -> {
PrimaryButton(onClick = onNext, text = stringResource(R.string.new_wallet_1_button))
}
is BackupStage.EducationRecoveryPhrase -> {
PrimaryButton(onClick = onNext, text = stringResource(R.string.new_wallet_2_button))
}
is BackupStage.Seed -> {
PrimaryButton(onClick = onNext, text = stringResource(R.string.new_wallet_3_button_finished))
}
is BackupStage.Test -> {
// no bottom navigation button placed
}
is BackupStage.Failure -> {
PrimaryButton(
onClick = {
// Clear the user's prior test inputs for the retest
selectedTestChoices.set(emptyMap())
onBack()
},
text = stringResource(R.string.new_wallet_4_button_retry)
)
}
is BackupStage.Complete -> {
PrimaryButton(onClick = onComplete, text = stringResource(R.string.new_wallet_5_button_finished))
TertiaryButton(onClick = onBackToSeedPhrase, text = stringResource(R.string.new_wallet_5_button_back))
}
is BackupStage.ReviewSeed -> {
PrimaryButton(onClick = onBack, text = stringResource(R.string.new_wallet_3_button_finished))
}
}
}
}