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
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user