adds nice git interface
This commit is contained in:
@@ -7,13 +7,16 @@ public struct GroupItem {
|
||||
case toggle(isOn: Bool)
|
||||
}
|
||||
|
||||
/// Keeps a button's identity while its label changes, as `Git 3` does.
|
||||
var id: String
|
||||
var label: String
|
||||
var keys: String?
|
||||
var kind: Kind
|
||||
var tip: Text
|
||||
var action: () -> Void
|
||||
|
||||
public init(_ label: String, keys: String? = nil, kind: Kind, tip: Text, action: @escaping () -> Void) {
|
||||
public init(_ label: String, id: String? = nil, keys: String? = nil, kind: Kind, tip: Text, action: @escaping () -> Void) {
|
||||
self.id = id ?? label
|
||||
self.label = label
|
||||
self.keys = keys
|
||||
self.kind = kind
|
||||
@@ -34,7 +37,7 @@ public struct ButtonGroup: View {
|
||||
|
||||
public var body: some View {
|
||||
HStack(spacing: 0) {
|
||||
ForEach(Array(items.enumerated()), id: \.element.label) { index, item in
|
||||
ForEach(Array(items.enumerated()), id: \.element.id) { index, item in
|
||||
GroupButton(item: item, isFirst: index == 0, isLast: index == items.count - 1)
|
||||
.tip(item.tip, edge: tipEdge)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user