Skip to content
Draft
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
3 changes: 3 additions & 0 deletions Bitkit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,14 @@
Models/BlocksWidgetFields.swift,
Models/BlocksWidgetOptions.swift,
Models/BitcoinFacts.swift,
Models/CalculatorWidgetData.swift,
Models/Currency.swift,
Models/NewsWidgetData.swift,
Models/NewsWidgetOptions.swift,
Models/PriceWidgetData.swift,
Models/PriceWidgetOptions.swift,
Services/Widgets/BlocksHomeScreenWidgetOptionsStore.swift,
Services/Widgets/CalculatorHomeScreenWidgetOptionsStore.swift,
Services/Widgets/NewsHomeScreenWidgetOptionsStore.swift,
Services/Widgets/PriceHomeScreenWidgetOptionsStore.swift,
Styles/Colors.swift,
Expand Down
2 changes: 2 additions & 0 deletions Bitkit/AppScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct AppScene: View {
@StateObject private var pubkyProfile = PubkyProfileManager()
@StateObject private var contactsManager = ContactsManager()
@State private var keyboardManager = KeyboardManager()
@State private var calculatorInputManager = CalculatorInputManager()

@State private var hideSplash = false
@State private var removeSplash = false
Expand Down Expand Up @@ -140,6 +141,7 @@ struct AppScene: View {
.environmentObject(pubkyProfile)
.environmentObject(contactsManager)
.environment(keyboardManager)
.environment(calculatorInputManager)
.onChange(of: pubkyProfile.authState, initial: true) { _, authState in
if authState == .authenticated, let pk = pubkyProfile.publicKey {
Task { try? await contactsManager.loadContacts(for: pk) }
Expand Down
8 changes: 7 additions & 1 deletion Bitkit/Components/Header.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SwiftUI

struct Header: View {
@Environment(CalculatorInputManager.self) private var calculatorInput
@EnvironmentObject var app: AppViewModel
@EnvironmentObject var navigation: NavigationViewModel
@EnvironmentObject var pubkyProfile: PubkyProfileManager
Expand All @@ -25,12 +26,14 @@ struct Header: View {
AppStatus(
testID: "HeaderAppStatus",
onPress: {
calculatorInput.dismiss()
navigation.navigate(.appStatus)
}
)

if showWidgetEditButton {
Button(action: {
calculatorInput.dismiss()
isEditingWidgets.toggle()
}) {
Image(isEditingWidgets ? "check-mark" : "pencil")
Expand All @@ -45,6 +48,8 @@ struct Header: View {
}

Button {
calculatorInput.dismiss()

withAnimation {
app.showDrawer = true
}
Expand All @@ -65,9 +70,10 @@ struct Header: View {
.padding(.trailing, 10)
}

@ViewBuilder
private var profileButton: some View {
Button {
calculatorInput.dismiss()

if pubkyProfile.isAuthenticated || pubkyProfile.cachedName != nil {
navigation.navigate(.profile)
} else if pubkyProfile.initializationErrorMessage != nil {
Expand Down
18 changes: 15 additions & 3 deletions Bitkit/Components/NumberPad.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@ enum NumberPadType {

struct NumberPad: View {
let type: NumberPadType
let decimalSeparator: String
let errorKey: String?
let onPress: (String) -> Void

init(type: NumberPadType = .simple, errorKey: String? = nil, onPress: @escaping (String) -> Void) {
static var contentHeight: CGFloat {
buttonHeight * 4
}

private static var buttonHeight: CGFloat {
UIScreen.main.isSmall ? 65 : 44 + 34
}

init(type: NumberPadType = .simple, decimalSeparator: String = ".", errorKey: String? = nil, onPress: @escaping (String) -> Void) {
self.type = type
self.decimalSeparator = decimalSeparator
self.errorKey = errorKey
self.onPress = onPress
}

private let buttonHeight: CGFloat = UIScreen.main.isSmall ? 65 : 44 + 34
private let gridItems = Array(repeating: GridItem(.flexible(), spacing: 0), count: 3)
private let numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9"]
private var buttonHeight: CGFloat {
Self.buttonHeight
}

var body: some View {
VStack(spacing: 0) {
Expand Down Expand Up @@ -59,7 +71,7 @@ struct NumberPad: View {
}
case .decimal:
NumberPadButton(
text: ".",
text: decimalSeparator,
height: buttonHeight,
hasError: errorKey == ".",
testID: "NDecimal"
Expand Down
5 changes: 5 additions & 0 deletions Bitkit/Components/TabBar/TabBar.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import SwiftUI

struct TabBar: View {
@Environment(CalculatorInputManager.self) private var calculatorInput
@EnvironmentObject var navigation: NavigationViewModel
@EnvironmentObject var sheets: SheetViewModel
@EnvironmentObject var wallet: WalletViewModel

var shouldShow: Bool {
if calculatorInput.isPresented { return false }

let routesWithTabBar = Set<Route>([.activityList, .savingsWallet, .spendingWallet])
if navigation.path.isEmpty { return true }
return navigation.currentRoute.map { routesWithTabBar.contains($0) } ?? false
Expand Down Expand Up @@ -66,6 +69,7 @@ struct TabBar: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
.overlay {
TabBar()
.environment(CalculatorInputManager())
.environmentObject(NavigationViewModel())
.environmentObject(SheetViewModel())
}
Expand All @@ -79,6 +83,7 @@ struct TabBar: View {
.frame(maxWidth: .infinity, maxHeight: .infinity)
.overlay {
TabBar()
.environment(CalculatorInputManager())
.environmentObject(NavigationViewModel())
.environmentObject(SheetViewModel())
}
Expand Down
Loading