Skip to content

Commit

Permalink
Merge branch 'master' into android-dd-confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry-Borodin authored Aug 17, 2023
2 parents f5ad37b + 96cbe2c commit 094da6e
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 437 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ fun SignerCheckbox(
Crossfade(
targetState = isChecked,
animationSpec = tween(durationMillis = 150),
label = "checkbox crossfade",
) { isChecked ->
Image(
painter = painterResource(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fun CloseIcon(
contentDescription = stringResource(R.string.description_close_button),
colorFilter = ColorFilter.tint(MaterialTheme.colors.primary),
modifier = Modifier
.size(24.dp)
.size(20.dp)
)
}
}
21 changes: 14 additions & 7 deletions android/src/main/java/io/parity/signer/domain/Models.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ data class KeySetDetailsModel(
fun createStub(): KeySetDetailsModel = KeySetDetailsModel(
keysAndNetwork = listOf(
KeyAndNetworkModel(
key = KeyModel.createStub(),
key = KeyModel.createStub(addressKey = "address key"),
network = NetworkInfoModel.createStub()
),
KeyAndNetworkModel(
key = KeyModel.createStub(),
key = KeyModel.createStub(addressKey = "address key2"),
network = NetworkInfoModel.createStub(networkName = "Some")
),
KeyAndNetworkModel(
key = KeyModel.createStub()
key = KeyModel.createStub(addressKey = "address key3")
.copy(path = "//polkadot//path3"),
network = NetworkInfoModel.createStub()
),
Expand All @@ -47,9 +47,13 @@ fun MKeysNew.toKeySetDetailsModel() = KeySetDetailsModel(
root = root?.toKeysModel(),
)

data class KeyAndNetworkModel(val key: KeyModel, val network: NetworkInfoModel) {
data class KeyAndNetworkModel(
val key: KeyModel,
val network: NetworkInfoModel
) {
companion object {
fun createStub() = KeyAndNetworkModel(KeyModel.createStub(), NetworkInfoModel.createStub())
fun createStub() =
KeyAndNetworkModel(KeyModel.createStub(), NetworkInfoModel.createStub())
}
}

Expand All @@ -72,8 +76,11 @@ data class KeyModel(
val wasImported: Boolean?,
) {
companion object {
fun createStub(wasImported: Boolean = false) = KeyModel(
addressKey = "address key",
fun createStub(
addressKey: String = "address key",
wasImported: Boolean = false
) = KeyModel(
addressKey = addressKey,
base58 = "5F3sa2TJAWMqDhXG6jhV4N8ko9SxwGy8TpaNS1repo5EYjQX",
identicon = PreviewData.Identicon.exampleIdenticonPng,
hasPwd = true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
package io.parity.signer.screens.keysetdetails

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import io.parity.signer.domain.*
import io.parity.signer.domain.KeySetDetailsModel
import io.parity.signer.domain.Navigator
import io.parity.signer.domain.NetworkState
import io.parity.signer.domain.SharedViewModel
import io.parity.signer.domain.storage.removeSeed
import io.parity.signer.screens.keysetdetails.backup.KeySetBackupFullOverlayBottomSheet
import io.parity.signer.screens.keysetdetails.backup.toSeedBackupModel
import io.parity.signer.screens.keysetdetails.export.KeySetDetailsExportScreenFull
import io.parity.signer.domain.submitErrorState

@Composable
fun KeySetDetailsNavSubgraph(
Expand Down Expand Up @@ -44,16 +42,9 @@ fun KeySetDetailsNavSubgraph(
},
)
}
composable(KeySetDetailsNavSubgraph.multiselect) {
KeySetDetailsExportScreenFull(
model = model,
onClose = { navController.navigate(KeySetDetailsNavSubgraph.home) },
)
}
}
}

internal object KeySetDetailsNavSubgraph {
const val home = "keyset_details_home"
const val multiselect = "keyset_details_multiselect"
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.runtime.Composable
import androidx.compose.runtime.State
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.viewmodel.compose.viewModel
Expand All @@ -22,8 +24,9 @@ import io.parity.signer.domain.getSeedPhraseForBackup
import io.parity.signer.domain.submitErrorState
import io.parity.signer.screens.keysetdetails.backup.KeySetBackupFullOverlayBottomSheet
import io.parity.signer.screens.keysetdetails.backup.toSeedBackupModel
import io.parity.signer.screens.keysetdetails.export.KeySetDetailsExportResultBottomSheet
import io.parity.signer.screens.keysetdetails.export.KeySetDetailsMultiselectBottomSheet
import io.parity.signer.screens.keysetdetails.filtermenu.NetworkFilterMenu
import io.parity.signer.domain.submitErrorState
import io.parity.signer.ui.BottomSheetWrapperRoot

@Composable
Expand All @@ -37,7 +40,8 @@ fun KeySetDetailsScreenSubgraph(
val menuNavController = rememberNavController()

val keySetViewModel: KeySetDetailsViewModel = viewModel()
val filteredModel = keySetViewModel.makeFilteredFlow(fullModel).collectAsStateWithLifecycle()
val filteredModel =
keySetViewModel.makeFilteredFlow(fullModel).collectAsStateWithLifecycle()

Box(Modifier.statusBarsPadding()) {
KeySetDetailsScreenView(
Expand Down Expand Up @@ -72,7 +76,7 @@ fun KeySetDetailsScreenSubgraph(
networkState = networkState,
onSelectKeysClicked = {
menuNavController.popBackStack()
navController.navigate(KeySetDetailsNavSubgraph.multiselect)
menuNavController.navigate(KeySetDetailsMenuSubgraph.export)
},
onBackupClicked = {
menuNavController.navigate(KeySetDetailsMenuSubgraph.backup) {
Expand Down Expand Up @@ -157,6 +161,36 @@ fun KeySetDetailsScreenSubgraph(
)
}
}
composable(KeySetDetailsMenuSubgraph.export) {
val selected = remember { mutableStateOf(setOf<String>()) }
val isResultState = remember { mutableStateOf(false) }

if (!isResultState.value) {
BottomSheetWrapperRoot(onClosedAction = closeAction) {
KeySetDetailsMultiselectBottomSheet(
model = fullModel,
selected = selected,
onClose = closeAction,
onExportSelected = {
isResultState.value = true
},
onExportAll = {
selected.value =
fullModel.keysAndNetwork.map { it.key.addressKey }.toSet()
isResultState.value = true
},
)
}
} else {
BottomSheetWrapperRoot(onClosedAction = closeAction) {
KeySetDetailsExportResultBottomSheet(
model = fullModel,
selectedKeys = selected.value,
onClose = closeAction,
)
}
}
}
}
}

Expand All @@ -168,7 +202,9 @@ private object KeySetDetailsMenuSubgraph {
const val network_filter = "keys_network_filters"
const val backup = "keyset_details_backup"
const val keys_public_key = "keys_public_key"
const val export = "export_multiselect"
}

private const val ARGUMENT_PUBLIC_KEY_TITLE = "ARGUMENT_PUBLIC_KEY_TITLE"
private const val ARGUMENT_PUBLIC_KEY_VALUE = "ARGUMENT_PUBLIC_KEY_VALUE"

Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ fun KeySetDetailsExportResultBottomSheet(
onClose()
} else {
Column(Modifier.background(MaterialTheme.colors.backgroundTertiary)) {
val keysToExport = selectedKeys.size + 1 // + root key
BottomSheetHeader(
title = pluralStringResource(
id = R.plurals.key_export_title,
count = selectedKeys.size,
selectedKeys.size,
count = keysToExport,
keysToExport,
),
onCloseClicked = onClose
)
Expand Down

This file was deleted.

Loading

0 comments on commit 094da6e

Please sign in to comment.