This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-issue-3484
- Loading branch information
Showing
15 changed files
with
731 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
screen/features/src/main/java/com/ivy/features/FeaturesUiEvent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
package com.ivy.features | ||
|
||
sealed interface FeaturesUiEvent { | ||
data class ToggleFeature(val index: Int) : FeaturesUiEvent | ||
data class ToggleFeature(val key: String) : FeaturesUiEvent | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
shared/domain/src/main/java/com/ivy/domain/features/FeatureGroup.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.ivy.domain.features | ||
|
||
enum class FeatureGroup { | ||
Category, Account, Other | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
shared/ui/core/src/main/java/com/ivy/ui/FormatMoneyUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.ivy.ui | ||
|
||
import android.content.Context | ||
import com.ivy.domain.features.Features | ||
import com.ivy.ui.time.DevicePreferences | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import java.text.DecimalFormat | ||
import java.text.DecimalFormatSymbols | ||
import javax.inject.Inject | ||
|
||
class FormatMoneyUseCase @Inject constructor( | ||
private val features: Features, | ||
private val devicePreferences: DevicePreferences, | ||
@ApplicationContext private val context: Context | ||
) { | ||
|
||
private val locale = devicePreferences.locale() | ||
private val withoutDecimalFormatter = DecimalFormat("###,###", DecimalFormatSymbols(locale)) | ||
private val withDecimalFormatter = DecimalFormat("###,###.00", DecimalFormatSymbols(locale)) | ||
|
||
suspend fun format(value: Double): String { | ||
val showDecimalPoint = features.showDecimalNumber.isEnabled(context) | ||
|
||
return when (showDecimalPoint) { | ||
true -> withDecimalFormatter.format(value) | ||
false -> withoutDecimalFormatter.format(value) | ||
} | ||
} | ||
} |
Oops, something went wrong.