Skip to content

Commit

Permalink
Replace page column with Scaffold
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Jun 18, 2024
1 parent 3a8c24e commit b196e25
Show file tree
Hide file tree
Showing 20 changed files with 1,165 additions and 966 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package io.horizontalsystems.bankwallet.modules.addtoken

import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.Icon
import androidx.compose.material.Scaffold
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
Expand Down Expand Up @@ -38,9 +35,11 @@ import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
import io.horizontalsystems.bankwallet.ui.compose.components.CellUniversalLawrenceSection
import io.horizontalsystems.bankwallet.ui.compose.components.FormsInput
import io.horizontalsystems.bankwallet.ui.compose.components.FormsInputStateWarning
import io.horizontalsystems.bankwallet.ui.compose.components.HSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton
import io.horizontalsystems.bankwallet.ui.compose.components.MenuItem
import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.body_leah
import io.horizontalsystems.bankwallet.ui.compose.components.subhead1_grey
import io.horizontalsystems.core.SnackbarDuration
Expand Down Expand Up @@ -116,26 +115,30 @@ private fun AddTokenScreen(
}
}

Column(modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)) {
AppBar(
title = stringResource(R.string.AddToken_Title),
navigationIcon = {
HsBackButton(onClick = closeScreen)
},
menuItems = listOf(
MenuItem(
title = TranslatableString.ResString(R.string.Button_Add),
onClick = viewModel::onAddClick,
enabled = uiState.addButtonEnabled
Scaffold(
backgroundColor = ComposeAppTheme.colors.tyler,
topBar = {
AppBar(
title = stringResource(R.string.AddToken_Title),
navigationIcon = {
HsBackButton(onClick = closeScreen)
},
menuItems = listOf(
MenuItem(
title = TranslatableString.ResString(R.string.Button_Add),
onClick = viewModel::onAddClick,
enabled = uiState.addButtonEnabled
)
)
)
)
},
) { innerPaddings ->
Column(
modifier = Modifier
.weight(1f)
.padding(innerPaddings)
.verticalScroll(rememberScrollState())
) {
Spacer(modifier = Modifier.height(12.dp))
VSpacer(12.dp)

CellUniversalLawrenceSection(
listOf {
Expand All @@ -149,7 +152,7 @@ private fun AddTokenScreen(
painter = painterResource(R.drawable.ic_blocks_24),
contentDescription = null
)
Spacer(modifier = Modifier.width(16.dp))
HSpacer(16.dp)
body_leah(
text = stringResource(R.string.AddToken_Blockchain),
modifier = Modifier.weight(1f)
Expand All @@ -167,7 +170,7 @@ private fun AddTokenScreen(
}
)

Spacer(modifier = Modifier.height(32.dp))
VSpacer(32.dp)

FormsInput(
modifier = Modifier.padding(horizontal = 16.dp),
Expand All @@ -179,7 +182,7 @@ private fun AddTokenScreen(
viewModel.onEnterText(it)
}

Spacer(modifier = Modifier.height(32.dp))
VSpacer(32.dp)

uiState.tokenInfo?.let { tokenInfo ->
CellUniversalLawrenceSection(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.Scaffold
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
Expand Down Expand Up @@ -119,56 +121,75 @@ fun BalanceForAccount(navController: NavController, accountViewItem: AccountView
)
}
) {
Column {
AppBar(
title = {
BalanceTitleRow(navController, accountViewItem.name)
},
menuItems = buildList {
if (accountViewItem.type.supportsWalletConnect) {
add(
MenuItem(
title = TranslatableString.ResString(R.string.WalletConnect_NewConnect),
icon = R.drawable.ic_qr_scan_20,
onClick = {
when (val state = viewModel.getWalletConnectSupportState()) {
WCManager.SupportState.Supported -> {
qrScannerLauncher.launch(QRScannerActivity.getScanQrIntent(context, true))

stat(page = StatPage.Balance, event = StatEvent.Open(StatPage.ScanQrCode))
}

WCManager.SupportState.NotSupportedDueToNoActiveAccount -> {
navController.slideFromBottom(R.id.wcErrorNoAccountFragment)
}

is WCManager.SupportState.NotSupportedDueToNonBackedUpAccount -> {
val text = Translator.getString(R.string.WalletConnect_Error_NeedBackup)
navController.slideFromBottom(
R.id.backupRequiredDialog,
BackupRequiredDialog.Input(state.account, text)
)

stat(page = StatPage.Balance, event = StatEvent.Open(StatPage.BackupRequired))
}

is WCManager.SupportState.NotSupported -> {
navController.slideFromBottom(
R.id.wcAccountTypeNotSupportedDialog,
WCAccountTypeNotSupportedDialog.Input(state.accountTypeDescription)
)
Scaffold(
backgroundColor = ComposeAppTheme.colors.tyler,
topBar = {
AppBar(
title = {
BalanceTitleRow(navController, accountViewItem.name)
},
menuItems = buildList {
if (accountViewItem.type.supportsWalletConnect) {
add(
MenuItem(
title = TranslatableString.ResString(R.string.WalletConnect_NewConnect),
icon = R.drawable.ic_qr_scan_20,
onClick = {
when (val state =
viewModel.getWalletConnectSupportState()) {
WCManager.SupportState.Supported -> {
qrScannerLauncher.launch(
QRScannerActivity.getScanQrIntent(context, true)
)

stat(
page = StatPage.Balance,
event = StatEvent.Open(StatPage.ScanQrCode)
)
}

WCManager.SupportState.NotSupportedDueToNoActiveAccount -> {
navController.slideFromBottom(R.id.wcErrorNoAccountFragment)
}

is WCManager.SupportState.NotSupportedDueToNonBackedUpAccount -> {
val text =
Translator.getString(R.string.WalletConnect_Error_NeedBackup)
navController.slideFromBottom(
R.id.backupRequiredDialog,
BackupRequiredDialog.Input(state.account, text)
)

stat(
page = StatPage.Balance,
event = StatEvent.Open(StatPage.BackupRequired)
)
}

is WCManager.SupportState.NotSupported -> {
navController.slideFromBottom(
R.id.wcAccountTypeNotSupportedDialog,
WCAccountTypeNotSupportedDialog.Input(state.accountTypeDescription)
)
}
}
}
}
)
)
)
}
}
}
)

)
}
) { paddingValues ->
val uiState = viewModel.uiState

Crossfade(uiState.viewState, label = "") { viewState ->
Crossfade(
targetState = uiState.viewState,
modifier = Modifier
.padding(paddingValues)
.fillMaxSize(),
label = ""
) { viewState ->
when (viewState) {
ViewState.Success -> {
val balanceViewItems = uiState.balanceViewItems
Expand All @@ -178,7 +199,7 @@ fun BalanceForAccount(navController: NavController, accountViewItem: AccountView
accountViewItem,
navController,
uiState,
viewModel.totalUiState
viewModel.totalUiState,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,23 @@
package io.horizontalsystems.bankwallet.modules.basecurrency

import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.material.ModalBottomSheetValue
import androidx.compose.material.Scaffold
import androidx.compose.material.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.rememberCoroutineScope
Expand All @@ -18,7 +33,17 @@ import androidx.navigation.NavController
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.BaseComposeFragment
import io.horizontalsystems.bankwallet.ui.compose.ComposeAppTheme
import io.horizontalsystems.bankwallet.ui.compose.components.*
import io.horizontalsystems.bankwallet.ui.compose.components.AppBar
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryTransparent
import io.horizontalsystems.bankwallet.ui.compose.components.ButtonPrimaryYellow
import io.horizontalsystems.bankwallet.ui.compose.components.CellUniversalLawrenceSection
import io.horizontalsystems.bankwallet.ui.compose.components.HeaderText
import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton
import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal
import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.compose.components.body_leah
import io.horizontalsystems.bankwallet.ui.compose.components.subhead2_grey
import io.horizontalsystems.bankwallet.ui.extensions.BottomSheetHeader
import kotlinx.coroutines.launch

Expand Down Expand Up @@ -80,29 +105,32 @@ private fun BaseCurrencyScreen(
)
}
) {
Column(
modifier = Modifier.background(color = ComposeAppTheme.colors.tyler)
) {
AppBar(
title = stringResource(R.string.SettingsCurrency_Title),
navigationIcon = {
HsBackButton(onClick = { navController.popBackStack() })
}
)
Scaffold(
backgroundColor = ComposeAppTheme.colors.tyler,
topBar = {
AppBar(
title = stringResource(R.string.SettingsCurrency_Title),
navigationIcon = {
HsBackButton(onClick = { navController.popBackStack() })
}
)
}
) { paddingValues ->
Column(
Modifier.verticalScroll(rememberScrollState())
Modifier
.verticalScroll(rememberScrollState())
.padding(paddingValues)
) {
Spacer(Modifier.height(12.dp))
VSpacer(12.dp)
CellUniversalLawrenceSection(viewModel.popularItems) { item ->
CurrencyCell(
item.currency.code,
item.currency.symbol,
item.currency.flag,
item.selected,
{ viewModel.onSelectBaseCurrency(item.currency) }
)
item.selected
) { viewModel.onSelectBaseCurrency(item.currency) }
}
Spacer(Modifier.height(24.dp))
VSpacer(24.dp)
HeaderText(
stringResource(R.string.SettingsCurrency_Other)
)
Expand All @@ -111,11 +139,10 @@ private fun BaseCurrencyScreen(
item.currency.code,
item.currency.symbol,
item.currency.flag,
item.selected,
{ viewModel.onSelectBaseCurrency(item.currency) }
)
item.selected
) { viewModel.onSelectBaseCurrency(item.currency) }
}
Spacer(Modifier.height(24.dp))
VSpacer(24.dp)
}
}
}
Expand Down
Loading

0 comments on commit b196e25

Please sign in to comment.