Skip to content

Commit

Permalink
Add Balance Auto Hide setting to Appearance module
Browse files Browse the repository at this point in the history
  • Loading branch information
ealymbaev authored and esen committed Apr 24, 2023
1 parent 7da56b0 commit 84e9eee
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "off@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "off@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions UnstoppableWallet/UnstoppableWallet/Core/App.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ class App {
logRecordManager: logRecordManager,
deepLinkManager: deepLinkManager,
evmLabelManager: evmLabelManager,
balanceHiddenManager: balanceHiddenManager,
walletConnectV2SocketConnectionService: walletConnectV2SocketConnectionService,
nftMetadataSyncer: nftMetadataSyncer
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class AppManager {
private let logRecordManager: LogRecordManager
private let deepLinkManager: DeepLinkManager
private let evmLabelManager: EvmLabelManager
private let balanceHiddenManager: BalanceHiddenManager
private let walletConnectV2SocketConnectionService: WalletConnectV2SocketConnectionService
private let nftMetadataSyncer: NftMetadataSyncer

Expand All @@ -28,7 +29,7 @@ class AppManager {
kitCleaner: KitCleaner, debugLogger: DebugLogger?,
appVersionManager: AppVersionManager, rateAppManager: RateAppManager,
logRecordManager: LogRecordManager,
deepLinkManager: DeepLinkManager, evmLabelManager: EvmLabelManager,
deepLinkManager: DeepLinkManager, evmLabelManager: EvmLabelManager, balanceHiddenManager: BalanceHiddenManager,
walletConnectV2SocketConnectionService: WalletConnectV2SocketConnectionService, nftMetadataSyncer: NftMetadataSyncer
) {
self.accountManager = accountManager
Expand All @@ -44,6 +45,7 @@ class AppManager {
self.logRecordManager = logRecordManager
self.deepLinkManager = deepLinkManager
self.evmLabelManager = evmLabelManager
self.balanceHiddenManager = balanceHiddenManager
self.walletConnectV2SocketConnectionService = walletConnectV2SocketConnectionService
self.nftMetadataSyncer = nftMetadataSyncer
}
Expand Down Expand Up @@ -84,6 +86,7 @@ extension AppManager {

pinKit.didEnterBackground()
walletConnectV2SocketConnectionService.didEnterBackground()
balanceHiddenManager.didEnterBackground()
}

func willEnterForeground() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import StorageKit

class BalanceHiddenManager {
private let keyBalanceHidden = "wallet-balance-hidden"
private let keyBalanceAutoHide = "wallet-balance-auto-hide"

private let localStorage: StorageKit.ILocalStorage

Expand All @@ -14,6 +15,8 @@ class BalanceHiddenManager {
}
}

private(set) var balanceAutoHide: Bool

init(localStorage: StorageKit.ILocalStorage) {
self.localStorage = localStorage

Expand All @@ -25,6 +28,17 @@ class BalanceHiddenManager {
} else {
balanceHidden = false
}

balanceAutoHide = localStorage.value(for: keyBalanceAutoHide) ?? false

if balanceAutoHide {
set(balanceHidden: true)
}
}

private func set(balanceHidden: Bool) {
self.balanceHidden = balanceHidden
localStorage.set(value: balanceHidden, for: keyBalanceHidden)
}

}
Expand All @@ -36,8 +50,18 @@ extension BalanceHiddenManager {
}

func toggleBalanceHidden() {
balanceHidden = !balanceHidden
localStorage.set(value: balanceHidden, for: keyBalanceHidden)
set(balanceHidden: !balanceHidden)
}

func set(balanceAutoHide: Bool) {
self.balanceAutoHide = balanceAutoHide
localStorage.set(value: balanceAutoHide, for: keyBalanceAutoHide)
}

func didEnterBackground() {
if balanceAutoHide {
set(balanceHidden: true)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AppearanceAppIconsCell: BaseThemeCell {
self.onSelect = onSelect

collectionView.reloadData()
collectionView.layoutIfNeeded()
}

static func height(viewItemsCount: Int) -> CGFloat {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ struct AppearanceModule {
launchScreenManager: App.shared.launchScreenManager,
appIconManager: App.shared.appIconManager,
balancePrimaryValueManager: App.shared.balancePrimaryValueManager,
balanceConversionManager: App.shared.balanceConversionManager
balanceConversionManager: App.shared.balanceConversionManager,
balanceHiddenManager: App.shared.balanceHiddenManager
)

let viewModel = AppearanceViewModel(service: service)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class AppearanceService {
private let appIconManager: AppIconManager
private let balancePrimaryValueManager: BalancePrimaryValueManager
private let balanceConversionManager: BalanceConversionManager
private let balanceHiddenManager: BalanceHiddenManager
private let disposeBag = DisposeBag()

private let themeModeItemsRelay = PublishRelay<[ThemeModeItem]>()
Expand Down Expand Up @@ -53,12 +54,13 @@ class AppearanceService {
launchScreenManager.showMarket
}

init(themeManager: ThemeManager, launchScreenManager: LaunchScreenManager, appIconManager: AppIconManager, balancePrimaryValueManager: BalancePrimaryValueManager, balanceConversionManager: BalanceConversionManager) {
init(themeManager: ThemeManager, launchScreenManager: LaunchScreenManager, appIconManager: AppIconManager, balancePrimaryValueManager: BalancePrimaryValueManager, balanceConversionManager: BalanceConversionManager, balanceHiddenManager: BalanceHiddenManager) {
self.themeManager = themeManager
self.launchScreenManager = launchScreenManager
self.appIconManager = appIconManager
self.balancePrimaryValueManager = balancePrimaryValueManager
self.balanceConversionManager = balanceConversionManager
self.balanceHiddenManager = balanceHiddenManager

subscribe(disposeBag, launchScreenManager.launchScreenObservable) { [weak self] in self?.syncLaunchScreenItems(current: $0) }
subscribe(disposeBag, appIconManager.appIconObservable) { [weak self] in self?.syncAppIconItems(current: $0) }
Expand Down Expand Up @@ -131,6 +133,10 @@ extension AppearanceService {
balancePrimaryValueItemsRelay.asObservable()
}

var balanceAutoHide: Bool {
balanceHiddenManager.balanceAutoHide
}

var showMarketTabObservable: Observable<Bool> {
showMarketTabRelay.asObservable()
}
Expand Down Expand Up @@ -161,6 +167,10 @@ extension AppearanceService {
balancePrimaryValueManager.balancePrimaryValue = BalancePrimaryValue.allCases[index]
}

func set(balanceAutoHide: Bool) {
balanceHiddenManager.set(balanceAutoHide: balanceAutoHide)
}

}

extension AppearanceService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ extension AppearanceViewController: SectionsDataSource {
Section(
id: "app-icon",
headerState: tableView.sectionHeader(text: "appearance.app_icon".localized),
footerState: .margin(height: .margin24),
footerState: .margin(height: .margin32),
rows: [
Row<AppearanceAppIconsCell>(
id: "app-icon",
Expand Down Expand Up @@ -239,6 +239,24 @@ extension AppearanceViewController: SectionsDataSource {
)
}

private func balanceAutoHideSection() -> SectionProtocol {
Section(
id: "balance-auto-hide",
footerState: .margin(height: .margin24),
rows: [
tableView.universalRow48(
id: "balance-auto-hide",
image: .local(UIImage(named: "eye_off_24")),
title: .body("appearance.balance_auto_hide".localized),
accessoryType: .switch(isOn: viewModel.balanceAutoHide) { [weak self] in self?.viewModel.onSet(balanceAutoHide: $0) },
hash: "\(viewModel.balanceAutoHide)",
isFirst: true,
isLast: true
)
]
)
}

func buildSections() -> [SectionProtocol] {
var sections: [SectionProtocol] = [
Section(id: "top-margin", headerState: .margin(height: .margin12)),
Expand All @@ -249,9 +267,10 @@ extension AppearanceViewController: SectionsDataSource {
sections.append(launchScreenSection)
}
sections.append(contentsOf: [
appIconSection(viewItems: appIconViewItems),
conversionSection(viewItems: conversionViewItems),
balanceValueSection(viewItems: balanceValueViewItems)
balanceValueSection(viewItems: balanceValueViewItems),
balanceAutoHideSection(),
appIconSection(viewItems: appIconViewItems)
])
return sections
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ extension AppearanceViewModel {
service.showMarketTab
}

var balanceAutoHide: Bool {
service.balanceAutoHide
}

func onSelectThemeMode(index: Int) {
service.setThemeMode(index: index)
}
Expand All @@ -139,6 +143,10 @@ extension AppearanceViewModel {
service.setBalancePrimaryValue(index: index)
}

func onSet(balanceAutoHide: Bool) {
service.set(balanceAutoHide: balanceAutoHide)
}

}

extension AppearanceViewModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ Go to Settings - > Unstoppable and allow access to the camera.";
"appearance.balance_value.coin_value" = "Coin Value";
"appearance.balance_value.fiat_value" = "Fiat Value";

"appearance.balance_auto_hide" = "Balance Auto Hide";

// Settings -> Contacts

"contacts.title" = "Contacts";
Expand Down

0 comments on commit 84e9eee

Please sign in to comment.