2024-08-07 08:36:33 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct SharedNavBarButton: View {
|
|
|
|
let image: Image?
|
|
|
|
let action: () -> Void
|
|
|
|
var isEnabled: Bool = true
|
|
|
|
|
|
|
|
init(
|
|
|
|
image: Image,
|
|
|
|
action: @escaping () -> Void,
|
|
|
|
isEnabled: Bool = true
|
|
|
|
) {
|
|
|
|
self.image = image
|
|
|
|
self.action = action
|
|
|
|
self.isEnabled = isEnabled
|
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Button {
|
|
|
|
action()
|
|
|
|
} label: {
|
|
|
|
image
|
|
|
|
.foregroundColor(isEnabled ? .Material.Elements.active : .Material.Elements.inactive)
|
|
|
|
.tappablePadding(.symmetric(12)) {
|
|
|
|
action()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.disabled(!isEnabled)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SharedNavBarText: View {
|
|
|
|
let text: String
|
2024-09-19 15:24:56 +00:00
|
|
|
let action: (() -> Void)?
|
|
|
|
|
|
|
|
init(
|
|
|
|
text: String,
|
|
|
|
action: (() -> Void)? = nil
|
|
|
|
) {
|
|
|
|
self.text = text
|
|
|
|
self.action = action
|
|
|
|
}
|
2024-08-07 08:36:33 +00:00
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
Text(text)
|
|
|
|
.font(.head2)
|
|
|
|
.foregroundColor(.Material.Text.main)
|
2024-09-19 15:24:56 +00:00
|
|
|
.tappablePadding(.init(top: 8, leading: 24, bottom: 8, trailing: 24)) {
|
|
|
|
action?()
|
|
|
|
}
|
2024-08-07 08:36:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct SharedNavigationBar: View {
|
|
|
|
var leftButton: SharedNavBarButton?
|
|
|
|
var centerText: SharedNavBarText?
|
|
|
|
var rightButton: SharedNavBarButton?
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
ZStack {
|
|
|
|
Color.Material.Background.dark
|
|
|
|
.ignoresSafeArea()
|
|
|
|
|
|
|
|
VStack {
|
|
|
|
if centerText != nil {
|
|
|
|
centerText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Spacer()
|
|
|
|
|
|
|
|
HStack(alignment: .center) {
|
|
|
|
VStack {
|
|
|
|
if leftButton != nil {
|
|
|
|
leftButton?.padding()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.frame(minWidth: 40)
|
|
|
|
Spacer()
|
|
|
|
VStack {
|
|
|
|
if rightButton != nil {
|
|
|
|
rightButton?
|
|
|
|
.padding()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.frame(minWidth: 40)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.frame(height: 44)
|
|
|
|
}
|
|
|
|
}
|