First actions for generation view
This commit is contained in:
45
CHDataManagement/Views/Generic/ColoredButton.swift
Normal file
45
CHDataManagement/Views/Generic/ColoredButton.swift
Normal file
@ -0,0 +1,45 @@
|
||||
import SwiftUI
|
||||
import SFSafeSymbols
|
||||
|
||||
struct ColoredButton: View {
|
||||
|
||||
let icon: SFSymbol
|
||||
|
||||
let text: LocalizedStringKey
|
||||
|
||||
let fillColor: Color
|
||||
|
||||
let textColor: Color
|
||||
|
||||
let action: () -> Void
|
||||
|
||||
init(icon: SFSymbol, text: LocalizedStringKey, fillColor: Color = .blue, textColor: Color = .white, action: @escaping () -> Void) {
|
||||
self.icon = icon
|
||||
self.text = text
|
||||
self.fillColor = fillColor
|
||||
self.textColor = textColor
|
||||
self.action = action
|
||||
}
|
||||
|
||||
init(delete: @escaping () -> Void) {
|
||||
self.icon = .trash
|
||||
self.text = "Delete"
|
||||
self.fillColor = .red
|
||||
self.textColor = .white
|
||||
self.action = delete
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Button(action: action) {
|
||||
HStack {
|
||||
Spacer()
|
||||
Image(systemSymbol: icon)
|
||||
Text(text)
|
||||
.padding(.vertical, 8)
|
||||
Spacer()
|
||||
}
|
||||
.foregroundStyle(textColor)
|
||||
.background(RoundedRectangle(cornerRadius: 8).fill(fillColor))
|
||||
}.buttonStyle(.plain)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user