Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #733 from ILIYANGERMANOV/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ILIYANGERMANOV authored Apr 15, 2022
2 parents 344ca58 + f309844 commit 16d25fa
Show file tree
Hide file tree
Showing 9 changed files with 117 additions and 37 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.domain.logic.zip.model
package com.ivy.wallet.domain

import com.ivy.wallet.domain.data.entity.*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import android.net.Uri
import androidx.core.net.toUri
import com.google.gson.*
import com.google.gson.reflect.TypeToken
import com.ivy.wallet.domain.IvyWalletCompleteData
import com.ivy.wallet.domain.logic.csv.model.ImportResult
import com.ivy.wallet.domain.logic.zip.model.IvyWalletCompleteData
import com.ivy.wallet.io.persistence.SharedPrefs
import com.ivy.wallet.io.persistence.dao.*
import com.ivy.wallet.utils.ioThread
Expand Down Expand Up @@ -102,6 +102,9 @@ class ExportZipLogic(
hashmap[SharedPrefs.APP_LOCK_ENABLED] =
sharedPrefs.getBoolean(SharedPrefs.APP_LOCK_ENABLED, false).toString()

hashmap[SharedPrefs.HIDE_CURRENT_BALANCE] =
sharedPrefs.getBoolean(SharedPrefs.HIDE_CURRENT_BALANCE, false).toString()

return hashmap
}

Expand Down Expand Up @@ -250,6 +253,11 @@ class ExportZipLogic(
(completeData.sharedPrefs[SharedPrefs.APP_LOCK_ENABLED] ?: "false").toBoolean()
)

sharedPrefs.putBoolean(
SharedPrefs.HIDE_CURRENT_BALANCE,
(completeData.sharedPrefs[SharedPrefs.HIDE_CURRENT_BALANCE] ?: "false").toBoolean()
)

plannedPayments.await()
settings.await()

