mirror of
https://github.com/VernissageApp/Vernissage.git
synced 2025-01-17 03:38:55 +01:00
44 lines
983 B
Swift
44 lines
983 B
Swift
|
//
|
||
|
// https://mczachurski.dev
|
||
|
// Copyright © 2022 Marcin Czachurski and the repository contributors.
|
||
|
// Licensed under the MIT License.
|
||
|
//
|
||
|
|
||
|
|
||
|
import SwiftUI
|
||
|
|
||
|
struct TagView<Content: View>: View {
|
||
|
let content: Content
|
||
|
let action: () -> Void
|
||
|
|
||
|
init(action: @escaping () -> Void, @ViewBuilder content: () -> Content) {
|
||
|
self.content = content()
|
||
|
self.action = action
|
||
|
}
|
||
|
|
||
|
var body: some View {
|
||
|
Button {
|
||
|
self.action()
|
||
|
} label: {
|
||
|
content
|
||
|
.padding(.horizontal, 12)
|
||
|
.padding(.vertical, 6)
|
||
|
.background(Color("actionButtonColor"))
|
||
|
.clipShape(Capsule())
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
struct TagView_Previews: PreviewProvider {
|
||
|
static var previews: some View {
|
||
|
TagView {
|
||
|
|
||
|
} content: {
|
||
|
HStack {
|
||
|
Image(systemName: "arrow.2.squarepath")
|
||
|
Text("7 boosts")
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|