From 484171e0398ce421e70e9555293afbe76f279234 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 28 Sep 2024 14:37:04 -0500 Subject: [PATCH 1/2] chore: use updated button closure style --- .../View/Activity/ActivityListView.swift | 4 ++-- BDKSwiftExampleWallet/View/Send/AddressView.swift | 8 ++++++-- BDKSwiftExampleWallet/View/WalletView.swift | 12 ++++++------ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift b/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift index 8a622a7e..4d756eea 100644 --- a/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift +++ b/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift @@ -67,11 +67,11 @@ struct CustomSegmentedControl: View { } private func segmentButton(for mode: ActivityListViewModel.DisplayMode) -> some View { - Button(action: { + Button { withAnimation(.spring(response: 0.5, dampingFraction: 0.7)) { selection = mode } - }) { + } label: { Text(mode == .transactions ? "Transactions" : "Unspent") .bold() .foregroundColor(selection == mode ? .primary : .gray) diff --git a/BDKSwiftExampleWallet/View/Send/AddressView.swift b/BDKSwiftExampleWallet/View/Send/AddressView.swift index 5712f9d2..2b06b6a4 100644 --- a/BDKSwiftExampleWallet/View/Send/AddressView.swift +++ b/BDKSwiftExampleWallet/View/Send/AddressView.swift @@ -104,7 +104,9 @@ struct CustomScannerView: View { VStack { HStack { - Button(action: { dismiss() }) { + Button { + dismiss() + } label: { Image(systemName: "xmark") .foregroundColor(.white) .font(.system(size: 20, weight: .bold)) @@ -120,7 +122,9 @@ struct CustomScannerView: View { Spacer() - Button(action: pasteAction) { + Button { + pasteAction() + } label: { Text("Paste Address") .padding() .foregroundColor(Color(uiColor: .label)) diff --git a/BDKSwiftExampleWallet/View/WalletView.swift b/BDKSwiftExampleWallet/View/WalletView.swift index 0d24b35f..8c64ed70 100644 --- a/BDKSwiftExampleWallet/View/WalletView.swift +++ b/BDKSwiftExampleWallet/View/WalletView.swift @@ -145,9 +145,9 @@ struct WalletView: View { .font(.caption) if viewModel.walletSyncState == .synced { - Button(action: { + Button { showAllTransactions = true - }) { + } label: { HStack(spacing: 2) { Text("Show All") Image(systemName: "arrow.right") @@ -173,9 +173,9 @@ struct WalletView: View { } HStack { - Button(action: { + Button { showReceiveView = true - }) { + } label: { Image(systemName: "qrcode") .font(.title) .foregroundColor(.primary) @@ -282,9 +282,9 @@ struct WalletView: View { } .toolbar { ToolbarItem(placement: .navigationBarTrailing) { - Button(action: { + Button { showSettingsView = true - }) { + } label: { Image(systemName: "person.and.background.dotted") } } From 8408cdc56580d1e5fba5554ca6a8085179bc70da Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 28 Sep 2024 14:41:29 -0500 Subject: [PATCH 2/2] refactor: foregroundcolor to foregroundstyle --- .../View/Activity/ActivityListView.swift | 2 +- .../View/Activity/LocalOutputItemView.swift | 4 ++-- .../View/Activity/TransactionDetailView.swift | 12 +++++------ .../View/Activity/TransactionItemView.swift | 4 ++-- .../View/Receive/ReceiveView.swift | 2 +- .../View/Send/AddressView.swift | 4 ++-- .../View/Send/AmountView.swift | 4 ++-- .../View/Send/BuildTransactionView.swift | 6 +++--- BDKSwiftExampleWallet/View/Send/FeeView.swift | 2 +- .../View/Settings/SettingsView.swift | 8 ++++---- BDKSwiftExampleWallet/View/WalletView.swift | 20 +++++++++---------- 11 files changed, 34 insertions(+), 34 deletions(-) diff --git a/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift b/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift index 4d756eea..b64018fa 100644 --- a/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift +++ b/BDKSwiftExampleWallet/View/Activity/ActivityListView.swift @@ -74,7 +74,7 @@ struct CustomSegmentedControl: View { } label: { Text(mode == .transactions ? "Transactions" : "Unspent") .bold() - .foregroundColor(selection == mode ? .primary : .gray) + .foregroundStyle(selection == mode ? Color.primary : Color.gray) } } } diff --git a/BDKSwiftExampleWallet/View/Activity/LocalOutputItemView.swift b/BDKSwiftExampleWallet/View/Activity/LocalOutputItemView.swift index 1ebdbbed..15e1a5c0 100644 --- a/BDKSwiftExampleWallet/View/Activity/LocalOutputItemView.swift +++ b/BDKSwiftExampleWallet/View/Activity/LocalOutputItemView.swift @@ -39,7 +39,7 @@ struct LocalOutputItemView: View { .fontDesign(.monospaced) .fontWeight(.semibold) .font(.title) - .foregroundColor(.primary) + .foregroundStyle(.primary) Text("Vout: \(output.outpoint.vout)") .lineLimit(dynamicTypeSize.isAccessibilitySize ? 2 : 1) @@ -47,7 +47,7 @@ struct LocalOutputItemView: View { .fontWidth(.condensed) } - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .font(.subheadline) .padding(.trailing, 30.0) .redacted(reason: isRedacted ? .placeholder : []) diff --git a/BDKSwiftExampleWallet/View/Activity/TransactionDetailView.swift b/BDKSwiftExampleWallet/View/Activity/TransactionDetailView.swift index 9400a077..a6d5ed6e 100644 --- a/BDKSwiftExampleWallet/View/Activity/TransactionDetailView.swift +++ b/BDKSwiftExampleWallet/View/Activity/TransactionDetailView.swift @@ -52,10 +52,10 @@ struct TransactionDetailView: View { switch canonicalTx.chainPosition { case .confirmed(let confirmationBlockTime): Text("Block \(confirmationBlockTime.blockId.height.delimiter)") - .foregroundColor(.secondary) + .foregroundStyle(.secondary) case .unconfirmed(_): Text("Unconfirmed") - .foregroundColor(.secondary) + .foregroundStyle(.secondary) } } @@ -71,7 +71,7 @@ struct TransactionDetailView: View { .lineLimit(1) .minimumScaleFactor(0.5) .font(.largeTitle) - .foregroundColor(.primary) + .foregroundStyle(.primary) .fontWeight(.bold) .fontDesign(.rounded) VStack(spacing: 4) { @@ -95,7 +95,7 @@ struct TransactionDetailView: View { Text("\(fee.formattedWithSeparator) sats fee") } } - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .font(.callout) } @@ -115,7 +115,7 @@ struct TransactionDetailView: View { } label: { Image(systemName: "safari") .fontWeight(.semibold) - .foregroundColor(.bitcoinOrange) + .foregroundStyle(Color.bitcoinOrange) } Spacer() } @@ -142,7 +142,7 @@ struct TransactionDetailView: View { } } .fontWeight(.semibold) - .foregroundColor(.bitcoinOrange) + .foregroundStyle(Color.bitcoinOrange) } } .fontDesign(.monospaced) diff --git a/BDKSwiftExampleWallet/View/Activity/TransactionItemView.swift b/BDKSwiftExampleWallet/View/Activity/TransactionItemView.swift index 80771ea3..2bfad83e 100644 --- a/BDKSwiftExampleWallet/View/Activity/TransactionItemView.swift +++ b/BDKSwiftExampleWallet/View/Activity/TransactionItemView.swift @@ -61,7 +61,7 @@ struct TransactionItemView: View { .fontDesign(.monospaced) .fontWeight(.semibold) .font(.title) - .foregroundColor(.primary) + .foregroundStyle(.primary) switch canonicalTx.chainPosition { case .confirmed(let confirmationBlockTime): Text( @@ -85,7 +85,7 @@ struct TransactionItemView: View { .fontWidth(.condensed) } } - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .font(.subheadline) .padding(.trailing, 30.0) .redacted(reason: isRedacted ? .placeholder : []) diff --git a/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift b/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift index d72ec9de..548805eb 100644 --- a/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift +++ b/BDKSwiftExampleWallet/View/Receive/ReceiveView.swift @@ -75,7 +75,7 @@ struct ReceiveView: View { } } .fontWeight(.semibold) - .foregroundColor(.bitcoinOrange) + .foregroundStyle(Color.bitcoinOrange) } } .padding() diff --git a/BDKSwiftExampleWallet/View/Send/AddressView.swift b/BDKSwiftExampleWallet/View/Send/AddressView.swift index 2b06b6a4..a56a6758 100644 --- a/BDKSwiftExampleWallet/View/Send/AddressView.swift +++ b/BDKSwiftExampleWallet/View/Send/AddressView.swift @@ -108,7 +108,7 @@ struct CustomScannerView: View { dismiss() } label: { Image(systemName: "xmark") - .foregroundColor(.white) + .foregroundStyle(.white) .font(.system(size: 20, weight: .bold)) .frame(width: 44, height: 44) .background(Color.black.opacity(0.6)) @@ -127,7 +127,7 @@ struct CustomScannerView: View { } label: { Text("Paste Address") .padding() - .foregroundColor(Color(uiColor: .label)) + .foregroundStyle(Color(uiColor: .label)) .background(Color(uiColor: .systemBackground).opacity(0.5)) .clipShape(Capsule()) } diff --git a/BDKSwiftExampleWallet/View/Send/AmountView.swift b/BDKSwiftExampleWallet/View/Send/AmountView.swift index ffe0e8c1..91725367 100644 --- a/BDKSwiftExampleWallet/View/Send/AmountView.swift +++ b/BDKSwiftExampleWallet/View/Send/AmountView.swift @@ -31,7 +31,7 @@ struct AmountView: View { } .fontWeight(.semibold) .font(.caption) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) } if let balance = viewModel.balanceConfirmed { HStack(spacing: 2) { @@ -40,7 +40,7 @@ struct AmountView: View { } .fontWeight(.semibold) .font(.caption) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) } } diff --git a/BDKSwiftExampleWallet/View/Send/BuildTransactionView.swift b/BDKSwiftExampleWallet/View/Send/BuildTransactionView.swift index ec1556b2..49d45ccd 100644 --- a/BDKSwiftExampleWallet/View/Send/BuildTransactionView.swift +++ b/BDKSwiftExampleWallet/View/Send/BuildTransactionView.swift @@ -46,7 +46,7 @@ struct BuildTransactionView: View { .font(.largeTitle) .fontWeight(.bold) .fontDesign(.rounded) - .foregroundColor(.primary) + .foregroundStyle(.primary) } else { Text("...") } @@ -166,7 +166,7 @@ struct BuildTransactionView: View { } else if isSent && viewModel.buildTransactionViewError == nil { VStack { Image(systemName: "checkmark") - .foregroundColor(.green) + .foregroundStyle(.green) if let transaction = viewModel.extractTransaction() { HStack { Text(transaction.computeTxid()) @@ -191,7 +191,7 @@ struct BuildTransactionView: View { } } .fontWeight(.semibold) - .foregroundColor(.bitcoinOrange) + .foregroundStyle(Color.bitcoinOrange) } } .fontDesign(.monospaced) diff --git a/BDKSwiftExampleWallet/View/Send/FeeView.swift b/BDKSwiftExampleWallet/View/Send/FeeView.swift index 8898666e..d0b91b83 100644 --- a/BDKSwiftExampleWallet/View/Send/FeeView.swift +++ b/BDKSwiftExampleWallet/View/Send/FeeView.swift @@ -75,7 +75,7 @@ struct FeeView: View { .accessibilityValue("\(viewModel.selectedFee ?? 1) satoshis per vbyte") Text("sat/vb") - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .fontWeight(.thin) Spacer() diff --git a/BDKSwiftExampleWallet/View/Settings/SettingsView.swift b/BDKSwiftExampleWallet/View/Settings/SettingsView.swift index f6133e08..285f576a 100644 --- a/BDKSwiftExampleWallet/View/Settings/SettingsView.swift +++ b/BDKSwiftExampleWallet/View/Settings/SettingsView.swift @@ -28,7 +28,7 @@ struct SettingsView: View { .padding(.horizontal, 20.0) .padding(.top, 40.0) .padding(.bottom, -40.0) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) Form { @@ -37,7 +37,7 @@ struct SettingsView: View { Text( "\(network.capitalized) • \(url.replacingOccurrences(of: "https://", with: "").replacingOccurrences(of: "http://", with: ""))" ) - .foregroundColor(.primary) + .foregroundStyle(.primary) } else { HStack { Text("No Network") @@ -53,11 +53,11 @@ struct SettingsView: View { } label: { Text("Full Scan") } - .foregroundColor(.bitcoinOrange) + .foregroundStyle(Color.bitcoinOrange) if viewModel.walletSyncState == .syncing { Text("\(viewModel.inspectedScripts)") .contentTransition(.numericText()) - .foregroundColor(.primary) + .foregroundStyle(.primary) .animation(.easeInOut, value: viewModel.inspectedScripts) } } diff --git a/BDKSwiftExampleWallet/View/WalletView.swift b/BDKSwiftExampleWallet/View/WalletView.swift index 8c64ed70..d7351689 100644 --- a/BDKSwiftExampleWallet/View/WalletView.swift +++ b/BDKSwiftExampleWallet/View/WalletView.swift @@ -31,7 +31,7 @@ struct WalletView: View { Text("Bitcoin".uppercased()) .fontWeight(.semibold) .fontWidth(.expanded) - .foregroundColor(.bitcoinOrange) + .foregroundStyle(Color.bitcoinOrange) .scaleEffect(isAnimating ? 1.0 : 0.6) .onAppear { withAnimation(.easeOut(duration: 0.5)) { @@ -41,7 +41,7 @@ struct WalletView: View { withAnimation { HStack(spacing: 15) { Image(systemName: "bitcoinsign") - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .font(.title) .fontWeight(.thin) Text(viewModel.balanceTotal.formattedSatoshis()) @@ -49,7 +49,7 @@ struct WalletView: View { .fontWeight(.semibold) .fontDesign(.rounded) Text("sats") - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .fontWeight(.thin) } .font(.largeTitle) @@ -70,7 +70,7 @@ struct WalletView: View { .contentTransition(.numericText()) .fontDesign(.rounded) } - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .font(.subheadline) } .padding(.vertical, 20.0) @@ -110,7 +110,7 @@ struct WalletView: View { } } .fontDesign(.monospaced) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .font(.caption2) .fontWeight(.thin) .animation(.easeInOut, value: viewModel.inspectedScripts) @@ -126,7 +126,7 @@ struct WalletView: View { ) } else if viewModel.walletSyncState == .synced { Image(systemName: "checkmark.circle.fill") - .foregroundColor( + .foregroundStyle( viewModel.walletSyncState == .synced ? .green : .secondary ) @@ -141,7 +141,7 @@ struct WalletView: View { .contentTransition(.symbolEffect(.replace.offUp)) } - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .font(.caption) if viewModel.walletSyncState == .synced { @@ -153,7 +153,7 @@ struct WalletView: View { Image(systemName: "arrow.right") } .font(.caption) - .foregroundColor(.secondary) + .foregroundStyle(.secondary) .fontWeight(.regular) } } @@ -178,7 +178,7 @@ struct WalletView: View { } label: { Image(systemName: "qrcode") .font(.title) - .foregroundColor(.primary) + .foregroundStyle(.primary) } Spacer() @@ -186,7 +186,7 @@ struct WalletView: View { NavigationLink(value: NavigationDestination.address) { Image(systemName: "qrcode.viewfinder") .font(.title) - .foregroundColor(.primary) + .foregroundStyle(.primary) } } .padding([.horizontal, .bottom])