Skip to content
Open
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
1 change: 1 addition & 0 deletions Example/StepperView/ExampleView11.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct ExampleView11: View {
.lineOptions(StepperLineOptions.rounded(4, 8, Color(customGreen)))
.stepLifeCycles([StepLifeCycle.completed, .completed, .completed, .pending])
.spacing(40)
.edgeInsets(EdgeInsets(top: 2, leading: 5, bottom: 2, trailing: 5))
.padding(.leading, 50)

StepperView()
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ dependencies: [

.pitStopLineOptions(_ options: [StepperLineOptions])
1. line customization `color` , `width` , `corner radius`

. edgeInsets(_ edgeInsets: EdgeInsets)
1. Places the stepper view for the insets provided.
```

## Usage
Expand Down
15 changes: 15 additions & 0 deletions Sources/StepperView/Extension/EnvironmentValues+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ extension EnvironmentValues {
get { self[StepLifeCycleKey.self] }
set { self[StepLifeCycleKey.self] = newValue }
}

/// property wrapper for `StepperEdgeInsetsKey`
var stepperEdgeInsets: EdgeInsets {
get { self[StepperEdgeInsetsKey.self] }
set { self[StepperEdgeInsetsKey.self] = newValue }
}

}

/// Environment Key for Steps
Expand Down Expand Up @@ -167,3 +174,11 @@ struct StepLifeCycleKey: EnvironmentKey {
/// provide a default value for custom dependency
static var defaultValue:[StepLifeCycle] = []
}

/// Environment Key for StepperEdgeInsets .
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
struct StepperEdgeInsetsKey: EnvironmentKey {
/// provide default values for Stepper Edge Insets
static var defaultValue: EdgeInsets =
EdgeInsets(top: Utils.standardSpacing, leading: Utils.standardSpacing, bottom: Utils.standardSpacing, trailing: Utils.standardSpacing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may slightly change the default spacing, as if you just add .padding() it uses the system default (varies based on device type and other conditions). If we made stepperEdgeInsets be optional EdgeInsets? with a default value of nil then passing .padding(nil) will retain the current behavior.

Copy link
Owner Author

@badrinathvm badrinathvm May 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am evaluating this default padding behaviour across all the watchOS, iOS and test it out.

}
5 changes: 5 additions & 0 deletions Sources/StepperView/Extension/View+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,9 @@ public extension View {
print("** \(log)")
return EmptyView()
}

/// Sets edgeInsets for StepperView
func edgeInsets(_ edgeInsets: EdgeInsets) -> some View {
self.environment(\EnvironmentValues.stepperEdgeInsets, edgeInsets)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ struct StepIndicatorHorizontalView<Cell:View>: View {
.multilineTextAlignment(.center)
}


// MARK: - Performas line customization
/// draws custom line between the indicators
/// - Parameters:
Expand Down
5 changes: 4 additions & 1 deletion Sources/StepperView/Views/StepIndicatorVerticalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ struct StepIndicatorVerticalView<Cell>: View where Cell:View {
/// environment variable to access steplife cycles
@Environment(\.stepLifeCycle) var stepLifeCycle

/// environment variable to access edgeInsets
@Environment(\.stepperEdgeInsets) var edgeInsets

/// list of `View's` to display step indictor content
var cells:[Cell]
/// list of alignments to display the step indicator position can be `top` or `center` or `bottom`
Expand Down Expand Up @@ -128,7 +131,7 @@ struct StepIndicatorVerticalView<Cell>: View where Cell:View {
self.dynamicSpace = Array($0.values).max() ?? 0.0
//print("Auto Spacing:: \(self.dynamicSpace)")
}
}.padding()
}.padding(edgeInsets)
}
}

Expand Down