mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-22 02:53:59 +00:00
61 lines
2.0 KiB
Swift
61 lines
2.0 KiB
Swift
import SwiftUI
|
|
|
|
/// View for the modes
|
|
struct ModeSelectorButton: View {
|
|
// MARK: Properties
|
|
|
|
|
|
/// If toll roads should be avoided during routing
|
|
@State var mode: MapMode
|
|
|
|
/// If toll roads should be avoided during routing
|
|
@Binding var selectedMode: MapMode
|
|
|
|
|
|
/// The actual view
|
|
var body: some View {
|
|
ZStack {
|
|
VStack(spacing: 0) {
|
|
ZStack {
|
|
mode.borderColor
|
|
.padding(.top, 16)
|
|
.padding(.bottom, selectedMode == mode ? 0 : 24)
|
|
|
|
mode.borderColor
|
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
}
|
|
.padding(.bottom, selectedMode == mode ? 0 : 8)
|
|
}
|
|
.compositingGroup()
|
|
|
|
Button {
|
|
selectedMode = mode
|
|
} label: {
|
|
Label {
|
|
Text(mode.description)
|
|
} icon: {
|
|
mode.color
|
|
.aspectRatio(1, contentMode: .fill)
|
|
.overlay {
|
|
ZStack {
|
|
RoundedRectangle(cornerRadius: 8).stroke(lineWidth: selectedMode == mode ? 8 : 2).foregroundColor(mode.borderColor)
|
|
|
|
mode.image
|
|
.resizable()
|
|
.aspectRatio(contentMode: .fit)
|
|
.padding(12)
|
|
.foregroundStyle(.white)
|
|
}
|
|
}
|
|
.clipShape(RoundedRectangle(cornerRadius: 8))
|
|
.compositingGroup()
|
|
.padding(.bottom, 8)
|
|
}
|
|
.labelStyle(.iconOnly)
|
|
.animation(nil, value: selectedMode)
|
|
}
|
|
}
|
|
.clipped()
|
|
}
|
|
}
|