Skip to content

Commit fe5716a

Browse files
authored
Merge pull request #177 from synonymdev/fix/clipboard-qr
fix: Add click action to QR code
2 parents eedf311 + 6eb9ae7 commit fe5716a

36 files changed

+85
-74
lines changed

Bitkit/Components/Core/ButtonLocationTracking.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import SwiftUI
22

33
/// Preference key for tracking button locations in a coordinate space
44
struct ButtonLocationPreferenceKey: PreferenceKey {
5-
public static var defaultValue: [CGRect] = []
5+
static var defaultValue: [CGRect] = []
66

7-
public static func reduce(value: inout [CGRect], nextValue: () -> [CGRect]) {
7+
static func reduce(value: inout [CGRect], nextValue: () -> [CGRect]) {
88
value.append(contentsOf: nextValue())
99
}
1010
}
@@ -17,12 +17,12 @@ private struct ButtonLocationModifier: ViewModifier {
1717
/// Callback when the view's location changes
1818
let onLocationChanged: (CGRect) -> Void
1919

20-
public init(coordinateSpace: String, onLocationChanged: @escaping (CGRect) -> Void) {
20+
init(coordinateSpace: String, onLocationChanged: @escaping (CGRect) -> Void) {
2121
self.coordinateSpace = coordinateSpace
2222
self.onLocationChanged = onLocationChanged
2323
}
2424

25-
public func body(content: Content) -> some View {
25+
func body(content: Content) -> some View {
2626
content
2727
.background(
2828
GeometryReader { geometry in

Bitkit/Components/FeeItem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ struct FeeItem: View {
3636
unitType: .primary,
3737
size: .bodyMSB,
3838
symbol: true,
39-
color: isDisabled ? .gray3 : .textPrimary,
39+
color: isDisabled ? .gray3 : .textPrimary
4040
)
4141

4242
MoneyText(
4343
sats: Int(amount),
4444
unitType: .secondary,
4545
size: .bodySSB,
4646
symbol: true,
47-
color: isDisabled ? .gray3 : .textSecondary,
47+
color: isDisabled ? .gray3 : .textSecondary
4848
)
4949
}
5050
}

Bitkit/Components/MoneyStack.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import SwiftUI
33
// MoneyStack - Stacked display with toggle functionality, optional eye icon and swipe gestures
44
struct MoneyStack: View {
55
let sats: Int
6-
var prefix: String? = nil
6+
var prefix: String?
77
var showSymbol: Bool = false
88
var showEyeIcon: Bool = false
99
var enableSwipeGesture: Bool = false

Bitkit/Components/MoneyText.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ struct MoneyText: View {
1919
let sats: Int
2020
var unitType: MoneyUnitType = .primary
2121
var size: MoneySize = .display
22-
var symbol: Bool? = nil
22+
var symbol: Bool?
2323
var enableHide: Bool = true
24-
var prefix: String? = nil
24+
var prefix: String?
2525
var color: Color = .textPrimary
26-
var symbolColor: Color? = nil
26+
var symbolColor: Color?
2727

2828
@EnvironmentObject var currency: CurrencyViewModel
2929
@EnvironmentObject var settings: SettingsViewModel

Bitkit/Components/QR.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import SwiftUI
33

44
struct QR: View {
55
let content: String
6-
var imageAsset: String? = nil
6+
var imageAsset: String?
77

88
@State private var cachedImage: UIImage?
99
@State private var cachedContent: String = ""
10+
var onPressed: (() -> Void)?
1011

1112
private let context = CIContext()
1213
private let filter = CIFilter.qrCodeGenerator()
@@ -35,6 +36,11 @@ struct QR: View {
3536
}
3637
}
3738
}
39+
.onTapGesture {
40+
if let onPressed {
41+
onPressed()
42+
}
43+
}
3844
.onAppear {
3945
// Generate initial QR code
4046
if cachedImage == nil {
@@ -68,7 +74,10 @@ struct QR: View {
6874
QR(
6975
content:
7076
"bitcoin:bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq?lightning=lnbc1500n1p3hk3sppp5k54t9c4p4u4tdgj0y8tqjp3kzjak8jtr0fwvnl2dpl5pvrm9gxsdqqcqzpgxqyz5vqsp5usxefww9jeqxv4ujmfwqhynz3rgf4x4k8kmjkjy8mkzctxt5vvq9qyyssqy4lgd8nj3vxjmnqyfgxnz3gqhykj8rd9v4xnz970m2cfqsz3vh7qwg0o4jj2mcwhzguktgc8hm8zmnwnp6f5ke4h8dkwrm8fqz2cpgqqqqqqqqlgqqqq",
71-
imageAsset: "btc-and-ln"
77+
imageAsset: "btc-and-ln",
78+
onPressed: {
79+
print("QR code pressed!")
80+
}
7281
)
7382

7483
QR(content: "bitcoin:bc1qar0srrr7xfkvy5l643lydnw9re59gtzzwf5mdq", imageAsset: "btc")

Bitkit/Components/RadioGroup.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct RadioGroup<T: Hashable>: View {
1515
ForEach(Array(options.enumerated()), id: \.element.value) { _, option in
1616
RadioButton(
1717
title: option.title,
18-
isSelected: selectedValue == option.value,
18+
isSelected: selectedValue == option.value
1919
) {
2020
selectedValue = option.value
2121
}

Bitkit/Components/TextField.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ struct TextField: View {
1212
text: Binding<String>,
1313
backgroundColor: Color = .white10,
1414
font: Font = .custom(Fonts.semiBold, size: 15),
15-
axis: Axis = .horizontal,
15+
axis: Axis = .horizontal
1616
) {
1717
self.placeholder = placeholder
1818
self.backgroundColor = backgroundColor

Bitkit/Managers/TimedSheets/NotificationsTimedSheet.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct NotificationsTimedSheet: TimedSheetItem {
1414
init(
1515
appViewModel: AppViewModel,
1616
settingsViewModel: SettingsViewModel,
17-
walletViewModel: WalletViewModel,
17+
walletViewModel: WalletViewModel
1818
) {
1919
self.appViewModel = appViewModel
2020
self.settingsViewModel = settingsViewModel

Bitkit/Styles/TextStyle.swift

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ struct DisplayText: View {
1010
let text: String
1111
var textColor: Color = .textPrimary
1212
var accentColor: Color = .brandAccent
13-
var accentFont: ((CGFloat) -> Font)? = nil
14-
var accentAction: (() -> Void)? = nil
13+
var accentFont: ((CGFloat) -> Font)?
14+
var accentAction: (() -> Void)?
1515

1616
private let fontSize: CGFloat = 44
1717

@@ -50,8 +50,8 @@ struct HeadlineText: View {
5050
let text: String
5151
var textColor: Color = .textPrimary
5252
var accentColor: Color = .brandAccent
53-
var accentFont: ((CGFloat) -> Font)? = nil
54-
var accentAction: (() -> Void)? = nil
53+
var accentFont: ((CGFloat) -> Font)?
54+
var accentAction: (() -> Void)?
5555

5656
private let fontSize: CGFloat = 30
5757

@@ -89,8 +89,8 @@ struct TitleText: View {
8989
let text: String
9090
var textColor: Color = .textPrimary
9191
var accentColor: Color = .brandAccent
92-
var accentFont: ((CGFloat) -> Font)? = nil
93-
var accentAction: (() -> Void)? = nil
92+
var accentFont: ((CGFloat) -> Font)?
93+
var accentAction: (() -> Void)?
9494

9595
private let fontSize: CGFloat = 22
9696

@@ -125,8 +125,8 @@ struct SubtitleText: View {
125125
let text: String
126126
var textColor: Color = .textPrimary
127127
var accentColor: Color = .brandAccent
128-
var accentFont: ((CGFloat) -> Font)? = nil
129-
var accentAction: (() -> Void)? = nil
128+
var accentFont: ((CGFloat) -> Font)?
129+
var accentAction: (() -> Void)?
130130

131131
private let fontSize: CGFloat = 17
132132

@@ -161,8 +161,8 @@ struct BodyMText: View {
161161
let text: String
162162
var textColor: Color = .textSecondary
163163
var accentColor: Color = .white
164-
var accentFont: ((CGFloat) -> Font)? = nil
165-
var accentAction: (() -> Void)? = nil
164+
var accentFont: ((CGFloat) -> Font)?
165+
var accentAction: (() -> Void)?
166166

167167
private let fontSize: CGFloat = 17
168168

@@ -197,8 +197,8 @@ struct BodyMSBText: View {
197197
let text: String
198198
var textColor: Color = .textPrimary
199199
var accentColor: Color = .brandAccent
200-
var accentFont: ((CGFloat) -> Font)? = nil
201-
var accentAction: (() -> Void)? = nil
200+
var accentFont: ((CGFloat) -> Font)?
201+
var accentAction: (() -> Void)?
202202

203203
private let fontSize: CGFloat = 17
204204

@@ -233,8 +233,8 @@ struct BodyMBoldText: View {
233233
let text: String
234234
var textColor: Color = .textSecondary
235235
var accentColor: Color = .brandAccent
236-
var accentFont: ((CGFloat) -> Font)? = nil
237-
var accentAction: (() -> Void)? = nil
236+
var accentFont: ((CGFloat) -> Font)?
237+
var accentAction: (() -> Void)?
238238

239239
private let fontSize: CGFloat = 17
240240

@@ -269,8 +269,8 @@ struct BodySText: View {
269269
let text: String
270270
var textColor: Color = .textSecondary
271271
var accentColor: Color = .brandAccent
272-
var accentFont: ((CGFloat) -> Font)? = nil
273-
var accentAction: (() -> Void)? = nil
272+
var accentFont: ((CGFloat) -> Font)?
273+
var accentAction: (() -> Void)?
274274

275275
private let fontSize: CGFloat = 15
276276

@@ -305,8 +305,8 @@ struct BodySSBText: View {
305305
let text: String
306306
var textColor: Color = .textPrimary
307307
var accentColor: Color = .brandAccent
308-
var accentFont: ((CGFloat) -> Font)? = nil
309-
var accentAction: (() -> Void)? = nil
308+
var accentFont: ((CGFloat) -> Font)?
309+
var accentAction: (() -> Void)?
310310

311311
private let fontSize: CGFloat = 15
312312

@@ -342,8 +342,8 @@ struct CaptionText: View {
342342
let text: String
343343
var textColor: Color = .textSecondary
344344
var accentColor: Color = .brandAccent
345-
var accentFont: ((CGFloat) -> Font)? = nil
346-
var accentAction: (() -> Void)? = nil
345+
var accentFont: ((CGFloat) -> Font)?
346+
var accentAction: (() -> Void)?
347347

348348
private let fontSize: CGFloat = 13
349349

@@ -377,8 +377,8 @@ struct CaptionBText: View {
377377
let text: String
378378
var textColor: Color = .textSecondary
379379
var accentColor: Color = .brandAccent
380-
var accentFont: ((CGFloat) -> Font)? = nil
381-
var accentAction: (() -> Void)? = nil
380+
var accentFont: ((CGFloat) -> Font)?
381+
var accentAction: (() -> Void)?
382382

383383
private let fontSize: CGFloat = 13
384384

@@ -413,8 +413,8 @@ struct CaptionMText: View {
413413
let text: String
414414
var textColor: Color = .textSecondary
415415
var accentColor: Color = .brandAccent
416-
var accentFont: ((CGFloat) -> Font)? = nil
417-
var accentAction: (() -> Void)? = nil
416+
var accentFont: ((CGFloat) -> Font)?
417+
var accentAction: (() -> Void)?
418418

419419
private let fontSize: CGFloat = 13
420420

@@ -449,8 +449,8 @@ struct FootnoteText: View {
449449
let text: String
450450
var textColor: Color = .textSecondary
451451
var accentColor: Color = .brandAccent
452-
var accentFont: ((CGFloat) -> Font)? = nil
453-
var accentAction: (() -> Void)? = nil
452+
var accentFont: ((CGFloat) -> Font)?
453+
var accentAction: (() -> Void)?
454454

455455
private let fontSize: CGFloat = 12
456456

Bitkit/Views/Backup/BackupConfirmMnemonic.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct BackupConfirmMnemonic: View {
6363
HStack(alignment: .center, spacing: 16) {
6464
CustomButton(
6565
title: t("common__continue"),
66-
isDisabled: selectedWords != mnemonic,
66+
isDisabled: selectedWords != mnemonic
6767
) {
6868
if let passphrase, !passphrase.isEmpty {
6969
navigationPath.append(.confirmPassphrase(passphrase: passphrase))

0 commit comments

Comments
 (0)