Skip to content

Commit 796d859

Browse files
committed
wip: update seedview to show descriptor
1 parent 4891ddf commit 796d859

File tree

3 files changed

+63
-44
lines changed

3 files changed

+63
-44
lines changed

BDKSwiftExampleWallet/Resources/Localizable.xcstrings

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@
320320
}
321321
},
322322
"Delete Seed" : {
323+
"extractionState" : "stale",
323324
"localizations" : {
324325
"fr" : {
325326
"stringUnit" : {
@@ -328,6 +329,9 @@
328329
}
329330
}
330331
}
332+
},
333+
"Delete Wallet" : {
334+
331335
},
332336
"Descriptors" : {
333337

@@ -640,6 +644,7 @@
640644
}
641645
},
642646
"Show Seed" : {
647+
"extractionState" : "stale",
643648
"localizations" : {
644649
"fr" : {
645650
"stringUnit" : {
@@ -648,6 +653,9 @@
648653
}
649654
}
650655
}
656+
},
657+
"Show Wallet" : {
658+
651659
},
652660
"Showing Seed Error" : {
653661
"localizations" : {

BDKSwiftExampleWallet/View/Settings/SeedView.swift

Lines changed: 53 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -24,54 +24,65 @@ struct SeedView: View {
2424
let publicDescriptor = viewModel.publicDescriptor,
2525
let publicChangeDescriptor = viewModel.publicChangeDescriptor
2626
{
27+
if backupInfo.mnemonic.isEmpty {
28+
Text(backupInfo.descriptor)
29+
.font(.system(.caption, design: .monospaced))
30+
.lineLimit(1)
31+
.truncationMode(.middle)
32+
.padding()
33+
} else {
34+
SeedPhraseView(
35+
words: backupInfo.mnemonic.components(separatedBy: " "),
36+
preferredWordsPerRow: 2,
37+
usePaging: true,
38+
wordsPerPage: 4
39+
)
40+
}
2741

28-
SeedPhraseView(
29-
words: backupInfo.mnemonic.components(separatedBy: " "),
30-
preferredWordsPerRow: 2,
31-
usePaging: true,
32-
wordsPerPage: 4
33-
)
34-
35-
VStack {
36-
Text("Seed is not synced across devices.")
37-
Text("Please make sure to write it down and store it securely.")
42+
if !backupInfo.mnemonic.isEmpty {
43+
VStack {
44+
Text("Seed is not synced across devices.")
45+
Text("Please make sure to write it down and store it securely.")
46+
}
47+
.font(.caption)
48+
.foregroundStyle(.secondary)
49+
.multilineTextAlignment(.center)
50+
.padding()
3851
}
39-
.font(.caption)
40-
.foregroundStyle(.secondary)
41-
.multilineTextAlignment(.center)
42-
.padding()
4352

44-
HStack {
45-
Spacer()
46-
Button {
47-
UIPasteboard.general.string = backupInfo.mnemonic
48-
isCopied = true
49-
showCheckmark = true
50-
DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) {
51-
isCopied = false
52-
showCheckmark = false
53+
if !backupInfo.mnemonic.isEmpty {
54+
HStack {
55+
Spacer()
56+
Button {
57+
UIPasteboard.general.string = backupInfo.mnemonic
58+
isCopied = true
59+
showCheckmark = true
60+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) {
61+
isCopied = false
62+
showCheckmark = false
63+
}
64+
} label: {
65+
HStack {
66+
Image(
67+
systemName: showCheckmark
68+
? "document.on.document.fill" : "document.on.document"
69+
)
70+
.contentTransition(.symbolEffect(.replace))
71+
Text("Seed")
72+
.bold()
73+
}
5374
}
54-
} label: {
55-
HStack {
56-
Image(
57-
systemName: showCheckmark
58-
? "document.on.document.fill" : "document.on.document"
75+
.buttonStyle(
76+
BitcoinFilled(
77+
width: 120,
78+
height: 40,
79+
tintColor: .primary,
80+
textColor: Color(uiColor: .systemBackground),
81+
isCapsule: true
5982
)
60-
.contentTransition(.symbolEffect(.replace))
61-
Text("Seed")
62-
.bold()
63-
}
64-
}
65-
.buttonStyle(
66-
BitcoinFilled(
67-
width: 120,
68-
height: 40,
69-
tintColor: .primary,
70-
textColor: Color(uiColor: .systemBackground),
71-
isCapsule: true
7283
)
73-
)
74-
Spacer()
84+
Spacer()
85+
}
7586
}
7687

7788
HStack {

BDKSwiftExampleWallet/View/Settings/SettingsView.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct SettingsView: View {
7373
Button {
7474
showingShowSeedConfirmation = true
7575
} label: {
76-
Text(String(localized: "Show Seed"))
76+
Text(String(localized: "Show Wallet"))
7777
.foregroundStyle(.red)
7878
}
7979
}
@@ -86,7 +86,7 @@ struct SettingsView: View {
8686
showingDeleteSeedConfirmation = true
8787
} label: {
8888
HStack {
89-
Text(String(localized: "Delete Seed"))
89+
Text(String(localized: "Delete Wallet"))
9090
.foregroundStyle(.red)
9191
}
9292
}

0 commit comments

Comments
 (0)