Skip to content

Commit 9f5e624

Browse files
authored
feat(receive): add CJIT geoblocked screen (#259)
1 parent 22f1542 commit 9f5e624

File tree

5 files changed

+46
-20
lines changed

5 files changed

+46
-20
lines changed

Bitkit/Components/IncomingTransfer.swift

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,18 @@ struct IncomingTransfer: View {
88
@EnvironmentObject var currency: CurrencyViewModel
99

1010
var body: some View {
11-
HStack(spacing: 4) {
12-
Image("transfer")
11+
HStack(spacing: 0) {
12+
Image("arrow-up-down")
1313
.resizable()
1414
.frame(width: 16, height: 16)
15-
.foregroundColor(.white64)
15+
.foregroundColor(.textSecondary)
16+
.padding(.trailing, 3)
1617

17-
CaptionBText(
18-
t("wallet__details_transfer_subtitle"),
19-
textColor: .white64
20-
)
18+
CaptionBText(t("wallet__details_transfer_subtitle"))
2119

2220
if let converted = currency.convert(sats: amount) {
2321
let formattedAmount = formatAmount(converted)
24-
CaptionBText(
25-
formattedAmount,
26-
textColor: .white64,
27-
accentColor: .white64
28-
)
22+
CaptionBText(formattedAmount)
2923
}
3024
}
3125
}

Bitkit/Components/RectangleButton.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,6 @@ struct RectangleButton: View {
7373
}
7474

7575
private var backgroundColor: Color {
76-
return isPressed ? .gray5 : .gray6
76+
return isPressed && !isDisabled ? .gray5 : .gray6
7777
}
7878
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import SwiftUI
2+
3+
struct ReceiveCjitGeoBlocked: View {
4+
@EnvironmentObject private var navigation: NavigationViewModel
5+
@EnvironmentObject private var sheets: SheetViewModel
6+
7+
var body: some View {
8+
VStack(alignment: .leading, spacing: 0) {
9+
SheetHeader(title: t("wallet__receive_bitcoin"), showBackButton: true)
10+
11+
BodyMText(t("lightning__funding__text_blocked_cjit"))
12+
13+
Spacer()
14+
15+
Image("globe-sphere")
16+
.resizable()
17+
.aspectRatio(contentMode: .fit)
18+
.frame(width: 256, height: 256)
19+
.padding()
20+
.frame(maxWidth: .infinity, maxHeight: .infinity)
21+
22+
Spacer()
23+
24+
CustomButton(title: tTodo("Advanced Setup")) {
25+
sheets.hideSheet()
26+
navigation.navigate(.fundingAdvanced)
27+
}
28+
}
29+
.navigationBarHidden(true)
30+
.padding(.horizontal, 16)
31+
.sheetBackground()
32+
}
33+
}

Bitkit/Views/Wallets/Receive/ReceiveQr.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,7 @@ struct ReceiveQr: View {
110110
isDisabled: wallet.nodeLifecycleState != .running
111111
) {
112112
if GeoService.shared.isGeoBlocked && !wallet.hasNonLspChannels() {
113-
app.toast(
114-
type: .error,
115-
title: "Instant Payments Unavailable",
116-
description: "Bitkit does not provide Lightning services in your country, but you can still connect to other nodes."
117-
)
113+
navigationPath.append(.cjitGeoBlocked)
118114
} else {
119115
navigationPath.append(.cjitAmount)
120116
}
@@ -149,7 +145,7 @@ struct ReceiveQr: View {
149145
} catch {
150146
app.toast(error)
151147
}
152-
try? await app.checkGeoStatus()
148+
await app.checkGeoStatus()
153149
}
154150
.onChange(of: wallet.nodeLifecycleState) { newState in
155151
// They may open this view before node has started
@@ -164,7 +160,7 @@ struct ReceiveQr: View {
164160
@ViewBuilder
165161
func tabContent(for tab: ReceiveTab) -> some View {
166162
VStack(spacing: 0) {
167-
if showingCjitOnboarding {
163+
if tab == .spending && wallet.channelCount == 0 && cjitInvoice == nil {
168164
cjitOnboarding
169165
} else if showDetails {
170166
detailsContent(for: tab)

Bitkit/Views/Wallets/Receive/ReceiveSheet.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ enum ReceiveRoute: Hashable {
88
case cjitAmount
99
case cjitConfirm(entry: IcJitEntry, receiveAmountSats: UInt64, isAdditional: Bool)
1010
case cjitLearnMore(entry: IcJitEntry, receiveAmountSats: UInt64, isAdditional: Bool)
11+
case cjitGeoBlocked
1112
}
1213

1314
struct ReceiveConfig {
@@ -72,6 +73,8 @@ struct ReceiveSheet: View {
7273
ReceiveCjitConfirmation(navigationPath: $navigationPath, entry: entry, receiveAmountSats: receiveAmountSats, isAdditional: isAdditional)
7374
case let .cjitLearnMore(entry, receiveAmountSats, isAdditional):
7475
ReceiveCjitLearnMore(entry: entry, receiveAmountSats: receiveAmountSats, isAdditional: isAdditional)
76+
case .cjitGeoBlocked:
77+
ReceiveCjitGeoBlocked()
7578
}
7679
}
7780
}

0 commit comments

Comments
 (0)