diff --git a/Example/StepperView/ExampleView11.swift b/Example/StepperView/ExampleView11.swift index 63c21ad..55b3278 100644 --- a/Example/StepperView/ExampleView11.swift +++ b/Example/StepperView/ExampleView11.swift @@ -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() diff --git a/README.md b/README.md index 445318d..f33d9e7 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Sources/StepperView/Extension/EnvironmentValues+Extension.swift b/Sources/StepperView/Extension/EnvironmentValues+Extension.swift index 365e2f0..37a65cb 100644 --- a/Sources/StepperView/Extension/EnvironmentValues+Extension.swift +++ b/Sources/StepperView/Extension/EnvironmentValues+Extension.swift @@ -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 @@ -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) +} diff --git a/Sources/StepperView/Extension/View+Extensions.swift b/Sources/StepperView/Extension/View+Extensions.swift index f7a6bbc..1843924 100644 --- a/Sources/StepperView/Extension/View+Extensions.swift +++ b/Sources/StepperView/Extension/View+Extensions.swift @@ -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) + } } diff --git a/Sources/StepperView/Views/StepIndicatorHorizontalView.swift b/Sources/StepperView/Views/StepIndicatorHorizontalView.swift index 8f87a49..6524fb2 100644 --- a/Sources/StepperView/Views/StepIndicatorHorizontalView.swift +++ b/Sources/StepperView/Views/StepIndicatorHorizontalView.swift @@ -125,7 +125,6 @@ struct StepIndicatorHorizontalView: View { .multilineTextAlignment(.center) } - // MARK: - Performas line customization /// draws custom line between the indicators /// - Parameters: diff --git a/Sources/StepperView/Views/StepIndicatorVerticalView.swift b/Sources/StepperView/Views/StepIndicatorVerticalView.swift index 45aa749..6a1cac1 100644 --- a/Sources/StepperView/Views/StepIndicatorVerticalView.swift +++ b/Sources/StepperView/Views/StepIndicatorVerticalView.swift @@ -36,6 +36,9 @@ struct StepIndicatorVerticalView: 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` @@ -128,7 +131,7 @@ struct StepIndicatorVerticalView: View where Cell:View { self.dynamicSpace = Array($0.values).max() ?? 0.0 //print("Auto Spacing:: \(self.dynamicSpace)") } - }.padding() + }.padding(edgeInsets) } }