fix picker and add preview with text

simplified symbolpreview args to just a host
This commit is contained in:
neon443
2025-06-26 10:02:22 +01:00
parent 642e4a78de
commit 58596905d7
3 changed files with 30 additions and 18 deletions

View File

@@ -8,29 +8,28 @@
import SwiftUI
struct SymbolPreview: View {
@State var symbol: Symbol
@State var label: String
@State var host: Host
var body: some View {
ZStack(alignment: .center) {
if symbol.isCustom {
Image(symbol.sf)
if host.symbol.isCustom {
Image(host.symbol.sf)
.resizable().scaledToFit()
.symbolRenderingMode(.monochrome)
.padding(5)
} else {
Image(systemName: symbol.sf)
Image(systemName: host.symbol.sf)
.resizable().scaledToFit()
.symbolRenderingMode(.monochrome)
.padding(5)
}
Text(label)
Text(host.label)
.font(.headline)
.offset(symbol.offset)
.offset(host.symbol.offset)
}
}
}
#Preview {
SymbolPreview(symbol: Symbol.desktopcomputer, label: "lo0")
SymbolPreview(host: Host.debug)
}

View File

@@ -25,19 +25,31 @@ struct ConnectionView: View {
NavigationStack {
List {
Section {
HStack {
Picker("", selection: $handler.host.symbol) {
ForEach(Symbol.allCases, id: \.self) { symbol in
SymbolPreview(symbol: symbol, label: handler.host.label)
.tag(symbol)
.frame(width: 60, height: 60)
HStack {
Picker("", selection: $handler.host.symbol) {
ForEach(Symbol.allCases, id: \.self) { symbol in
Group {
if symbol.isCustom {
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)
.textFieldStyle(.roundedBorder)
}
}
Section {
HStack {

View File

@@ -44,8 +44,9 @@ struct HostsView: View {
keyManager: keyManager
)
} label: {
SymbolPreview(symbol: host.symbol, label: host.label)
.frame(width: 30, height: 30)
SymbolPreview(host: host)
.frame(width: 40, height: 40)
Text(hostsManager.makeLabel(forHost: host))
}
.animation(.default, value: host)
.swipeActions(edge: .trailing) {