Providing option for custom spacing (#87)

Co-authored-by: Badarinath Venkatnarayansetty <Badarinath_Venkatnarayansetty@intuit.com>
This commit is contained in:
Badarinath Venkatnarayansetty
2021-08-26 11:44:04 -07:00
committed by GitHub
parent f320167dea
commit d4420f6b31
5 changed files with 29 additions and 4 deletions
+1
View File
@@ -38,6 +38,7 @@ struct ExampleView3:View {
.stepIndicatorMode(StepperMode.vertical)
.indicators(indicationTypes)
.lineOptions(StepperLineOptions.custom(1, Colors.blue(.teal).rawValue))
.stepperEdgeInsets(EdgeInsets(top: 10, leading: 5, bottom: 10, trailing: 10)) // for custom leading , trailing , top and bottom spacing
}
}.padding(.vertical, 50)
}
+6 -3
View File
@@ -66,7 +66,7 @@ StepperView is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile.
```ruby
pod 'StepperView','~> 1.6.6'
pod 'StepperView','~> 1.6.7'
```
## Carthage
@@ -74,7 +74,7 @@ pod 'StepperView','~> 1.6.6'
[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate StepperView into your Xcode project using Carthage, specify it in your Cartfile:
```ruby
github "badrinathvm/stepperView" == 1.6.6
github "badrinathvm/stepperView" == 1.6.7
```
## Swift Package Manager
@@ -83,7 +83,7 @@ StepperView is available through [Swift Package Manager](https://swift.org/packa
```ruby
dependencies: [
.package(url: "https://github.com/badrinathvm/StepperView.git", from: "1.6.6")
.package(url: "https://github.com/badrinathvm/StepperView.git", from: "1.6.7")
]
```
@@ -172,6 +172,9 @@ dependencies: [
.pitStopLineOptions(_ options: [StepperLineOptions])
1. line customization `color` , `width` , `corner radius`
.stepperEdgeInsets(_ value: EdgeInsets)
1. Provides custiom `leading`, `trailing`, `top` & `bottom` spacing.
```
## Usage
@@ -82,6 +82,12 @@ 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 +173,10 @@ struct StepLifeCycleKey: EnvironmentKey {
/// provide a default value for custom dependency
static var defaultValue:[StepLifeCycle] = []
}
/// Environment Key for pit stop line options.
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
struct StepperEdgeInsetsKey: EnvironmentKey {
/// provide a default value for custom dependency
static var defaultValue: EdgeInsets = EdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10)
}
@@ -156,6 +156,11 @@ public extension View {
self.environment(\EnvironmentValues.autoSpacing, value)
}
/// Configures edgeInsets to environment value
func stepperEdgeInsets(_ value: EdgeInsets) -> some View {
self.environment(\EnvironmentValues.stepperEdgeInsets, value)
}
/// Configures line options to environment value
func lineOptions(_ options: StepperLineOptions) -> some View {
self.environment(\EnvironmentValues.lineOptions, options)
@@ -33,6 +33,9 @@ struct StepIndicatorVerticalView<Cell>: View where Cell:View {
/// environment variable to access autospacing
@Environment(\.autoSpacing) var autoSpacing
/// environment variable for edge Insets
@Environment(\.stepperEdgeInsets) var stepperEdgeInsets
/// environment variable to access steplife cycles
@Environment(\.stepLifeCycle) var stepLifeCycle
@@ -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(stepperEdgeInsets)
}
}