Bottom sheet code cleanup
This commit is contained in:
parent
0209bec72b
commit
2281a8e60f
|
@ -90,7 +90,7 @@ fun rememberModalBottomSheetState(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
@ExperimentalMaterial3Api
|
@ExperimentalMaterial3Api
|
||||||
private fun rememberSheetState(
|
fun rememberSheetState(
|
||||||
skipPartiallyExpanded: Boolean,
|
skipPartiallyExpanded: Boolean,
|
||||||
confirmValueChange: (SheetValue) -> Boolean,
|
confirmValueChange: (SheetValue) -> Boolean,
|
||||||
initialValue: SheetValue,
|
initialValue: SheetValue,
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package co.electriccoin.zcash.ui.design.component
|
||||||
|
|
||||||
|
import androidx.activity.compose.BackHandler
|
||||||
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.SheetState
|
||||||
|
import androidx.compose.material3.SheetValue
|
||||||
|
import androidx.compose.material3.SheetValue.Hidden
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
|
import co.electriccoin.zcash.ui.design.LocalSheetStateManager
|
||||||
|
|
||||||
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
|
@Composable
|
||||||
|
fun <T : ModalBottomSheetState> ZashiScreenModalBottomSheet(
|
||||||
|
state: T?,
|
||||||
|
sheetState: SheetState = rememberScreenModalBottomSheetState(),
|
||||||
|
content: @Composable () -> Unit = {},
|
||||||
|
) {
|
||||||
|
ZashiModalBottomSheet(
|
||||||
|
sheetState = sheetState,
|
||||||
|
content = {
|
||||||
|
BackHandler(state != null) {
|
||||||
|
state?.onBack?.invoke()
|
||||||
|
}
|
||||||
|
content()
|
||||||
|
},
|
||||||
|
onDismissRequest = { state?.onBack?.invoke() }
|
||||||
|
)
|
||||||
|
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
sheetState.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@ExperimentalMaterial3Api
|
||||||
|
fun rememberScreenModalBottomSheetState(
|
||||||
|
initialValue: SheetValue = Hidden,
|
||||||
|
skipHiddenState: Boolean = false,
|
||||||
|
skipPartiallyExpanded: Boolean = true,
|
||||||
|
confirmValueChange: (SheetValue) -> Boolean = { true },
|
||||||
|
): SheetState {
|
||||||
|
val sheetManager = LocalSheetStateManager.current
|
||||||
|
val sheetState =
|
||||||
|
rememberSheetState(
|
||||||
|
skipPartiallyExpanded = skipPartiallyExpanded,
|
||||||
|
confirmValueChange = confirmValueChange,
|
||||||
|
initialValue = initialValue,
|
||||||
|
skipHiddenState = skipHiddenState,
|
||||||
|
)
|
||||||
|
DisposableEffect(sheetState) {
|
||||||
|
sheetManager.onSheetOpened(sheetState)
|
||||||
|
onDispose {
|
||||||
|
sheetManager.onSheetDisposed(sheetState)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sheetState
|
||||||
|
}
|
|
@ -1,18 +1,13 @@
|
||||||
package co.electriccoin.zcash.ui.screen.accountlist
|
package co.electriccoin.zcash.ui.screen.accountlist
|
||||||
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.activity.compose.BackHandler
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.window.DialogWindowProvider
|
import androidx.compose.ui.window.DialogWindowProvider
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import co.electriccoin.zcash.ui.design.LocalSheetStateManager
|
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
|
||||||
import co.electriccoin.zcash.ui.screen.accountlist.view.AccountListView
|
import co.electriccoin.zcash.ui.screen.accountlist.view.AccountListView
|
||||||
import co.electriccoin.zcash.ui.screen.accountlist.viewmodel.AccountListViewModel
|
import co.electriccoin.zcash.ui.screen.accountlist.viewmodel.AccountListViewModel
|
||||||
import org.koin.androidx.compose.koinViewModel
|
import org.koin.androidx.compose.koinViewModel
|
||||||
|
@ -22,38 +17,12 @@ import org.koin.androidx.compose.koinViewModel
|
||||||
fun AndroidAccountList() {
|
fun AndroidAccountList() {
|
||||||
val viewModel = koinViewModel<AccountListViewModel>()
|
val viewModel = koinViewModel<AccountListViewModel>()
|
||||||
val state by viewModel.state.collectAsStateWithLifecycle()
|
val state by viewModel.state.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
||||||
val sheetManager = LocalSheetStateManager.current
|
|
||||||
DisposableEffect(sheetState) {
|
|
||||||
sheetManager.onSheetOpened(sheetState)
|
|
||||||
onDispose {
|
|
||||||
sheetManager.onSheetDisposed(sheetState)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val parent = LocalView.current.parent
|
val parent = LocalView.current.parent
|
||||||
|
|
||||||
SideEffect {
|
SideEffect {
|
||||||
(parent as? DialogWindowProvider)?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
(parent as? DialogWindowProvider)?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
||||||
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
state?.let {
|
state?.let {
|
||||||
AccountListView(
|
AccountListView(it)
|
||||||
state = it,
|
|
||||||
sheetState = sheetState,
|
|
||||||
onDismissRequest = {
|
|
||||||
state?.onBack?.invoke()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
sheetState.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
BackHandler {
|
|
||||||
state?.onBack?.invoke()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package co.electriccoin.zcash.ui.screen.accountlist.model
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import co.electriccoin.zcash.ui.design.component.ButtonState
|
import co.electriccoin.zcash.ui.design.component.ButtonState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.ModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
||||||
import co.electriccoin.zcash.ui.design.util.StringResource
|
import co.electriccoin.zcash.ui.design.util.StringResource
|
||||||
|
|
||||||
|
@ -9,8 +10,8 @@ data class AccountListState(
|
||||||
val items: List<AccountListItem>?,
|
val items: List<AccountListItem>?,
|
||||||
val isLoading: Boolean,
|
val isLoading: Boolean,
|
||||||
val addWalletButton: ButtonState?,
|
val addWalletButton: ButtonState?,
|
||||||
val onBack: () -> Unit,
|
override val onBack: () -> Unit,
|
||||||
)
|
) : ModalBottomSheetState
|
||||||
|
|
||||||
data class ZashiAccountListItemState(
|
data class ZashiAccountListItemState(
|
||||||
@DrawableRes val icon: Int,
|
@DrawableRes val icon: Int,
|
||||||
|
|
|
@ -33,13 +33,14 @@ import co.electriccoin.zcash.ui.design.component.ButtonState
|
||||||
import co.electriccoin.zcash.ui.design.component.LottieProgress
|
import co.electriccoin.zcash.ui.design.component.LottieProgress
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiButton
|
import co.electriccoin.zcash.ui.design.component.ZashiButton
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiButtonDefaults
|
import co.electriccoin.zcash.ui.design.component.ZashiButtonDefaults
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiModalBottomSheet
|
import co.electriccoin.zcash.ui.design.component.ZashiScreenModalBottomSheet
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.BaseListItem
|
import co.electriccoin.zcash.ui.design.component.listitem.BaseListItem
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemColors
|
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemColors
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemDefaults
|
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemDefaults
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemDesignType
|
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemDesignType
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.rememberScreenModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
||||||
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
||||||
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
||||||
|
@ -54,16 +55,15 @@ import kotlinx.collections.immutable.persistentListOf
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
internal fun AccountListView(
|
internal fun AccountListView(
|
||||||
onDismissRequest: () -> Unit,
|
state: AccountListState,
|
||||||
sheetState: SheetState,
|
sheetState: SheetState = rememberScreenModalBottomSheetState(),
|
||||||
state: AccountListState
|
|
||||||
) {
|
) {
|
||||||
ZashiModalBottomSheet(
|
ZashiScreenModalBottomSheet(
|
||||||
|
state = state,
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
content = {
|
content = {
|
||||||
BottomSheetContent(state)
|
BottomSheetContent(state)
|
||||||
},
|
},
|
||||||
onDismissRequest = onDismissRequest
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,10 @@ private fun BottomSheetContent(state: AccountListState) {
|
||||||
Spacer(modifier = Modifier.height(32.dp))
|
Spacer(modifier = Modifier.height(32.dp))
|
||||||
ZashiButton(
|
ZashiButton(
|
||||||
state = state.addWalletButton,
|
state = state.addWalletButton,
|
||||||
modifier = Modifier.fillMaxWidth().padding(horizontal = 24.dp),
|
modifier =
|
||||||
|
Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.padding(horizontal = 24.dp),
|
||||||
colors =
|
colors =
|
||||||
ZashiButtonDefaults.secondaryColors(
|
ZashiButtonDefaults.secondaryColors(
|
||||||
borderColor = ZashiColors.Btns.Secondary.btnSecondaryBorder
|
borderColor = ZashiColors.Btns.Secondary.btnSecondaryBorder
|
||||||
|
@ -273,7 +276,6 @@ private fun Preview() =
|
||||||
onBack = {},
|
onBack = {},
|
||||||
addWalletButton = ButtonState(stringRes("Connect Hardware Wallet"))
|
addWalletButton = ButtonState(stringRes("Connect Hardware Wallet"))
|
||||||
),
|
),
|
||||||
onDismissRequest = {},
|
|
||||||
sheetState =
|
sheetState =
|
||||||
rememberModalBottomSheetState(
|
rememberModalBottomSheetState(
|
||||||
skipHiddenState = true,
|
skipHiddenState = true,
|
||||||
|
@ -317,7 +319,6 @@ private fun HardwareWalletAddedPreview() =
|
||||||
onBack = {},
|
onBack = {},
|
||||||
addWalletButton = null
|
addWalletButton = null
|
||||||
),
|
),
|
||||||
onDismissRequest = {},
|
|
||||||
sheetState =
|
sheetState =
|
||||||
rememberModalBottomSheetState(
|
rememberModalBottomSheetState(
|
||||||
skipHiddenState = true,
|
skipHiddenState = true,
|
||||||
|
|
|
@ -11,11 +11,6 @@ import androidx.compose.foundation.layout.height
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
import androidx.compose.foundation.lazy.LazyColumn
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.getValue
|
|
||||||
import androidx.compose.runtime.mutableStateOf
|
|
||||||
import androidx.compose.runtime.remember
|
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.runtime.setValue
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
|
@ -35,12 +30,9 @@ import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture
|
||||||
import co.electriccoin.zcash.ui.screen.balances.BalanceState
|
import co.electriccoin.zcash.ui.screen.balances.BalanceState
|
||||||
import co.electriccoin.zcash.ui.screen.balances.BalanceWidget
|
import co.electriccoin.zcash.ui.screen.balances.BalanceWidget
|
||||||
import co.electriccoin.zcash.ui.screen.home.messages.HomeMessage
|
import co.electriccoin.zcash.ui.screen.home.messages.HomeMessage
|
||||||
import co.electriccoin.zcash.ui.screen.home.messages.HomeMessageState
|
|
||||||
import co.electriccoin.zcash.ui.screen.transactionhistory.widget.TransactionHistoryWidgetState
|
import co.electriccoin.zcash.ui.screen.transactionhistory.widget.TransactionHistoryWidgetState
|
||||||
import co.electriccoin.zcash.ui.screen.transactionhistory.widget.TransactionHistoryWidgetStateFixture
|
import co.electriccoin.zcash.ui.screen.transactionhistory.widget.TransactionHistoryWidgetStateFixture
|
||||||
import co.electriccoin.zcash.ui.screen.transactionhistory.widget.createTransactionHistoryWidgets
|
import co.electriccoin.zcash.ui.screen.transactionhistory.widget.createTransactionHistoryWidgets
|
||||||
import kotlinx.coroutines.delay
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
internal fun HomeView(
|
internal fun HomeView(
|
||||||
|
@ -142,8 +134,6 @@ private fun NavButtons(
|
||||||
@Composable
|
@Composable
|
||||||
private fun Preview() {
|
private fun Preview() {
|
||||||
ZcashTheme {
|
ZcashTheme {
|
||||||
var isHomeMessageStateVisible by remember { mutableStateOf(true) }
|
|
||||||
val scope = rememberCoroutineScope()
|
|
||||||
HomeView(
|
HomeView(
|
||||||
appBarState = ZashiMainTopAppBarStateFixture.new(),
|
appBarState = ZashiMainTopAppBarStateFixture.new(),
|
||||||
balanceState = BalanceStateFixture.new(),
|
balanceState = BalanceStateFixture.new(),
|
||||||
|
@ -174,7 +164,7 @@ private fun Preview() {
|
||||||
icon = R.drawable.ic_warning,
|
icon = R.drawable.ic_warning,
|
||||||
onClick = {}
|
onClick = {}
|
||||||
),
|
),
|
||||||
message = null.takeIf { isHomeMessageStateVisible }
|
message = null
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,6 @@ class HomeViewModel(
|
||||||
private val isRestoreSuccessDialogVisible: IsRestoreSuccessDialogVisibleUseCase,
|
private val isRestoreSuccessDialogVisible: IsRestoreSuccessDialogVisibleUseCase,
|
||||||
private val navigateToCoinbase: NavigateToCoinbaseUseCase
|
private val navigateToCoinbase: NavigateToCoinbaseUseCase
|
||||||
) : ViewModel() {
|
) : ViewModel() {
|
||||||
|
|
||||||
private val isMessageVisible = MutableStateFlow(true)
|
private val isMessageVisible = MutableStateFlow(true)
|
||||||
|
|
||||||
private val isRestoreDialogVisible: Flow<Boolean?> =
|
private val isRestoreDialogVisible: Flow<Boolean?> =
|
||||||
|
|
|
@ -35,6 +35,7 @@ import androidx.compose.ui.zIndex
|
||||||
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
|
@Suppress("MagicNumber")
|
||||||
@Composable
|
@Composable
|
||||||
fun HomeMessage(state: HomeMessageState?) {
|
fun HomeMessage(state: HomeMessageState?) {
|
||||||
val cutoutHeight = 16.dp
|
val cutoutHeight = 16.dp
|
||||||
|
@ -46,36 +47,41 @@ fun HomeMessage(state: HomeMessageState?) {
|
||||||
)
|
)
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier =
|
||||||
.background(Color.Gray)
|
Modifier
|
||||||
|
.background(Color.Gray)
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier =
|
||||||
.fillMaxWidth()
|
Modifier
|
||||||
.height(cutoutHeight)
|
.fillMaxWidth()
|
||||||
.zIndex(2f)
|
.height(cutoutHeight)
|
||||||
.bottomOnlyShadow(
|
.zIndex(2f)
|
||||||
elevation = 2.dp,
|
.bottomOnlyShadow(
|
||||||
shape = RoundedCornerShape(bottomStart = 32.dp, bottomEnd = 32.dp),
|
elevation = 2.dp,
|
||||||
backgroundColor = ZashiColors.Surfaces.bgPrimary
|
shape = RoundedCornerShape(bottomStart = 32.dp, bottomEnd = 32.dp),
|
||||||
),
|
backgroundColor = ZashiColors.Surfaces.bgPrimary
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
modifier = Modifier
|
modifier =
|
||||||
.fillMaxWidth()
|
Modifier
|
||||||
.zIndex(0f),
|
.fillMaxWidth()
|
||||||
|
.zIndex(0f),
|
||||||
visible = isVisible,
|
visible = isVisible,
|
||||||
enter = expandIn(animationSpec = tween(350)),
|
enter = expandIn(animationSpec = tween(350)),
|
||||||
exit = shrinkOut(animationSpec = tween(350))
|
exit = shrinkOut(animationSpec = tween(350))
|
||||||
) {
|
) {
|
||||||
when (normalizedState) {
|
when (normalizedState) {
|
||||||
is WalletBackupMessageState -> WalletBackupMessage(
|
is WalletBackupMessageState ->
|
||||||
state = normalizedState as WalletBackupMessageState,
|
WalletBackupMessage(
|
||||||
contentPadding = PaddingValues(
|
state = normalizedState as WalletBackupMessageState,
|
||||||
vertical = cutoutHeight
|
contentPadding =
|
||||||
|
PaddingValues(
|
||||||
|
vertical = cutoutHeight
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
null -> {
|
null -> {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -84,16 +90,17 @@ fun HomeMessage(state: HomeMessageState?) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier
|
modifier =
|
||||||
.fillMaxWidth()
|
Modifier
|
||||||
.height(cutoutHeight)
|
.fillMaxWidth()
|
||||||
.zIndex(1f)
|
.height(cutoutHeight)
|
||||||
.align(Alignment.BottomCenter)
|
.zIndex(1f)
|
||||||
.topOnlyShadow(
|
.align(Alignment.BottomCenter)
|
||||||
elevation = 2.dp,
|
.topOnlyShadow(
|
||||||
shape = RoundedCornerShape(topStart = bottomCornerSize, topEnd = bottomCornerSize),
|
elevation = 2.dp,
|
||||||
backgroundColor = ZashiColors.Surfaces.bgPrimary
|
shape = RoundedCornerShape(topStart = bottomCornerSize, topEnd = bottomCornerSize),
|
||||||
),
|
backgroundColor = ZashiColors.Surfaces.bgPrimary
|
||||||
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,25 +123,26 @@ private fun Modifier.bottomOnlyShadow(
|
||||||
clip: Boolean = elevation > 0.dp,
|
clip: Boolean = elevation > 0.dp,
|
||||||
ambientColor: Color = DefaultShadowColor,
|
ambientColor: Color = DefaultShadowColor,
|
||||||
spotColor: Color = DefaultShadowColor,
|
spotColor: Color = DefaultShadowColor,
|
||||||
): Modifier = this
|
): Modifier =
|
||||||
.drawWithCache {
|
this
|
||||||
// bottom shadow offset in Px based on elevation
|
.drawWithCache {
|
||||||
val bottomOffsetPx = elevation.toPx()
|
// bottom shadow offset in Px based on elevation
|
||||||
// Adjust the size to extend the bottom by the bottom shadow offset
|
val bottomOffsetPx = elevation.toPx()
|
||||||
val adjustedSize = Size(size.width, size.height + bottomOffsetPx)
|
// Adjust the size to extend the bottom by the bottom shadow offset
|
||||||
val outline = shape.createOutline(adjustedSize, layoutDirection, this)
|
val adjustedSize = Size(size.width, size.height + bottomOffsetPx)
|
||||||
val path = Path().apply { addOutline(outline) }
|
val outline = shape.createOutline(adjustedSize, layoutDirection, this)
|
||||||
onDrawWithContent {
|
val path = Path().apply { addOutline(outline) }
|
||||||
clipPath(path, ClipOp.Intersect) {
|
onDrawWithContent {
|
||||||
this@onDrawWithContent.drawContent()
|
clipPath(path, ClipOp.Intersect) {
|
||||||
|
this@onDrawWithContent.drawContent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
.shadow(elevation, shape, clip, ambientColor, spotColor)
|
||||||
.shadow(elevation, shape, clip, ambientColor, spotColor)
|
.background(
|
||||||
.background(
|
backgroundColor,
|
||||||
backgroundColor,
|
shape
|
||||||
shape
|
)
|
||||||
)
|
|
||||||
|
|
||||||
private fun Modifier.topOnlyShadow(
|
private fun Modifier.topOnlyShadow(
|
||||||
elevation: Dp,
|
elevation: Dp,
|
||||||
|
@ -143,20 +151,21 @@ private fun Modifier.topOnlyShadow(
|
||||||
clip: Boolean = elevation > 0.dp,
|
clip: Boolean = elevation > 0.dp,
|
||||||
ambientColor: Color = DefaultShadowColor,
|
ambientColor: Color = DefaultShadowColor,
|
||||||
spotColor: Color = DefaultShadowColor,
|
spotColor: Color = DefaultShadowColor,
|
||||||
): Modifier = this
|
): Modifier =
|
||||||
.drawWithCache {
|
this
|
||||||
// Adjust the size to extend the bottom by the bottom shadow offset
|
.drawWithCache {
|
||||||
val adjustedSize = Size(size.width, size.height)
|
// Adjust the size to extend the bottom by the bottom shadow offset
|
||||||
val outline = shape.createOutline(adjustedSize, layoutDirection, this)
|
val adjustedSize = Size(size.width, size.height)
|
||||||
val path = Path().apply { addOutline(outline) }
|
val outline = shape.createOutline(adjustedSize, layoutDirection, this)
|
||||||
onDrawWithContent {
|
val path = Path().apply { addOutline(outline) }
|
||||||
clipPath(path, ClipOp.Intersect) {
|
onDrawWithContent {
|
||||||
this@onDrawWithContent.drawContent()
|
clipPath(path, ClipOp.Intersect) {
|
||||||
|
this@onDrawWithContent.drawContent()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
.shadow(elevation, shape, clip, ambientColor, spotColor)
|
||||||
.shadow(elevation, shape, clip, ambientColor, spotColor)
|
.background(
|
||||||
.background(
|
backgroundColor,
|
||||||
backgroundColor,
|
shape
|
||||||
shape
|
)
|
||||||
)
|
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
package co.electriccoin.zcash.ui.screen.home.messages
|
package co.electriccoin.zcash.ui.screen.home.messages
|
||||||
|
|
||||||
sealed interface HomeMessageState
|
sealed interface HomeMessageState
|
||||||
|
|
|
@ -25,13 +25,14 @@ fun HomeMessageWrapper(
|
||||||
modifier = Modifier.padding(contentPadding)
|
modifier = Modifier.padding(contentPadding)
|
||||||
) {
|
) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(
|
modifier =
|
||||||
horizontal = 16.dp,
|
Modifier.padding(
|
||||||
vertical = 14.dp
|
horizontal = 16.dp,
|
||||||
),
|
vertical = 14.dp
|
||||||
|
),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
content = content
|
content = content
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,10 @@ import co.electriccoin.zcash.ui.design.theme.typography.ZashiTypography
|
||||||
import co.electriccoin.zcash.ui.design.util.stringRes
|
import co.electriccoin.zcash.ui.design.util.stringRes
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun WalletBackupMessage(state: WalletBackupMessageState, contentPadding: PaddingValues) {
|
fun WalletBackupMessage(
|
||||||
|
state: WalletBackupMessageState,
|
||||||
|
contentPadding: PaddingValues
|
||||||
|
) {
|
||||||
HomeMessageWrapper(
|
HomeMessageWrapper(
|
||||||
color = ZashiColors.Utility.Espresso.utilityEspresso100,
|
color = ZashiColors.Utility.Espresso.utilityEspresso100,
|
||||||
contentPadding = contentPadding,
|
contentPadding = contentPadding,
|
||||||
|
@ -54,10 +57,11 @@ fun WalletBackupMessage(state: WalletBackupMessageState, contentPadding: Padding
|
||||||
}
|
}
|
||||||
ZashiButton(
|
ZashiButton(
|
||||||
modifier = Modifier.height(36.dp),
|
modifier = Modifier.height(36.dp),
|
||||||
state = ButtonState(
|
state =
|
||||||
onClick = state.onClick,
|
ButtonState(
|
||||||
text = stringRes("Start")
|
onClick = state.onClick,
|
||||||
)
|
text = stringRes("Start")
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,13 +73,15 @@ data class WalletBackupMessageState(
|
||||||
|
|
||||||
@PreviewScreens
|
@PreviewScreens
|
||||||
@Composable
|
@Composable
|
||||||
private fun Preview() = ZcashTheme {
|
private fun Preview() =
|
||||||
BlankSurface {
|
ZcashTheme {
|
||||||
WalletBackupMessage(
|
BlankSurface {
|
||||||
state = WalletBackupMessageState(
|
WalletBackupMessage(
|
||||||
onClick = {}
|
state =
|
||||||
),
|
WalletBackupMessageState(
|
||||||
contentPadding = PaddingValues()
|
onClick = {}
|
||||||
)
|
),
|
||||||
|
contentPadding = PaddingValues()
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
package co.electriccoin.zcash.ui.screen.integrations
|
package co.electriccoin.zcash.ui.screen.integrations
|
||||||
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.activity.compose.BackHandler
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.window.DialogWindowProvider
|
import androidx.compose.ui.window.DialogWindowProvider
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import co.electriccoin.zcash.ui.design.LocalSheetStateManager
|
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.koin.androidx.compose.koinViewModel
|
import org.koin.androidx.compose.koinViewModel
|
||||||
import org.koin.core.parameter.parametersOf
|
import org.koin.core.parameter.parametersOf
|
||||||
|
@ -20,22 +15,10 @@ import org.koin.core.parameter.parametersOf
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun AndroidDialogIntegrations() {
|
fun AndroidDialogIntegrations() {
|
||||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
||||||
val sheetManager = LocalSheetStateManager.current
|
|
||||||
DisposableEffect(sheetState) {
|
|
||||||
sheetManager.onSheetOpened(sheetState)
|
|
||||||
onDispose {
|
|
||||||
sheetManager.onSheetDisposed(sheetState)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val parent = LocalView.current.parent
|
val parent = LocalView.current.parent
|
||||||
val viewModel = koinViewModel<IntegrationsViewModel> { parametersOf(true) }
|
val viewModel = koinViewModel<IntegrationsViewModel> { parametersOf(true) }
|
||||||
val state by viewModel.state.collectAsStateWithLifecycle()
|
val state by viewModel.state.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
BackHandler(enabled = state != null) {
|
|
||||||
state?.onBack?.invoke()
|
|
||||||
}
|
|
||||||
|
|
||||||
SideEffect {
|
SideEffect {
|
||||||
(parent as? DialogWindowProvider)?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
(parent as? DialogWindowProvider)?.window?.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
||||||
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
||||||
|
@ -44,15 +27,7 @@ fun AndroidDialogIntegrations() {
|
||||||
state?.let {
|
state?.let {
|
||||||
IntegrationsDialogView(
|
IntegrationsDialogView(
|
||||||
state = it,
|
state = it,
|
||||||
sheetState = sheetState,
|
|
||||||
onDismissRequest = {
|
|
||||||
it.onBack()
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
sheetState.show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,10 @@ import androidx.compose.ui.text.style.TextAlign
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import co.electriccoin.zcash.ui.R
|
import co.electriccoin.zcash.ui.R
|
||||||
import co.electriccoin.zcash.ui.design.component.HorizontalSpacer
|
import co.electriccoin.zcash.ui.design.component.HorizontalSpacer
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiModalBottomSheet
|
import co.electriccoin.zcash.ui.design.component.ZashiScreenModalBottomSheet
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.rememberScreenModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
||||||
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
||||||
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
||||||
|
@ -38,16 +39,15 @@ import kotlinx.collections.immutable.persistentListOf
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
internal fun IntegrationsDialogView(
|
internal fun IntegrationsDialogView(
|
||||||
onDismissRequest: () -> Unit,
|
state: IntegrationsState,
|
||||||
sheetState: SheetState,
|
sheetState: SheetState = rememberScreenModalBottomSheetState(),
|
||||||
state: IntegrationsState
|
|
||||||
) {
|
) {
|
||||||
ZashiModalBottomSheet(
|
ZashiScreenModalBottomSheet(
|
||||||
|
state = state,
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
content = {
|
content = {
|
||||||
BottomSheetContent(state)
|
BottomSheetContent(state)
|
||||||
},
|
},
|
||||||
onDismissRequest = onDismissRequest
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,6 @@ fun BottomSheetContent(state: IntegrationsState) {
|
||||||
private fun IntegrationSettings() =
|
private fun IntegrationSettings() =
|
||||||
ZcashTheme {
|
ZcashTheme {
|
||||||
IntegrationsDialogView(
|
IntegrationsDialogView(
|
||||||
onDismissRequest = {},
|
|
||||||
sheetState =
|
sheetState =
|
||||||
rememberModalBottomSheetState(
|
rememberModalBottomSheetState(
|
||||||
skipHiddenState = true,
|
skipHiddenState = true,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
package co.electriccoin.zcash.ui.screen.integrations
|
package co.electriccoin.zcash.ui.screen.integrations
|
||||||
|
|
||||||
|
import co.electriccoin.zcash.ui.design.component.ModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
import co.electriccoin.zcash.ui.design.component.listitem.ZashiListItemState
|
||||||
import co.electriccoin.zcash.ui.design.util.StringResource
|
import co.electriccoin.zcash.ui.design.util.StringResource
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
|
|
||||||
data class IntegrationsState(
|
data class IntegrationsState(
|
||||||
val disabledInfo: StringResource?,
|
val disabledInfo: StringResource?,
|
||||||
val onBack: () -> Unit,
|
override val onBack: () -> Unit,
|
||||||
val items: ImmutableList<ZashiListItemState>,
|
val items: ImmutableList<ZashiListItemState>,
|
||||||
)
|
) : ModalBottomSheetState
|
||||||
|
|
|
@ -3,17 +3,11 @@ package co.electriccoin.zcash.ui.screen.restore.info
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.runtime.remember
|
import androidx.compose.runtime.remember
|
||||||
import androidx.compose.runtime.rememberCoroutineScope
|
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.window.DialogWindowProvider
|
import androidx.compose.ui.window.DialogWindowProvider
|
||||||
import co.electriccoin.zcash.ui.NavigationRouter
|
import co.electriccoin.zcash.ui.NavigationRouter
|
||||||
import co.electriccoin.zcash.ui.design.LocalSheetStateManager
|
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import org.koin.compose.koinInject
|
import org.koin.compose.koinInject
|
||||||
|
|
||||||
|
@ -28,25 +22,9 @@ fun AndroidSeedInfo() {
|
||||||
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
||||||
val sheetManager = LocalSheetStateManager.current
|
|
||||||
|
|
||||||
DisposableEffect(sheetState) {
|
|
||||||
sheetManager.onSheetOpened(sheetState)
|
|
||||||
onDispose {
|
|
||||||
sheetManager.onSheetDisposed(sheetState)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SeedInfoView(
|
SeedInfoView(
|
||||||
sheetState = sheetState,
|
|
||||||
state = remember { SeedInfoState(onBack = { navigationRouter.back() }) },
|
state = remember { SeedInfoState(onBack = { navigationRouter.back() }) },
|
||||||
onDismissRequest = { navigationRouter.back() }
|
|
||||||
)
|
)
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
sheetState.show()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Serializable
|
@Serializable
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package co.electriccoin.zcash.ui.screen.restore.info
|
package co.electriccoin.zcash.ui.screen.restore.info
|
||||||
|
|
||||||
|
import co.electriccoin.zcash.ui.design.component.ModalBottomSheetState
|
||||||
|
|
||||||
data class SeedInfoState(
|
data class SeedInfoState(
|
||||||
val onBack: () -> Unit
|
override val onBack: () -> Unit
|
||||||
)
|
) : ModalBottomSheetState
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package co.electriccoin.zcash.ui.screen.restore.info
|
package co.electriccoin.zcash.ui.screen.restore.info
|
||||||
|
|
||||||
import androidx.activity.compose.BackHandler
|
|
||||||
import androidx.compose.foundation.Image
|
import androidx.compose.foundation.Image
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
@ -28,8 +27,9 @@ import androidx.compose.ui.text.withStyle
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import co.electriccoin.zcash.ui.R
|
import co.electriccoin.zcash.ui.R
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiButton
|
import co.electriccoin.zcash.ui.design.component.ZashiButton
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiModalBottomSheet
|
import co.electriccoin.zcash.ui.design.component.ZashiScreenModalBottomSheet
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.rememberScreenModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
||||||
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
||||||
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
||||||
|
@ -38,19 +38,15 @@ import co.electriccoin.zcash.ui.design.theme.typography.ZashiTypography
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
internal fun SeedInfoView(
|
internal fun SeedInfoView(
|
||||||
onDismissRequest: () -> Unit,
|
|
||||||
state: SeedInfoState,
|
state: SeedInfoState,
|
||||||
sheetState: SheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true),
|
sheetState: SheetState = rememberScreenModalBottomSheetState(),
|
||||||
) {
|
) {
|
||||||
ZashiModalBottomSheet(
|
ZashiScreenModalBottomSheet(
|
||||||
|
state = state,
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
content = {
|
content = {
|
||||||
BackHandler {
|
|
||||||
state.onBack()
|
|
||||||
}
|
|
||||||
Content(state)
|
Content(state)
|
||||||
},
|
},
|
||||||
onDismissRequest = onDismissRequest
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,6 +128,5 @@ private fun Preview() =
|
||||||
initialValue = SheetValue.Expanded,
|
initialValue = SheetValue.Expanded,
|
||||||
),
|
),
|
||||||
state = SeedInfoState { },
|
state = SeedInfoState { },
|
||||||
onDismissRequest = {}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,13 +18,14 @@ fun AndroidSeedBackup() {
|
||||||
val viewModel = koinActivityViewModel<WalletViewModel>()
|
val viewModel = koinActivityViewModel<WalletViewModel>()
|
||||||
val appBarState by viewModel.walletStateInformation.collectAsStateWithLifecycle()
|
val appBarState by viewModel.walletStateInformation.collectAsStateWithLifecycle()
|
||||||
val navigationRouter = koinInject<NavigationRouter>()
|
val navigationRouter = koinInject<NavigationRouter>()
|
||||||
val state = remember {
|
val state =
|
||||||
SeedBackupState(
|
remember {
|
||||||
onBack = { navigationRouter.back() },
|
SeedBackupState(
|
||||||
onNextClick = { navigationRouter.replace(SeedRecovery) },
|
onBack = { navigationRouter.back() },
|
||||||
onInfoClick = { navigationRouter.forward(SeedInfo) }
|
onNextClick = { navigationRouter.replace(SeedRecovery) },
|
||||||
)
|
onInfoClick = { navigationRouter.forward(SeedInfo) }
|
||||||
}
|
)
|
||||||
|
}
|
||||||
|
|
||||||
BackHandler {
|
BackHandler {
|
||||||
state.onBack()
|
state.onBack()
|
||||||
|
|
|
@ -157,10 +157,11 @@ private fun Content(
|
||||||
VerticalSpacer(24.dp)
|
VerticalSpacer(24.dp)
|
||||||
|
|
||||||
ZashiButton(
|
ZashiButton(
|
||||||
state = ButtonState(
|
state =
|
||||||
text = stringRes(stringResource(R.string.wallet_backup_btn)),
|
ButtonState(
|
||||||
onClick = state.onNextClick
|
text = stringRes(stringResource(R.string.wallet_backup_btn)),
|
||||||
),
|
onClick = state.onNextClick
|
||||||
|
),
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -202,10 +203,11 @@ private fun Preview() =
|
||||||
ZcashTheme {
|
ZcashTheme {
|
||||||
SeedBackupView(
|
SeedBackupView(
|
||||||
appBarState = TopAppBarSubTitleState.None,
|
appBarState = TopAppBarSubTitleState.None,
|
||||||
state = SeedBackupState(
|
state =
|
||||||
onBack = {},
|
SeedBackupState(
|
||||||
onNextClick = {},
|
onBack = {},
|
||||||
onInfoClick = {}
|
onNextClick = {},
|
||||||
)
|
onInfoClick = {}
|
||||||
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,13 @@
|
||||||
package co.electriccoin.zcash.ui.screen.transactionfilters
|
package co.electriccoin.zcash.ui.screen.transactionfilters
|
||||||
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.activity.compose.BackHandler
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.window.DialogWindowProvider
|
import androidx.compose.ui.window.DialogWindowProvider
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import co.electriccoin.zcash.ui.design.LocalSheetStateManager
|
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
|
||||||
import co.electriccoin.zcash.ui.screen.transactionfilters.view.TransactionFiltersView
|
import co.electriccoin.zcash.ui.screen.transactionfilters.view.TransactionFiltersView
|
||||||
import co.electriccoin.zcash.ui.screen.transactionfilters.viewmodel.TransactionFiltersViewModel
|
import co.electriccoin.zcash.ui.screen.transactionfilters.viewmodel.TransactionFiltersViewModel
|
||||||
import org.koin.androidx.compose.koinViewModel
|
import org.koin.androidx.compose.koinViewModel
|
||||||
|
@ -22,16 +17,6 @@ import org.koin.androidx.compose.koinViewModel
|
||||||
fun AndroidTransactionFiltersList() {
|
fun AndroidTransactionFiltersList() {
|
||||||
val viewModel = koinViewModel<TransactionFiltersViewModel>()
|
val viewModel = koinViewModel<TransactionFiltersViewModel>()
|
||||||
val state by viewModel.state.collectAsStateWithLifecycle()
|
val state by viewModel.state.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
||||||
val sheetManager = LocalSheetStateManager.current
|
|
||||||
DisposableEffect(sheetState) {
|
|
||||||
sheetManager.onSheetOpened(sheetState)
|
|
||||||
onDispose {
|
|
||||||
sheetManager.onSheetDisposed(sheetState)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val parent = LocalView.current.parent
|
val parent = LocalView.current.parent
|
||||||
|
|
||||||
SideEffect {
|
SideEffect {
|
||||||
|
@ -41,15 +26,5 @@ fun AndroidTransactionFiltersList() {
|
||||||
|
|
||||||
TransactionFiltersView(
|
TransactionFiltersView(
|
||||||
state = state,
|
state = state,
|
||||||
sheetState = sheetState,
|
|
||||||
onDismissRequest = state?.onBack ?: {}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
sheetState.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
BackHandler(state != null) {
|
|
||||||
state?.onBack?.invoke()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
package co.electriccoin.zcash.ui.screen.transactionfilters.model
|
package co.electriccoin.zcash.ui.screen.transactionfilters.model
|
||||||
|
|
||||||
import co.electriccoin.zcash.ui.design.component.ButtonState
|
import co.electriccoin.zcash.ui.design.component.ButtonState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.ModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.util.StringResource
|
import co.electriccoin.zcash.ui.design.util.StringResource
|
||||||
|
|
||||||
data class TransactionFiltersState(
|
data class TransactionFiltersState(
|
||||||
val filters: List<TransactionFilterState>,
|
val filters: List<TransactionFilterState>,
|
||||||
val onBack: () -> Unit,
|
override val onBack: () -> Unit,
|
||||||
val primaryButton: ButtonState,
|
val primaryButton: ButtonState,
|
||||||
val secondaryButton: ButtonState
|
val secondaryButton: ButtonState
|
||||||
)
|
) : ModalBottomSheetState
|
||||||
|
|
||||||
data class TransactionFilterState(
|
data class TransactionFilterState(
|
||||||
val text: StringResource,
|
val text: StringResource,
|
||||||
|
|
|
@ -35,8 +35,9 @@ import co.electriccoin.zcash.ui.design.component.ZashiButtonDefaults
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiChipButton
|
import co.electriccoin.zcash.ui.design.component.ZashiChipButton
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiChipButtonDefaults
|
import co.electriccoin.zcash.ui.design.component.ZashiChipButtonDefaults
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiChipButtonState
|
import co.electriccoin.zcash.ui.design.component.ZashiChipButtonState
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiModalBottomSheet
|
import co.electriccoin.zcash.ui.design.component.ZashiScreenModalBottomSheet
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.rememberScreenModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
||||||
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
||||||
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
||||||
|
@ -47,16 +48,15 @@ import co.electriccoin.zcash.ui.screen.transactionfilters.model.TransactionFilte
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
internal fun TransactionFiltersView(
|
internal fun TransactionFiltersView(
|
||||||
onDismissRequest: () -> Unit,
|
state: TransactionFiltersState?,
|
||||||
sheetState: SheetState,
|
sheetState: SheetState = rememberScreenModalBottomSheetState(),
|
||||||
state: TransactionFiltersState?
|
|
||||||
) {
|
) {
|
||||||
ZashiModalBottomSheet(
|
ZashiScreenModalBottomSheet(
|
||||||
|
state = state,
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
content = {
|
content = {
|
||||||
BottomSheetContent(state)
|
BottomSheetContent(state)
|
||||||
},
|
},
|
||||||
onDismissRequest = onDismissRequest
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,6 @@ private fun Preview() =
|
||||||
ZcashTheme {
|
ZcashTheme {
|
||||||
TransactionFiltersView(
|
TransactionFiltersView(
|
||||||
state = TransactionFiltersStateFixture.new(),
|
state = TransactionFiltersStateFixture.new(),
|
||||||
onDismissRequest = {},
|
|
||||||
sheetState =
|
sheetState =
|
||||||
rememberModalBottomSheetState(
|
rememberModalBottomSheetState(
|
||||||
skipHiddenState = true,
|
skipHiddenState = true,
|
||||||
|
|
|
@ -1,23 +1,15 @@
|
||||||
package co.electriccoin.zcash.ui.screen.transactionnote
|
package co.electriccoin.zcash.ui.screen.transactionnote
|
||||||
|
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
import androidx.activity.compose.BackHandler
|
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
import androidx.compose.material3.SheetValue.Expanded
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
|
||||||
import androidx.compose.runtime.SideEffect
|
import androidx.compose.runtime.SideEffect
|
||||||
import androidx.compose.runtime.getValue
|
import androidx.compose.runtime.getValue
|
||||||
import androidx.compose.runtime.snapshotFlow
|
|
||||||
import androidx.compose.ui.platform.LocalView
|
import androidx.compose.ui.platform.LocalView
|
||||||
import androidx.compose.ui.window.DialogWindowProvider
|
import androidx.compose.ui.window.DialogWindowProvider
|
||||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||||
import co.electriccoin.zcash.ui.design.LocalSheetStateManager
|
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
|
||||||
import co.electriccoin.zcash.ui.screen.transactionnote.view.TransactionNoteView
|
import co.electriccoin.zcash.ui.screen.transactionnote.view.TransactionNoteView
|
||||||
import co.electriccoin.zcash.ui.screen.transactionnote.viewmodel.TransactionNoteViewModel
|
import co.electriccoin.zcash.ui.screen.transactionnote.viewmodel.TransactionNoteViewModel
|
||||||
import kotlinx.coroutines.cancel
|
|
||||||
import org.koin.androidx.compose.koinViewModel
|
import org.koin.androidx.compose.koinViewModel
|
||||||
import org.koin.core.parameter.parametersOf
|
import org.koin.core.parameter.parametersOf
|
||||||
|
|
||||||
|
@ -26,15 +18,6 @@ import org.koin.core.parameter.parametersOf
|
||||||
fun AndroidTransactionNote(transactionNote: TransactionNote) {
|
fun AndroidTransactionNote(transactionNote: TransactionNote) {
|
||||||
val viewModel = koinViewModel<TransactionNoteViewModel> { parametersOf(transactionNote) }
|
val viewModel = koinViewModel<TransactionNoteViewModel> { parametersOf(transactionNote) }
|
||||||
val state by viewModel.state.collectAsStateWithLifecycle()
|
val state by viewModel.state.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
|
|
||||||
val sheetManager = LocalSheetStateManager.current
|
|
||||||
DisposableEffect(sheetState) {
|
|
||||||
sheetManager.onSheetOpened(sheetState)
|
|
||||||
onDispose {
|
|
||||||
sheetManager.onSheetDisposed(sheetState)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val parent = LocalView.current.parent
|
val parent = LocalView.current.parent
|
||||||
|
|
||||||
SideEffect {
|
SideEffect {
|
||||||
|
@ -42,25 +25,5 @@ fun AndroidTransactionNote(transactionNote: TransactionNote) {
|
||||||
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
(parent as? DialogWindowProvider)?.window?.setDimAmount(0f)
|
||||||
}
|
}
|
||||||
|
|
||||||
TransactionNoteView(
|
TransactionNoteView(state = state)
|
||||||
state = state,
|
|
||||||
sheetState = sheetState,
|
|
||||||
onDismissRequest = state.onBack,
|
|
||||||
)
|
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
sheetState.show()
|
|
||||||
}
|
|
||||||
|
|
||||||
LaunchedEffect(Unit) {
|
|
||||||
snapshotFlow { sheetState.currentValue }.collect {
|
|
||||||
if (it == Expanded) {
|
|
||||||
this.cancel()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BackHandler {
|
|
||||||
state.onBack()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
package co.electriccoin.zcash.ui.screen.transactionnote.model
|
package co.electriccoin.zcash.ui.screen.transactionnote.model
|
||||||
|
|
||||||
import co.electriccoin.zcash.ui.design.component.ButtonState
|
import co.electriccoin.zcash.ui.design.component.ButtonState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.ModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.component.TextFieldState
|
import co.electriccoin.zcash.ui.design.component.TextFieldState
|
||||||
import co.electriccoin.zcash.ui.design.util.StringResource
|
import co.electriccoin.zcash.ui.design.util.StringResource
|
||||||
import co.electriccoin.zcash.ui.design.util.StyledStringResource
|
import co.electriccoin.zcash.ui.design.util.StyledStringResource
|
||||||
|
|
||||||
data class TransactionNoteState(
|
data class TransactionNoteState(
|
||||||
val onBack: () -> Unit,
|
override val onBack: () -> Unit,
|
||||||
val title: StringResource,
|
val title: StringResource,
|
||||||
val note: TextFieldState,
|
val note: TextFieldState,
|
||||||
val noteCharacters: StyledStringResource,
|
val noteCharacters: StyledStringResource,
|
||||||
val primaryButton: ButtonState?,
|
val primaryButton: ButtonState?,
|
||||||
val secondaryButton: ButtonState?,
|
val secondaryButton: ButtonState?,
|
||||||
val negative: ButtonState?,
|
val negative: ButtonState?,
|
||||||
)
|
) : ModalBottomSheetState
|
||||||
|
|
|
@ -22,9 +22,10 @@ import co.electriccoin.zcash.ui.design.component.ButtonState
|
||||||
import co.electriccoin.zcash.ui.design.component.TextFieldState
|
import co.electriccoin.zcash.ui.design.component.TextFieldState
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiButton
|
import co.electriccoin.zcash.ui.design.component.ZashiButton
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiButtonDefaults
|
import co.electriccoin.zcash.ui.design.component.ZashiButtonDefaults
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiModalBottomSheet
|
import co.electriccoin.zcash.ui.design.component.ZashiScreenModalBottomSheet
|
||||||
import co.electriccoin.zcash.ui.design.component.ZashiTextField
|
import co.electriccoin.zcash.ui.design.component.ZashiTextField
|
||||||
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
import co.electriccoin.zcash.ui.design.component.rememberModalBottomSheetState
|
||||||
|
import co.electriccoin.zcash.ui.design.component.rememberScreenModalBottomSheetState
|
||||||
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
import co.electriccoin.zcash.ui.design.newcomponent.PreviewScreens
|
||||||
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
||||||
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
import co.electriccoin.zcash.ui.design.theme.colors.ZashiColors
|
||||||
|
@ -38,16 +39,15 @@ import co.electriccoin.zcash.ui.screen.transactionnote.model.TransactionNoteStat
|
||||||
@Composable
|
@Composable
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
internal fun TransactionNoteView(
|
internal fun TransactionNoteView(
|
||||||
onDismissRequest: () -> Unit,
|
|
||||||
sheetState: SheetState,
|
|
||||||
state: TransactionNoteState,
|
state: TransactionNoteState,
|
||||||
|
sheetState: SheetState = rememberScreenModalBottomSheetState(),
|
||||||
) {
|
) {
|
||||||
ZashiModalBottomSheet(
|
ZashiScreenModalBottomSheet(
|
||||||
|
state = state,
|
||||||
sheetState = sheetState,
|
sheetState = sheetState,
|
||||||
content = {
|
content = {
|
||||||
BottomSheetContent(state)
|
BottomSheetContent(state)
|
||||||
},
|
},
|
||||||
onDismissRequest = onDismissRequest
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,7 +147,6 @@ private fun Preview() =
|
||||||
secondaryButton = null,
|
secondaryButton = null,
|
||||||
negative = ButtonState(stringRes("Delete note")),
|
negative = ButtonState(stringRes("Delete note")),
|
||||||
),
|
),
|
||||||
onDismissRequest = {},
|
|
||||||
sheetState =
|
sheetState =
|
||||||
rememberModalBottomSheetState(
|
rememberModalBottomSheetState(
|
||||||
skipHiddenState = true,
|
skipHiddenState = true,
|
||||||
|
|
Loading…
Reference in New Issue