Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions Bitkit/Components/MoneyStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct MoneyStack: View {
var showEyeIcon: Bool = false
var enableSwipeGesture: Bool = false

@EnvironmentObject var app: AppViewModel
@EnvironmentObject var currency: CurrencyViewModel
@EnvironmentObject var settings: SettingsViewModel

Expand Down Expand Up @@ -109,10 +110,29 @@ struct MoneyStack: View {
.accessibilityIdentifier("TotalBalance")
.contentShape(Rectangle())
.onTapGesture {
let previousDisplay = currency.primaryDisplay

withAnimation(springAnimation) {
currency.togglePrimaryDisplay()
}
Haptics.play(.medium)

// Show toast on first switch
if !settings.ignoresSwitchUnitToast {
let newDisplay = currency.primaryDisplay
let toUnitText = getUnitText(for: newDisplay)
let fromUnitText = getUnitText(for: previousDisplay)

app.toast(
type: .info,
title: t("wallet__balance_unit_switched_title", variables: ["unit": toUnitText]),
description: t("wallet__balance_unit_switched_message", variables: ["unit": fromUnitText]),
visibilityTime: 5.0,
accessibilityIdentifier: "BalanceUnitSwitchedToast"
)

settings.ignoresSwitchUnitToast = true
}
}
.animation(springAnimation, value: currency.primaryDisplay)
.conditionalGesture(enableSwipeGesture) {
Expand All @@ -123,10 +143,24 @@ struct MoneyStack: View {

// Only trigger if horizontal swipe is more significant than vertical
if abs(horizontalAmount) > abs(verticalAmount) {
let wasHidden = settings.hideBalance
withAnimation(springAnimation) {
settings.hideBalance.toggle()
}
Haptics.play(.medium)

// Show toast on first hide (when balance becomes hidden)
if !wasHidden && settings.hideBalance && !settings.ignoresHideBalanceToast {
app.toast(
type: .info,
title: t("wallet__balance_hidden_title"),
description: t("wallet__balance_hidden_message"),
visibilityTime: 5.0,
accessibilityIdentifier: "BalanceHiddenToast"
)

settings.ignoresHideBalanceToast = true
}
}
}
}
Expand Down Expand Up @@ -158,6 +192,15 @@ private extension MoneyStack {
}
Haptics.play(.medium)
}

func getUnitText(for display: PrimaryDisplay) -> String {
switch display {
case .bitcoin:
return t("settings__general__unit_bitcoin")
case .fiat:
return currency.selectedCurrency
}
}
}

// MARK: - Helper View Modifier
Expand Down
14 changes: 12 additions & 2 deletions Bitkit/ViewModels/AppViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,21 @@ extension AppViewModel {

try await CoreService.shared.activity.insert(.lightning(ln))
} else {
toast(type: .lightning, title: t("lightning__channel_opened_title"), description: t("lightning__channel_opened_msg"))
toast(
type: .lightning,
title: t("lightning__channel_opened_title"),
description: t("lightning__channel_opened_msg"),
visibilityTime: 5.0
)
}
}
} else {
toast(type: .lightning, title: t("lightning__channel_opened_title"), description: t("lightning__channel_opened_msg"))
toast(
type: .lightning,
title: t("lightning__channel_opened_title"),
description: t("lightning__channel_opened_msg"),
visibilityTime: 5.0
)
}
case .channelClosed(channelId: _, userChannelId: _, counterpartyNodeId: _, reason: _):
break
Expand Down
2 changes: 2 additions & 0 deletions Bitkit/ViewModels/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ class SettingsViewModel: NSObject, ObservableObject {
@AppStorage("quickpayAmount") var quickpayAmount: Double = 5
@AppStorage("enableNotifications") var enableNotifications: Bool = false
@AppStorage("enableNotificationsAmount") var enableNotificationsAmount: Bool = false // TODO: remove this
@AppStorage("ignoresSwitchUnitToast") var ignoresSwitchUnitToast: Bool = false
@AppStorage("ignoresHideBalanceToast") var ignoresHideBalanceToast: Bool = false

// PIN Management
@Published internal(set) var pinEnabled: Bool = false
Expand Down
Loading