mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-10-22 15:22:07 +00:00
SimpleX names v2: Android, desktop and iOS UIs
The names hub and the buy / gift / receive / renew / recovery-key flows across the Kotlin multiplatform app and the iOS Swift app. Stacked on the core PR. iOS is written but unbuilt: it needs a Mac build (no iOS job in CI) and a core lib rebuilt from the new simplexmq pin; expect MsgContent.assetTransfer exhaustiveness one-liners and a few accessor fixes on first xcodebuild.
This commit is contained in:
1 parent
dd0dcbf2bc
commit
31cd2619da
34 files changed
+2970
-7
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import SwiftUI
|
||||
import SimpleXChat
|
||||
|
||||
// The recovery key for the user's names. For most users this is the only backup
|
||||
// they have of anything. The stakes are impersonation, not loss: whoever holds
|
||||
// it can point a name at their own address.
|
||||
struct NameRecoveryKeyView: View {
|
||||
@State private var phrase: String? = nil
|
||||
@State private var loadFailed = false
|
||||
@State private var saved = false
|
||||
@State private var revealed = false
|
||||
|
||||
var body: some View {
|
||||
List {
|
||||
Section { Text("These words control your names. Anyone who has them controls your names too.").foregroundColor(.secondary) }
|
||||
|
||||
if loadFailed {
|
||||
Section { Text("Could not load your names. Check your connection and reopen this screen.").foregroundColor(.orange) }
|
||||
} else if phrase == nil {
|
||||
Section { Text("You will get a recovery key when you get your first name.").foregroundColor(.secondary) }
|
||||
} else if !revealed {
|
||||
Section {
|
||||
Button { revealed = true } label: { Label("Show recovery key", systemImage: "eye").foregroundColor(.accentColor) }
|
||||
} footer: { Text("Make sure no one can see your screen.") }
|
||||
} else {
|
||||
Section("Your recovery key") {
|
||||
Text(phrase!).font(.body.monospaced()).fontWeight(.medium)
|
||||
Button("Copy") { UIPasteboard.general.string = phrase }.foregroundColor(.accentColor)
|
||||
} footer: {
|
||||
Text("Write these words down and keep them somewhere safe and offline. Anyone who takes a photo of this screen can take your names.")
|
||||
}
|
||||
Section {
|
||||
if saved { Text("You marked this as saved.").foregroundColor(.secondary) }
|
||||
else { Button { markSaved() } label: { Label("I have saved it", systemImage: "checkmark").foregroundColor(.accentColor) } }
|
||||
}
|
||||
}
|
||||
|
||||
Section("If someone else gets this key") {
|
||||
Text("They can point your name at their own profile, so people looking for you would find them instead.").foregroundColor(.red)
|
||||
}
|
||||
}
|
||||
.navigationTitle("Recovery key")
|
||||
.task {
|
||||
if let r = await apiNameRecoveryKey() { phrase = r.phrase; saved = r.saved } else { loadFailed = true }
|
||||
}
|
||||
}
|
||||
|
||||
private func markSaved() { Task { if await apiNameRecoveryKeySaved() { saved = true } } }
|
||||
}
|
||||
Reference in new issue
Block a user