mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-04 15:36:32 +00:00
* ios: set alias on connection link, see link again, remove QR code on connection * update UX for connection alias * change layout * layout * return pencil * incognito Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * color * style Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * fix * pencil color * update * remove UB sanitizer * exit edit mode * fix flicker Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com>
71 lines
2.0 KiB
Swift
71 lines
2.0 KiB
Swift
//
|
|
// CreateLinkView.swift
|
|
// SimpleX (iOS)
|
|
//
|
|
// Created by Evgeny on 21/09/2022.
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
enum CreateLinkTab {
|
|
case oneTime
|
|
case longTerm
|
|
}
|
|
|
|
struct CreateLinkView: View {
|
|
@EnvironmentObject var m: ChatModel
|
|
@State var selection: CreateLinkTab
|
|
@State var connReqInvitation: String = ""
|
|
@State private var creatingConnReq = false
|
|
var viaSettings = false
|
|
|
|
var body: some View {
|
|
TabView(selection: $selection) {
|
|
AddContactView(connReqInvitation: connReqInvitation, viaSettings: viaSettings)
|
|
.tabItem {
|
|
Label(
|
|
connReqInvitation == ""
|
|
? "Create one-time invitation link"
|
|
: "One-time invitation link",
|
|
systemImage: "1.circle"
|
|
)
|
|
}
|
|
.tag(CreateLinkTab.oneTime)
|
|
UserAddress(viaSettings: viaSettings)
|
|
.tabItem {
|
|
Label("Your contact address", systemImage: "infinity.circle")
|
|
}
|
|
.tag(CreateLinkTab.longTerm)
|
|
}
|
|
.onChange(of: selection) { _ in
|
|
if case .oneTime = selection, connReqInvitation == "" && !creatingConnReq {
|
|
createInvitation()
|
|
}
|
|
}
|
|
.onAppear { m.connReqInv = connReqInvitation }
|
|
.onDisappear { m.connReqInv = nil }
|
|
}
|
|
|
|
private func createInvitation() {
|
|
creatingConnReq = true
|
|
Task {
|
|
let connReq = await apiAddContact()
|
|
await MainActor.run {
|
|
if let connReq = connReq {
|
|
connReqInvitation = connReq
|
|
m.connReqInv = connReq
|
|
} else {
|
|
creatingConnReq = false
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct CreateLinkView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
CreateLinkView(selection: CreateLinkTab.oneTime)
|
|
}
|
|
}
|