mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
added textbox to make pretty textboxes with label
updated connectionview to use nice textboxes with labels put disconnect and minimize on the left
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
A96C6AFE2E0C43B600F377FE /* Keypair.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C6AFD2E0C43B600F377FE /* Keypair.swift */; };
|
A96C6AFE2E0C43B600F377FE /* Keypair.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C6AFD2E0C43B600F377FE /* Keypair.swift */; };
|
||||||
A96C6B002E0C45FE00F377FE /* KeyDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C6AFF2E0C45FE00F377FE /* KeyDetailView.swift */; };
|
A96C6B002E0C45FE00F377FE /* KeyDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C6AFF2E0C45FE00F377FE /* KeyDetailView.swift */; };
|
||||||
A96C6B022E0C49E800F377FE /* CenteredLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C6B012E0C49E800F377FE /* CenteredLabel.swift */; };
|
A96C6B022E0C49E800F377FE /* CenteredLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C6B012E0C49E800F377FE /* CenteredLabel.swift */; };
|
||||||
|
A96C90A12E12B87A00724253 /* TextBox.swift in Sources */ = {isa = PBXBuildFile; fileRef = A96C90A02E12B87900724253 /* TextBox.swift */; };
|
||||||
A98554552E05535F009051BD /* KeyManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554542E05535F009051BD /* KeyManagerView.swift */; };
|
A98554552E05535F009051BD /* KeyManagerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554542E05535F009051BD /* KeyManagerView.swift */; };
|
||||||
A98554592E0553AA009051BD /* KeyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554582E0553AA009051BD /* KeyManager.swift */; };
|
A98554592E0553AA009051BD /* KeyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A98554582E0553AA009051BD /* KeyManager.swift */; };
|
||||||
A985545D2E055D4D009051BD /* ConnectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A985545C2E055D4D009051BD /* ConnectionView.swift */; };
|
A985545D2E055D4D009051BD /* ConnectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A985545C2E055D4D009051BD /* ConnectionView.swift */; };
|
||||||
@@ -143,6 +144,7 @@
|
|||||||
A96C6AFD2E0C43B600F377FE /* Keypair.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keypair.swift; sourceTree = "<group>"; };
|
A96C6AFD2E0C43B600F377FE /* Keypair.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Keypair.swift; sourceTree = "<group>"; };
|
||||||
A96C6AFF2E0C45FE00F377FE /* KeyDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyDetailView.swift; sourceTree = "<group>"; };
|
A96C6AFF2E0C45FE00F377FE /* KeyDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyDetailView.swift; sourceTree = "<group>"; };
|
||||||
A96C6B012E0C49E800F377FE /* CenteredLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenteredLabel.swift; sourceTree = "<group>"; };
|
A96C6B012E0C49E800F377FE /* CenteredLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CenteredLabel.swift; sourceTree = "<group>"; };
|
||||||
|
A96C90A02E12B87900724253 /* TextBox.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextBox.swift; sourceTree = "<group>"; };
|
||||||
A98554542E05535F009051BD /* KeyManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyManagerView.swift; sourceTree = "<group>"; };
|
A98554542E05535F009051BD /* KeyManagerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyManagerView.swift; sourceTree = "<group>"; };
|
||||||
A98554582E0553AA009051BD /* KeyManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyManager.swift; sourceTree = "<group>"; };
|
A98554582E0553AA009051BD /* KeyManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeyManager.swift; sourceTree = "<group>"; };
|
||||||
A985545C2E055D4D009051BD /* ConnectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionView.swift; sourceTree = "<group>"; };
|
A985545C2E055D4D009051BD /* ConnectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConnectionView.swift; sourceTree = "<group>"; };
|
||||||
@@ -334,6 +336,7 @@
|
|||||||
A96C6B012E0C49E800F377FE /* CenteredLabel.swift */,
|
A96C6B012E0C49E800F377FE /* CenteredLabel.swift */,
|
||||||
A93143C52DF61FE300FCD5DB /* ViewModifiers.swift */,
|
A93143C52DF61FE300FCD5DB /* ViewModifiers.swift */,
|
||||||
A9B15A992E0ABA0400F66E02 /* DialogView.swift */,
|
A9B15A992E0ABA0400F66E02 /* DialogView.swift */,
|
||||||
|
A96C90A02E12B87900724253 /* TextBox.swift */,
|
||||||
);
|
);
|
||||||
path = Misc;
|
path = Misc;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -582,6 +585,7 @@
|
|||||||
A96BE6AD2E11825800C0FEE9 /* SessionView.swift in Sources */,
|
A96BE6AD2E11825800C0FEE9 /* SessionView.swift in Sources */,
|
||||||
A96C6B002E0C45FE00F377FE /* KeyDetailView.swift in Sources */,
|
A96C6B002E0C45FE00F377FE /* KeyDetailView.swift in Sources */,
|
||||||
A9DA97712E0D30ED00142DDC /* HostSymbol.swift in Sources */,
|
A9DA97712E0D30ED00142DDC /* HostSymbol.swift in Sources */,
|
||||||
|
A96C90A12E12B87A00724253 /* TextBox.swift in Sources */,
|
||||||
A96BE6A82E116E2B00C0FEE9 /* SessionsListView.swift in Sources */,
|
A96BE6A82E116E2B00C0FEE9 /* SessionsListView.swift in Sources */,
|
||||||
A98554612E058433009051BD /* HostsManager.swift in Sources */,
|
A98554612E058433009051BD /* HostsManager.swift in Sources */,
|
||||||
A985545D2E055D4D009051BD /* ConnectionView.swift in Sources */,
|
A985545D2E055D4D009051BD /* ConnectionView.swift in Sources */,
|
||||||
|
|||||||
@@ -51,43 +51,34 @@ struct ConnectionView: View {
|
|||||||
.id(handler.host)
|
.id(handler.host)
|
||||||
.frame(width: 60, height: 60)
|
.frame(width: 60, height: 60)
|
||||||
|
|
||||||
TextField("label", text: $handler.host.label)
|
TextBox(label: "Icon Text", text: $handler.host.label)
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Section {
|
Section {
|
||||||
Text("\(handler.state)")
|
Text("\(handler.state)")
|
||||||
.foregroundStyle(handler.state.color)
|
.foregroundStyle(handler.state.color)
|
||||||
|
|
||||||
TextField("name", text: $handler.host.name)
|
TextBox(label: "Name", text: $handler.host.name)
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
|
|
||||||
TextField("address", text: $handler.host.address)
|
TextBox(label: "Address", text: $handler.host.address)
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
|
|
||||||
TextField(
|
TextBox(label: "Port", text: Binding(
|
||||||
"port",
|
|
||||||
text: Binding(
|
|
||||||
get: { String(handler.host.port) },
|
get: { String(handler.host.port) },
|
||||||
set: {
|
set: {
|
||||||
if let input = Int($0) {
|
if let input = Int($0) {
|
||||||
handler.host.port = input
|
handler.host.port = input
|
||||||
}
|
}
|
||||||
}
|
}),
|
||||||
|
keyboardType: .numberPad
|
||||||
)
|
)
|
||||||
)
|
|
||||||
.keyboardType(.numberPad)
|
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Section {
|
Section {
|
||||||
TextField("Username", text: $handler.host.username)
|
TextBox(label: "Username", text: $handler.host.username)
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
|
|
||||||
SecureField("Password", text: $handler.host.password)
|
TextBox(label: "Password", text: $handler.host.password, secure: true)
|
||||||
.textFieldStyle(.roundedBorder)
|
|
||||||
|
|
||||||
TextField("", text: $pubkeyStr, prompt: Text("Public Key"))
|
TextBox(label: "Publickey", text: $pubkeyStr)
|
||||||
.onChange(of: pubkeyStr) { _ in
|
.onChange(of: pubkeyStr) { _ in
|
||||||
let newStr = pubkeyStr.replacingOccurrences(of: "\r\n", with: "")
|
let newStr = pubkeyStr.replacingOccurrences(of: "\r\n", with: "")
|
||||||
handler.host.publicKey = Data(newStr.utf8)
|
handler.host.publicKey = Data(newStr.utf8)
|
||||||
@@ -97,7 +88,7 @@ struct ConnectionView: View {
|
|||||||
handler.host.publicKey = Data(newStr.utf8)
|
handler.host.publicKey = Data(newStr.utf8)
|
||||||
}
|
}
|
||||||
|
|
||||||
SecureField("", text: $privkeyStr, prompt: Text("Private Key"))
|
TextBox(label: "Privatekey", text: $privkeyStr, secure: true)
|
||||||
.onSubmit {
|
.onSubmit {
|
||||||
let newStr = privkeyStr.replacingOccurrences(of: "\r\n", with: "")
|
let newStr = privkeyStr.replacingOccurrences(of: "\r\n", with: "")
|
||||||
handler.host.privateKey = Data(newStr.utf8)
|
handler.host.privateKey = Data(newStr.utf8)
|
||||||
@@ -107,7 +98,7 @@ struct ConnectionView: View {
|
|||||||
handler.host.privateKey = Data(newStr.utf8)
|
handler.host.privateKey = Data(newStr.utf8)
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField("", text: $handler.host.passphrase, prompt: Text("Passphrase (Optional)"))
|
TextBox(label: "Passphrase", text: $handler.host.passphrase)
|
||||||
}
|
}
|
||||||
|
|
||||||
Button() {
|
Button() {
|
||||||
|
|||||||
31
ShhShell/Views/Misc/TextBox.swift
Normal file
31
ShhShell/Views/Misc/TextBox.swift
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// TextBoxWLabel.swift
|
||||||
|
// ShhShell
|
||||||
|
//
|
||||||
|
// Created by neon443 on 30/06/2025.
|
||||||
|
//
|
||||||
|
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
struct TextBox: View {
|
||||||
|
@State var label: String
|
||||||
|
@Binding var text: String
|
||||||
|
@State var secure: Bool = false
|
||||||
|
@State var keyboardType: UIKeyboardType = .default
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
HStack {
|
||||||
|
Text(label)
|
||||||
|
Spacer()
|
||||||
|
if secure {
|
||||||
|
SecureField("", text: $text)
|
||||||
|
} else {
|
||||||
|
TextField("", text: $text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#Preview {
|
||||||
|
TextBox(label: "Label", text: .constant("asdflkajsdl"))
|
||||||
|
}
|
||||||
@@ -47,15 +47,6 @@ struct ShellView: View {
|
|||||||
.navigationTitle(handler.title)
|
.navigationTitle(handler.title)
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.toolbar {
|
.toolbar {
|
||||||
ToolbarItem {
|
|
||||||
Button() {
|
|
||||||
handler.disconnect()
|
|
||||||
if !handler.connected { dismiss() }
|
|
||||||
} label: {
|
|
||||||
Label("Disconnect", systemImage: "xmark.app.fill")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//TODO: FIX
|
|
||||||
ToolbarItem(placement: .cancellationAction) {
|
ToolbarItem(placement: .cancellationAction) {
|
||||||
Button() {
|
Button() {
|
||||||
dismiss()
|
dismiss()
|
||||||
@@ -63,6 +54,14 @@ struct ShellView: View {
|
|||||||
Label("Close", systemImage: "arrow.down.right.and.arrow.up.left")
|
Label("Close", systemImage: "arrow.down.right.and.arrow.up.left")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ToolbarItem(placement: .cancellationAction) {
|
||||||
|
Button() {
|
||||||
|
handler.disconnect()
|
||||||
|
if !handler.connected { dismiss() }
|
||||||
|
} label: {
|
||||||
|
Label("Disconnect", systemImage: "xmark.app.fill")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user