mirror of
https://github.com/seemoo-lab/openhaystack.git
synced 2026-02-14 17:49:54 +00:00
Allow changing color
This commit is contained in:
@@ -20,6 +20,7 @@ struct AccessoryListEntry: View {
|
||||
let formatter = DateFormatter()
|
||||
|
||||
@State var editingName: Bool = false
|
||||
@State var editingColor: Bool = false
|
||||
|
||||
func timestampView() -> some View {
|
||||
formatter.dateStyle = .short
|
||||
@@ -39,6 +40,12 @@ struct AccessoryListEntry: View {
|
||||
HStack {
|
||||
IconSelectionView(selectedImageName: $accessoryIcon, selectedColor: $accessoryColor)
|
||||
|
||||
if self.editingColor {
|
||||
ColorPicker(selection: $accessoryColor, supportsOpacity: false) {
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
|
||||
VStack(alignment: .leading) {
|
||||
if self.editingName {
|
||||
TextField("Enter accessory name", text: $accessoryName, onCommit: { self.editingName = false })
|
||||
@@ -49,7 +56,6 @@ struct AccessoryListEntry: View {
|
||||
.font(.headline)
|
||||
}
|
||||
self.timestampView()
|
||||
|
||||
}
|
||||
|
||||
Spacer()
|
||||
@@ -65,11 +71,16 @@ struct AccessoryListEntry: View {
|
||||
}
|
||||
.padding(EdgeInsets(top: 5, leading: 0, bottom: 5, trailing: 0))
|
||||
.contextMenu {
|
||||
Button("Rename", action: { self.editingName = true })
|
||||
Button("Delete", action: { self.delete(accessory) })
|
||||
Divider()
|
||||
Button("Rename", action: { self.editingName = true })
|
||||
Button("Change color", action: { self.editingColor = true })
|
||||
Divider()
|
||||
Button("Copy advertisment key (Base64)", action: { self.copyPublicKey(of: accessory) })
|
||||
Button("Copy key id (Base64)", action: { self.copyPublicKeyHash(of: accessory) })
|
||||
Button("Copy key ID (Base64)", action: { self.copyPublicKeyHash(of: accessory) })
|
||||
}
|
||||
.onChange(of: self.accessoryColor) { _ in
|
||||
self.editingColor = false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,26 +68,24 @@ struct ImageSelectionList: View {
|
||||
let dismiss: () -> Void
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
List(self.selectableIcons, id: \.self) { iconName in
|
||||
Button(
|
||||
action: {
|
||||
self.selectedImageName = iconName
|
||||
self.dismiss()
|
||||
},
|
||||
label: {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(systemName: iconName)
|
||||
Spacer()
|
||||
}
|
||||
List(self.selectableIcons, id: \.self) { iconName in
|
||||
Button(
|
||||
action: {
|
||||
self.selectedImageName = iconName
|
||||
self.dismiss()
|
||||
},
|
||||
label: {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(systemName: iconName)
|
||||
Spacer()
|
||||
}
|
||||
)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.frame(width: 100)
|
||||
}
|
||||
)
|
||||
.buttonStyle(PlainButtonStyle())
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.frame(width: 100)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user