mirror of
https://github.com/neon443/ShhShell.git
synced 2026-03-11 13:26:16 +00:00
fix picker and add preview with text
simplified symbolpreview args to just a host
This commit is contained in:
@@ -8,29 +8,28 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct SymbolPreview: View {
|
struct SymbolPreview: View {
|
||||||
@State var symbol: Symbol
|
@State var host: Host
|
||||||
@State var label: String
|
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
ZStack(alignment: .center) {
|
ZStack(alignment: .center) {
|
||||||
if symbol.isCustom {
|
if host.symbol.isCustom {
|
||||||
Image(symbol.sf)
|
Image(host.symbol.sf)
|
||||||
.resizable().scaledToFit()
|
.resizable().scaledToFit()
|
||||||
.symbolRenderingMode(.monochrome)
|
.symbolRenderingMode(.monochrome)
|
||||||
.padding(5)
|
.padding(5)
|
||||||
} else {
|
} else {
|
||||||
Image(systemName: symbol.sf)
|
Image(systemName: host.symbol.sf)
|
||||||
.resizable().scaledToFit()
|
.resizable().scaledToFit()
|
||||||
.symbolRenderingMode(.monochrome)
|
.symbolRenderingMode(.monochrome)
|
||||||
.padding(5)
|
.padding(5)
|
||||||
}
|
}
|
||||||
Text(label)
|
Text(host.label)
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
.offset(symbol.offset)
|
.offset(host.symbol.offset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#Preview {
|
#Preview {
|
||||||
SymbolPreview(symbol: Symbol.desktopcomputer, label: "lo0")
|
SymbolPreview(host: Host.debug)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,19 +25,31 @@ struct ConnectionView: View {
|
|||||||
NavigationStack {
|
NavigationStack {
|
||||||
List {
|
List {
|
||||||
Section {
|
Section {
|
||||||
HStack {
|
HStack {
|
||||||
Picker("", selection: $handler.host.symbol) {
|
Picker("", selection: $handler.host.symbol) {
|
||||||
ForEach(Symbol.allCases, id: \.self) { symbol in
|
ForEach(Symbol.allCases, id: \.self) { symbol in
|
||||||
SymbolPreview(symbol: symbol, label: handler.host.label)
|
Group {
|
||||||
.tag(symbol)
|
if symbol.isCustom {
|
||||||
.frame(width: 60, height: 60)
|
Image(symbol.sf)
|
||||||
|
.resizable().scaledToFit()
|
||||||
|
} else {
|
||||||
|
Image(systemName: symbol.sf)
|
||||||
|
.resizable().scaledToFit()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
.padding(5)
|
||||||
|
.tag(symbol)
|
||||||
}
|
}
|
||||||
.pickerStyle(SegmentedPickerStyle())
|
|
||||||
}
|
}
|
||||||
.scrollIndicators(.hidden)
|
.controlSize(.large)
|
||||||
|
.pickerStyle(SegmentedPickerStyle())
|
||||||
|
|
||||||
|
SymbolPreview(host: handler.host)
|
||||||
|
.frame(width: 60, height: 60)
|
||||||
|
|
||||||
TextField("label", text: $handler.host.label)
|
TextField("label", text: $handler.host.label)
|
||||||
.textFieldStyle(.roundedBorder)
|
.textFieldStyle(.roundedBorder)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Section {
|
Section {
|
||||||
HStack {
|
HStack {
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ struct HostsView: View {
|
|||||||
keyManager: keyManager
|
keyManager: keyManager
|
||||||
)
|
)
|
||||||
} label: {
|
} label: {
|
||||||
SymbolPreview(symbol: host.symbol, label: host.label)
|
SymbolPreview(host: host)
|
||||||
.frame(width: 30, height: 30)
|
.frame(width: 40, height: 40)
|
||||||
|
Text(hostsManager.makeLabel(forHost: host))
|
||||||
}
|
}
|
||||||
.animation(.default, value: host)
|
.animation(.default, value: host)
|
||||||
.swipeActions(edge: .trailing) {
|
.swipeActions(edge: .trailing) {
|
||||||
|
|||||||
Reference in New Issue
Block a user