Skip to content

Commit

Permalink
Make pill control togglable
Browse files Browse the repository at this point in the history
  • Loading branch information
ianthetechie committed Apr 5, 2024
1 parent 820a457 commit f0f94a0
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
15 changes: 9 additions & 6 deletions apple/Sources/FerrostarSwiftUI/Views/InstructionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ public struct InstructionsView: View {
distanceFormatter: Formatter = MKDistanceFormatter(),
distanceToNextManeuver: CLLocationDistance? = nil,
primaryRowTheme: InstructionRowTheme = DefaultInstructionRowTheme(),
secondaryRowTheme: InstructionRowTheme = DefaultSecondaryInstructionRowTheme()
secondaryRowTheme: InstructionRowTheme = DefaultSecondaryInstructionRowTheme(),
showPillControl: Bool = false
) {
self.visualInstruction = visualInstruction
self.distanceFormatter = distanceFormatter
self.distanceToNextManeuver = distanceToNextManeuver
self.primaryRowTheme = primaryRowTheme
self.secondaryRowTheme = secondaryRowTheme
self.showPillControl = showPillControl
}

public var body: some View {
Expand Down Expand Up @@ -65,12 +67,12 @@ public struct InstructionsView: View {
.padding(.top, 8)

// TODO: Show the pill when interactivity is enabled
// pillControl()
pillControl(isActive: showPillControl)
}
.background(.gray.opacity(0.2))
} else {
// TODO: Show the pill when interactivity is enabled
// pillControl()
pillControl(isActive: showPillControl)
}
}
.background(Color.white)
Expand All @@ -80,10 +82,10 @@ public struct InstructionsView: View {
}

/// The pill control that is shown at the bottom of the Instructions View.
@ViewBuilder fileprivate func pillControl() -> some View {
@ViewBuilder fileprivate func pillControl(isActive: Bool) -> some View {
RoundedRectangle(cornerRadius: 3)
.frame(width: 24, height: 6)
.opacity(0.1)
.opacity(isActive ? 0.1 : 0.0)
.padding(.bottom, 8)
}
}
Expand Down Expand Up @@ -137,7 +139,8 @@ public struct InstructionsView: View {
triggerDistanceBeforeManeuver: 123
),
distanceFormatter: germanFormatter,
distanceToNextManeuver: 1500.0
distanceToNextManeuver: 1500.0,
showPillControl: true
)

Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ final class InstructionsViewTests: XCTestCase {
}
}

func testSingularInstructionsViewWithPill() {
assertView {
InstructionsView(
visualInstruction: VisualInstruction(
primaryContent: VisualInstructionContent(
text: "Use the second exit to leave the roundabout.",
maneuverType: .rotary,
maneuverModifier: .slightRight,
roundaboutExitDegrees: nil
),
secondaryContent: nil,
triggerDistanceBeforeManeuver: 123
),
distanceFormatter: americanDistanceFormatter,
primaryRowTheme: TestingInstructionRowTheme(),
secondaryRowTheme: TestingInstructionRowTheme(),
showPillControl: true
)
}
}

func testFormattingDE() {
assertView {
InstructionsView(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f0f94a0

Please sign in to comment.