mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-27 23:46:18 +00:00
e87660974e
* initial implementation of textbox * paste to connect box implemented (and tested) in android * first pass at pastebox in iOS * clean up iOS implementation * put paste link page in for groups in android * initial inclusion in iOS UI * refactor naming * lint kotlin * fix typo * ios: update "connect via link" ui, refactor connecting via link to use the one function * android: update paste link UI * add russian translations * update translations Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com> * update translations Co-authored-by: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Co-authored-by: JRoberts <8711996+jr-simplex@users.noreply.github.com>
79 lines
2.7 KiB
Swift
79 lines
2.7 KiB
Swift
//
|
|
// PasteToConnectView.swift
|
|
// SimpleX (iOS)
|
|
//
|
|
// Created by Ian Davies on 22/04/2022.
|
|
// Copyright © 2022 SimpleX Chat. All rights reserved.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct PasteToConnectView: View {
|
|
@Binding var openedSheet: Bool
|
|
@State private var connectionLink: String = ""
|
|
|
|
var body: some View {
|
|
VStack(alignment: .leading) {
|
|
Text("Connect via link")
|
|
.font(.title)
|
|
.padding([.bottom])
|
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
Text("Paste the link you received into the box below to connect with your contact.")
|
|
.multilineTextAlignment(.leading)
|
|
Text("Your profile will be sent to the contact that you received this link from")
|
|
.multilineTextAlignment(.leading)
|
|
.padding(.bottom)
|
|
TextEditor(text: $connectionLink)
|
|
.onSubmit(connect)
|
|
.font(.body)
|
|
.textInputAutocapitalization(.never)
|
|
.disableAutocorrection(true)
|
|
.allowsTightening(false)
|
|
.frame(height: 180)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 10)
|
|
.strokeBorder(.secondary, lineWidth: 0.3, antialiased: true)
|
|
)
|
|
|
|
HStack(spacing: 20) {
|
|
if connectionLink == "" {
|
|
Button {
|
|
connectionLink = UIPasteboard.general.string ?? ""
|
|
} label: {
|
|
Label("Paste", systemImage: "doc.on.clipboard")
|
|
}
|
|
} else {
|
|
Button {
|
|
connectionLink = ""
|
|
} label: {
|
|
Label("Clear", systemImage: "multiply")
|
|
}
|
|
|
|
}
|
|
Spacer()
|
|
Button(action: connect, label: {
|
|
Label("Connect", systemImage: "link")
|
|
})
|
|
.disabled(connectionLink == "" || connectionLink.trimmingCharacters(in: .whitespaces).firstIndex(of: " ") != nil)
|
|
}
|
|
.frame(height: 48)
|
|
.padding(.bottom)
|
|
|
|
Text("You can also connect by clicking the link. If it opens in the browser, click **Open in mobile app** button")
|
|
.multilineTextAlignment(.leading)
|
|
}
|
|
.padding()
|
|
}
|
|
|
|
private func connect() {
|
|
connectViaLink(connectionLink.trimmingCharacters(in: .whitespaces), $openedSheet)
|
|
}
|
|
}
|
|
|
|
struct PasteToConnectView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
@State var openedSheet: Bool = true
|
|
return PasteToConnectView(openedSheet: $openedSheet)
|
|
}
|
|
}
|