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 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)
} }

View File

@@ -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 {

View File

@@ -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) {