Expand Down
44 changes: 29 additions & 15 deletions app/src/main/java/com/ivy/wallet/ui/home/HomeHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ internal fun HomeHeader(
currency: String,
balance: Double,
bufferDiff: Double,
hideCurrentBalance: Boolean = false,

onShowMonthModal: () -> Unit,
onBalanceClick: () -> Unit,
onHiddenBalanceClick: () -> Unit = {},

onSelectNextMonth: () -> Unit,
onSelectPreviousMonth: () -> Unit,
Expand All @@ -69,9 +71,11 @@ internal fun HomeHeader(
period = period,
currency = currency,
balance = balance,
hideCurrentBalance = hideCurrentBalance,

onShowMonthModal = onShowMonthModal,
onBalanceClick = onBalanceClick,
onHiddenBalanceClick = onHiddenBalanceClick,

onSelectNextMonth = onSelectNextMonth,
onSelectPreviousMonth = onSelectPreviousMonth
Expand All @@ -95,9 +99,11 @@ private fun HeaderStickyRow(

currency: String,
balance: Double,
hideCurrentBalance: Boolean = false,

onShowMonthModal: () -> Unit,
onBalanceClick: () -> Unit,
onHiddenBalanceClick: () -> Unit = {},

onSelectNextMonth: () -> Unit,
onSelectPreviousMonth: () -> Unit,
Expand Down Expand Up @@ -127,11 +133,16 @@ private fun HeaderStickyRow(
modifier = Modifier
.alpha(alpha = 1f - percentExpanded)
.clickableNoIndication {
onBalanceClick()
if (hideCurrentBalance)
onHiddenBalanceClick()
else
onBalanceClick()

},
currency = currency,
balance = balance,
shortenBigNumbers = true
shortenBigNumbers = true,
hiddenMode = hideCurrentBalance
)
}
}
Expand Down Expand Up @@ -176,7 +187,8 @@ fun CashFlowInfo(
hideCurrentBalance: Boolean,

onOpenMoreMenu: () -> Unit,
onBalanceClick: () -> Unit
onBalanceClick: () -> Unit,
onHiddenBalanceClick: () -> Unit = {}
) {
Column(
modifier = Modifier
Expand All @@ -187,19 +199,21 @@ fun CashFlowInfo(
}
)
) {
if (!hideCurrentBalance) {
BalanceRow(
modifier = Modifier
.padding(horizontal = 20.dp)
.clickableNoIndication {
BalanceRow(
modifier = Modifier
.padding(horizontal = 20.dp)
.clickableNoIndication {
if (hideCurrentBalance)
onHiddenBalanceClick()
else
onBalanceClick()
}
.testTag("home_balance"),
currency = currency,
balance = balance,
shortenBigNumbers = true
)
}
}
.testTag("home_balance"),
currency = currency,
balance = balance,
shortenBigNumbers = true,
hiddenMode = hideCurrentBalance
)

Spacer(modifier = Modifier.height(24.dp))

Expand Down
11 changes: 9 additions & 2 deletions app/src/main/java/com/ivy/wallet/ui/home/HomeTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,15 @@ fun BoxWithConstraintsScope.HomeTab(screen: Main) {
customerJourneyCards = state.customerJourneyCards,

onBalanceClick = viewModel::onBalanceClick,
onHiddenBalanceClick = viewModel::onHiddenBalanceClick,
onSwitchTheme = viewModel::switchTheme,
onSetBuffer = viewModel::setBuffer,
onSetCurrency = viewModel::setCurrency,
onSetPeriod = viewModel::setPeriod,
onPayOrGet = viewModel::payOrGet,
onDismissCustomerJourneyCard = viewModel::dismissCustomerJourneyCard,
onSelectNextMonth = viewModel::nextMonth,
onSelectPreviousMonth = viewModel::previousMonth
onSelectPreviousMonth = viewModel::previousMonth,
)
}

Expand Down Expand Up @@ -134,6 +135,7 @@ private fun BoxWithConstraintsScope.UI(
customerJourneyCards: List<CustomerJourneyCardData> = emptyList(),

onBalanceClick: () -> Unit = {},
onHiddenBalanceClick: () -> Unit = {},
onSwitchTheme: () -> Unit = {},
onSetCurrency: (String) -> Unit = {},
onSetBuffer: (Double) -> Unit = {},
Expand Down Expand Up @@ -192,6 +194,7 @@ private fun BoxWithConstraintsScope.UI(
currency = currencyCode,
balance = balance,
bufferDiff = bufferDiff,
hideCurrentBalance = hideCurrentBalance,

onShowMonthModal = {
choosePeriodModal = ChoosePeriodModalData(
Expand All @@ -201,6 +204,7 @@ private fun BoxWithConstraintsScope.UI(
onBalanceClick = {
onBalanceClick()
},
onHiddenBalanceClick = onHiddenBalanceClick,
onSelectNextMonth = onSelectNextMonth,
onSelectPreviousMonth = onSelectPreviousMonth
)
Expand All @@ -216,6 +220,7 @@ private fun BoxWithConstraintsScope.UI(
onBalanceClick = {
onBalanceClick()
},
onHiddenBalanceClick = onHiddenBalanceClick,

hideCurrentBalance = hideCurrentBalance,

Expand Down Expand Up @@ -312,6 +317,7 @@ fun HomeLazyColumn(

onOpenMoreMenu: () -> Unit,
onBalanceClick: () -> Unit,
onHiddenBalanceClick: () -> Unit = {},


period: TimePeriod,
Expand Down Expand Up @@ -399,7 +405,8 @@ fun HomeLazyColumn(
monthlyExpenses = monthlyExpenses,

onOpenMoreMenu = onOpenMoreMenu,
onBalanceClick = onBalanceClick
onBalanceClick = onBalanceClick,
onHiddenBalanceClick = onHiddenBalanceClick
)
}
item {
Expand Down
15 changes: 15 additions & 0 deletions app/src/main/java/com/ivy/wallet/ui/home/HomeViewModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import com.ivy.wallet.utils.TestIdlingResource
import com.ivy.wallet.utils.dateNowUTC
import com.ivy.wallet.utils.ioThread
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import javax.inject.Inject
Expand Down Expand Up @@ -197,6 +199,19 @@ class HomeViewModel @Inject constructor(
}
}

fun onHiddenBalanceClick() {
viewModelScope.launch(Dispatchers.Default) {
updateState {
it.copy(hideCurrentBalance = false)
}
//Showing Balance fow 5s
delay(5000)
updateState {
it.copy(hideCurrentBalance = true)
}
}
}

fun switchTheme() {
viewModelScope.launch {
TestIdlingResource.increment()
Expand Down
35 changes: 26 additions & 9 deletions app/src/main/java/com/ivy/wallet/ui/settings/SettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.lifecycle.viewmodel.compose.viewModel
import com.google.accompanist.coil.rememberCoilPainter
import com.google.accompanist.insets.navigationBarsPadding
Expand Down Expand Up @@ -269,6 +270,7 @@ private fun BoxWithConstraintsScope.UI(
lockApp = hideCurrentBalance,
onSetLockApp = onSetHideCurrentBalance,
text = "Hide balance",
description = "Click on the hidden balance to show the balance for 5s",
icon = R.drawable.ic_hide_m
)

Expand Down Expand Up @@ -546,7 +548,8 @@ private fun AppSwitch(
lockApp: Boolean,
onSetLockApp: (Boolean) -> Unit,
text: String,
icon: Int
description: String = "",
icon: Int,
) {
SettingsButtonRow(
onClick = {
Expand All @@ -562,16 +565,30 @@ private fun AppSwitch(

Spacer(Modifier.width(8.dp))

Text(
modifier = Modifier.padding(vertical = 20.dp),
text = text,
style = UI.typo.b2.style(
color = UI.colors.pureInverse,
fontWeight = FontWeight.Bold
Column(
Modifier
.weight(1f)
.padding(top = 20.dp, bottom = 20.dp, end = 8.dp)) {
Text(
text = text,
style = UI.typo.b2.style(
color = UI.colors.pureInverse,
fontWeight = FontWeight.Bold
)
)
)
if (description.isNotEmpty()) {
Text(
modifier = Modifier.padding(end = 8.dp),
text = description,
style = UI.typo.nB2.style(
color = Gray,
fontWeight = FontWeight.Normal
).copy(fontSize = 14.sp)
)
}
}

Spacer(Modifier.weight(1f))
//Spacer(Modifier.weight(1f))

IvySwitch(enabled = lockApp) {
onSetLockApp(it)
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/com/ivy/wallet/ui/theme/components/BalanceRow.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fun BalanceRowMedium(
balanceAmountPrefix: String? = null,
currencyUpfront: Boolean = true,
shortenBigNumbers: Boolean = false,
hiddenMode: Boolean = false,
) {
BalanceRow(
modifier = modifier,
Expand All @@ -41,6 +42,7 @@ fun BalanceRowMedium(
textColor = textColor,
currency = currency,
balance = balance,
hiddenMode = hiddenMode,
spacerCurrency = 12.dp,
spacerDecimal = 8.dp,
currencyFontSize = 24.sp,
Expand All @@ -62,6 +64,7 @@ fun BalanceRowMini(
balanceAmountPrefix: String? = null,
currencyUpfront: Boolean = true,
shortenBigNumbers: Boolean = false,
hiddenMode: Boolean = false,
) {
BalanceRow(
modifier = modifier,
Expand All @@ -70,6 +73,7 @@ fun BalanceRowMini(
textColor = textColor,
currency = currency,
balance = balance,
hiddenMode = hiddenMode,
spacerCurrency = 8.dp,
spacerDecimal = 4.dp,
currencyFontSize = 20.sp,
Expand All @@ -87,6 +91,7 @@ fun BalanceRow(
modifier: Modifier = Modifier,
currency: String,
balance: Double,
hiddenMode: Boolean = false,

textColor: Color = UI.colors.pureInverse,
decimalPaddingTop: Dp = 12.dp,
Expand Down Expand Up @@ -122,8 +127,11 @@ fun BalanceRow(
DecimalFormat("###,###").format(truncate(balance))
}
Text(
text = if (balanceAmountPrefix != null)
"$balanceAmountPrefix$integerPartFormatted" else integerPartFormatted,
text = when {
hiddenMode -> "****"
balanceAmountPrefix != null -> "$balanceAmountPrefix$integerPartFormatted"
else -> integerPartFormatted
},
style = if (integerFontSize == null) {
UI.typo.nH1.style(
fontWeight = FontWeight.ExtraBold,
Expand All @@ -144,7 +152,7 @@ fun BalanceRow(
modifier = Modifier
.align(Alignment.Top)
.padding(top = decimalPaddingTop),
text = decimalPartFormatted(currency, balance),
text = if (hiddenMode) "" else decimalPartFormatted(currency, balance),
style = if (decimalFontSize == null) {
UI.typo.nB1.style(
fontWeight = FontWeight.Bold,
Expand Down
19 changes: 15 additions & 4 deletions app/src/main/res/drawable/ic_hide_m.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<vector android:height="32dp" android:tint="#000000"
android:viewportHeight="24" android:viewportWidth="24"
android:width="32dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z"/>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="48dp"
android:height="48dp"
android:viewportWidth="24"
android:viewportHeight="24">
<group
android:pivotX="12"
android:pivotY="12"
android:scaleX="0.6"
android:scaleY="0.6">
<path
android:fillColor="@android:color/white"
android:pathData="M12,7c2.76,0 5,2.24 5,5 0,0.65 -0.13,1.26 -0.36,1.83l2.92,2.92c1.51,-1.26 2.7,-2.89 3.43,-4.75 -1.73,-4.39 -6,-7.5 -11,-7.5 -1.4,0 -2.74,0.25 -3.98,0.7l2.16,2.16C10.74,7.13 11.35,7 12,7zM2,4.27l2.28,2.28 0.46,0.46C3.08,8.3 1.78,10.02 1,12c1.73,4.39 6,7.5 11,7.5 1.55,0 3.03,-0.3 4.38,-0.84l0.42,0.42L19.73,22 21,20.73 3.27,3 2,4.27zM7.53,9.8l1.55,1.55c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.66 1.34,3 3,3 0.22,0 0.44,-0.03 0.65,-0.08l1.55,1.55c-0.67,0.33 -1.41,0.53 -2.2,0.53 -2.76,0 -5,-2.24 -5,-5 0,-0.79 0.2,-1.53 0.53,-2.2zM11.84,9.02l3.15,3.15 0.02,-0.16c0,-1.66 -1.34,-3 -3,-3l-0.17,0.01z" />

</group>
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import org.gradle.kotlin.dsl.project

object Project {
//Version
const val versionName = "3.1.1-fast"
const val versionCode = 103
const val versionName = "3.1.2-fast"
const val versionCode = 104

//Compile SDK & Build Tools
const val compileSdkVersion = 31
Expand Down

0 comments on commit 16d25fa

Please sign in to comment.