Skip to content

Commit

Permalink
Apply new ui for tab settings
Browse files Browse the repository at this point in the history
  • Loading branch information
abdrasulov committed May 24, 2024
1 parent 7b51c6f commit 221b1cc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.D1
import io.horizontalsystems.bankwallet.ui.compose.components.HeaderText
import io.horizontalsystems.bankwallet.ui.compose.components.HsBackButton
import io.horizontalsystems.bankwallet.ui.compose.components.HsSwitch
import io.horizontalsystems.bankwallet.ui.compose.components.InfoText
import io.horizontalsystems.bankwallet.ui.compose.components.MultitextM1
import io.horizontalsystems.bankwallet.ui.compose.components.RowUniversal
import io.horizontalsystems.bankwallet.ui.compose.components.TextImportantWarning
Expand Down Expand Up @@ -159,7 +160,7 @@ fun AppearanceScreen(navController: NavController) {

HeaderText(text = stringResource(id = R.string.Appearance_Tab))
CellUniversalLawrenceSection(
listOf({
listOf {
RowUniversal(
modifier = Modifier.padding(horizontal = 16.dp),
) {
Expand All @@ -171,21 +172,26 @@ fun AppearanceScreen(navController: NavController) {
)

body_leah(
text = stringResource(id = R.string.Appearance_MarketsTab),
text = stringResource(id = R.string.Appearance_HideMarketsTab),
modifier = Modifier
.weight(1f)
.padding(horizontal = 16.dp)
)

HsSwitch(
checked = uiState.marketsTabEnabled,
checked = uiState.marketsTabHidden,
onCheckedChange = {
viewModel.onSetMarketTabsEnabled(it)
viewModel.onSetMarketTabsHidden(it)
}
)

}
}, {
}
)
Spacer(modifier = Modifier.height(24.dp))

HeaderText(text = stringResource(id = R.string.Appearance_BalanceTab))
CellUniversalLawrenceSection(
listOf {
RowUniversal(
modifier = Modifier.padding(horizontal = 16.dp),
) {
Expand All @@ -197,25 +203,27 @@ fun AppearanceScreen(navController: NavController) {
)

body_leah(
text = stringResource(id = R.string.Appearance_BalanceTabButtons),
text = stringResource(id = R.string.Appearance_HideBalanceTabButtons),
modifier = Modifier
.weight(1f)
.padding(horizontal = 16.dp)
)

HsSwitch(
checked = uiState.balanceTabButtonsEnabled,
checked = uiState.balanceTabButtonsHidden,
onCheckedChange = {
viewModel.onSetBalanceTabButtons(it)
viewModel.onSetBalanceTabButtonsHidden(it)
}
)

}
})
}
)
InfoText(
text = stringResource(R.string.Appearance_HideBalanceTabButtonsDescription),
paddingBottom = 24.dp
)
Spacer(modifier = Modifier.height(24.dp))

AnimatedVisibility(visible = uiState.marketsTabEnabled) {
AnimatedVisibility(visible = !uiState.marketsTabHidden) {
Column {
HeaderText(text = stringResource(id = R.string.Appearance_LaunchScreen))
CellUniversalLawrenceSection(uiState.launchScreenOptions.options) { option ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class AppearanceViewModel(
private var appIconOptions = appIconService.optionsFlow.value
private var themeOptions = themeService.optionsFlow.value
private var baseTokenOptions = buildBaseTokenSelect(baseTokenManager.baseTokenFlow.value)
private var marketsTabEnabled = localStorage.marketsTabEnabled
private var balanceTabButtonsEnabled = localStorage.balanceTabButtonsEnabled
private var marketsTabHidden = !localStorage.marketsTabEnabled
private var balanceTabButtonsHidden = !localStorage.balanceTabButtonsEnabled
private var balanceViewTypeOptions =
buildBalanceViewTypeSelect(balanceViewTypeManager.balanceViewTypeFlow.value)
private val currentLanguageDisplayName: String
Expand Down Expand Up @@ -86,10 +86,10 @@ class AppearanceViewModel(
themeOptions = themeOptions,
baseTokenOptions = baseTokenOptions,
balanceViewTypeOptions = balanceViewTypeOptions,
marketsTabEnabled = marketsTabEnabled,
marketsTabHidden = marketsTabHidden,
currentLanguage = currentLanguageDisplayName,
baseCurrencyCode = baseCurrencyCode,
balanceTabButtonsEnabled = balanceTabButtonsEnabled
balanceTabButtonsHidden = balanceTabButtonsHidden
)

private fun buildBaseTokenSelect(token: Token?): SelectOptional<Token> {
Expand Down Expand Up @@ -145,20 +145,20 @@ class AppearanceViewModel(
balanceViewTypeManager.setViewType(viewType)
}

fun onSetMarketTabsEnabled(enabled: Boolean) {
if (enabled.not() && (launchScreenOptions.selected == LaunchPage.Market || launchScreenOptions.selected == LaunchPage.Watchlist)) {
fun onSetMarketTabsHidden(hidden: Boolean) {
if (hidden && (launchScreenOptions.selected == LaunchPage.Market || launchScreenOptions.selected == LaunchPage.Watchlist)) {
launchScreenService.setLaunchScreen(LaunchPage.Auto)
}
localStorage.marketsTabEnabled = enabled
localStorage.marketsTabEnabled = !hidden

marketsTabEnabled = enabled
marketsTabHidden = hidden
emitState()
}

fun onSetBalanceTabButtons(enabled: Boolean) {
localStorage.balanceTabButtonsEnabled = enabled
fun onSetBalanceTabButtonsHidden(hidden: Boolean) {
localStorage.balanceTabButtonsEnabled = !hidden

balanceTabButtonsEnabled = enabled
balanceTabButtonsHidden = hidden
emitState()
}

Expand All @@ -170,8 +170,8 @@ data class AppearanceUIState(
val themeOptions: Select<ThemeType>,
val baseTokenOptions: SelectOptional<Token>,
val balanceViewTypeOptions: Select<BalanceViewType>,
val marketsTabEnabled: Boolean,
val marketsTabHidden: Boolean,
val currentLanguage: String,
val baseCurrencyCode: String,
val balanceTabButtonsEnabled: Boolean,
val balanceTabButtonsHidden: Boolean,
)
6 changes: 4 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -983,13 +983,15 @@

<string name="Appearance_Theme">THEME</string>
<string name="Appearance_Tab">TAB SETTINGS</string>
<string name="Appearance_BalanceTab">BALANCE TAB</string>
<string name="Appearance_LaunchScreen">LAUNCH SCREEN</string>
<string name="Appearance_AppIcon">APP ICON</string>
<string name="Appearance_BalanceConversion">BALANCE CONVERSION</string>
<string name="Appearance_BalanceValue">BALANCE VALUE</string>
<string name="Appearance_Warning_CloseApplication">Changing icon will close application</string>
<string name="Appearance_MarketsTab">Markets Tab</string>
<string name="Appearance_BalanceTabButtons">Balance Tab Buttons</string>
<string name="Appearance_HideMarketsTab">Hide Markets</string>
<string name="Appearance_HideBalanceTabButtons">Hide Buttons</string>
<string name="Appearance_HideBalanceTabButtonsDescription">This configuration hides the Send, Receive, and Swap buttons on Balance tab.</string>
<string name="Appearance_BalanceAutoHide">Balance Auto Hide</string>
<string name="Appearance_BalanceAutoHide_Description">Automatically hides balance each time the app is opened, regardless of previous preferences.</string>

Expand Down

0 comments on commit 221b1cc

Please sign in to comment.