Merge pull request #7341 from vector-im/alfogrillo/pollhistory_design_change

Improve SegmentedPicker UI
This commit is contained in:
Alfonso Grillo
2023-02-06 14:55:30 +01:00
committed by GitHub
2 changed files with 19 additions and 1 deletions
@@ -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(
+1
View File
@@ -0,0 +1 @@
Polls: update poll history UI.