mirror of
https://gitlab.opencode.de/bwi/bundesmessenger/clients/bundesmessenger-ios.git
synced 2026-04-21 17:12:45 +02:00
Improve SegmentedPicker UI
This commit is contained in:
@@ -39,7 +39,7 @@ struct SegmentedPicker<Segment: Hashable & CustomStringConvertible>: View {
|
||||
} label: {
|
||||
Text(segment.description)
|
||||
.font(isSelectedSegment ? theme.fonts.headline : theme.fonts.body)
|
||||
.underline(isSelectedSegment)
|
||||
.underlineBar(isSelectedSegment)
|
||||
}
|
||||
.accentColor(isSelectedSegment ? theme.colors.accent : theme.colors.primaryContent)
|
||||
.accessibilityLabel(segment.description)
|
||||
@@ -49,6 +49,23 @@ struct SegmentedPicker<Segment: Hashable & CustomStringConvertible>: View {
|
||||
}
|
||||
}
|
||||
|
||||
private extension Text {
|
||||
@ViewBuilder
|
||||
func underlineBar(_ isActive: Bool) -> some View {
|
||||
if #available(iOS 15.0, *) {
|
||||
overlay(alignment: .bottom) {
|
||||
if isActive {
|
||||
Rectangle()
|
||||
.frame(height: 1)
|
||||
.offset(y: 2)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
underline(isActive)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SegmentedPicker_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
SegmentedPicker(
|
||||
|
||||
Reference in New Issue
Block a user