Skip to content

Add support for custom colors for lines in .pending state #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/StepperView/Views/Lines/HorizontalLineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct HorizontalLineView: View {
.frame(width: dividerWidth, height: height)
.offset(y: -(lineYOffsetPosition + 1))
.eraseToAnyView()
case .rounded(_,_,_):
case .rounded(_,_,_,_):
return EmptyView().eraseToAnyView()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/StepperView/Views/Lines/PitStopLineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct PitStopLineView: View {
.frame(width: width, height: proxy.size.height)
.offset(x: proxy[value].midX - self.width / 2 - (width + 1), y: proxy[value].maxY)
.eraseToAnyView()
case .rounded(_, _, _):
case .rounded(_, _, _, _):
return EmptyView().eraseToAnyView()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/StepperView/Views/Lines/VerticalLineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct VerticalLineView: View {
y: getYOffsetPosition(for: alignments.0, last: alignments.1, and: lineYPosition))
.padding()
.eraseToAnyView()
case .rounded(_, _, _):
case .rounded(_, _, _, _):
return EmptyView().eraseToAnyView()
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/StepperView/Views/StepIndicatorHorizontalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct StepIndicatorHorizontalView<Cell:View>: View {
self.horizontalSpacing = horizontalSpacing
self.lineOptions = lineOptions
switch lineOptions {
case .rounded(_, _, _):
case .rounded(_, _, _, _):
self.isRounded = true
default: self.isRounded = false
}
Expand Down Expand Up @@ -136,10 +136,10 @@ struct StepIndicatorHorizontalView<Cell:View>: View {
private func drawCustomLine(proxy: GeometryProxy, value: Anchor<CGRect>, index: Int) -> some View {
guard index != self.cells.count - 1 else { return EmptyView().eraseToAnyView() }
switch lineOptions {
case .rounded(let width, let cornerRadius, let color):
case .rounded(let width, let cornerRadius, let color, let pendingColor):
// draw a line
return RoundedRectangle(cornerRadius: cornerRadius)
.foregroundColor(stepLifeCycle[index] == StepLifeCycle.completed ? color : Color.gray.opacity(0.5))
.foregroundColor(stepLifeCycle[index] == StepLifeCycle.completed ? color : pendingColor)
.frame(width: self.horizontalSpacing, height: width)
.offset(x: proxy[value].maxX + width, y: proxy[value].midY)
.eraseToAnyView()
Expand Down
6 changes: 3 additions & 3 deletions Sources/StepperView/Views/StepIndicatorVerticalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct StepIndicatorVerticalView<Cell>: View where Cell:View {
self.verticalSpacing = verticalSpacing
self.lineOptions = lineOptions
switch lineOptions {
case .rounded(_, _, _):
case .rounded(_, _, _, _):
self.isRounded = true
default: self.isRounded = false
}
Expand Down Expand Up @@ -219,10 +219,10 @@ extension StepIndicatorVerticalView {
private func drawCustomLine(proxy: GeometryProxy, value: Anchor<CGRect>, index: Int) -> some View {
guard index != self.cells.count - 1 else { return EmptyView().eraseToAnyView() }
switch lineOptions {
case .rounded(let width, let cornerRadius, let color):
case .rounded(let width, let cornerRadius, let color, let pendingColor):
// draw a line
return RoundedRectangle(cornerRadius: cornerRadius)
.foregroundColor(stepLifeCycle[index] == StepLifeCycle.completed ? color : Color.gray.opacity(0.5))
.foregroundColor(stepLifeCycle[index] == StepLifeCycle.completed ? color : pendingColor)
.frame(width: width, height: self.verticalSpacing)
.offset(x: proxy[value].midX - width/2, y: proxy[value].maxY)
.eraseToAnyView()
Expand Down
4 changes: 2 additions & 2 deletions Sources/StepperView/Views/StepperView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public enum StepperLineOptions {
case defaults
/// custom line option with `width` and `Color`
case custom(CGFloat, Color)
/// rounded line options with `width` , `corner radius` and `Color`
case rounded(CGFloat, CGFloat, Color)
/// rounded line options with `width` , `corner radius`, `completed color` and `pending color`
case rounded(CGFloat, CGFloat, Color, Color = Color.gray.opacity(0.5))
}

/**
Expand Down