Skip to content

Commit bcaf417

Browse files
Badarinath VenkatnarayansettyBadarinath Venkatnarayansetty
authored andcommitted
Fix merge conflicts
2 parents 0a8999f + 11ba20e commit bcaf417

File tree

13 files changed

+191
-159
lines changed

13 files changed

+191
-159
lines changed

Example/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PODS:
44
- FBSnapshotTestCase/Core (2.1.4)
55
- FBSnapshotTestCase/SwiftSupport (2.1.4):
66
- FBSnapshotTestCase/Core
7-
- StepperView (1.0.4)
7+
- StepperView (1.1.0)
88

99
DEPENDENCIES:
1010
- FBSnapshotTestCase (~> 2.1.4)
@@ -20,7 +20,7 @@ EXTERNAL SOURCES:
2020

2121
SPEC CHECKSUMS:
2222
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
23-
StepperView: 3c1e9d67bfd4c73040e42b0488548ebaada5abc4
23+
StepperView: 25478de5670fdd777852f8fe90461fabf0b13c4e
2424

2525
PODFILE CHECKSUM: 9f7510adb19f7a52307ff19e961fb8365a7bc522
2626

Example/Pods/Local Podspecs/StepperView.podspec.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Manifest.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Pods.xcodeproj/project.pbxproj

Lines changed: 125 additions & 125 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/Pods/Target Support Files/StepperView/StepperView-Info.plist

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example/StepperView/ExampleView3.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct ExampleView3:View {
2020
CustomView(text: "Select type of Account",imageName: "cash")
2121
]
2222

23-
let alignments = [StepperAlignment.top, .center, .bottom, .bottom]
23+
let alignments = [StepperAlignment.center, .center, .center, .center]
2424

2525
let indicationTypes = [
2626
StepperIndicationType<AnyView>.circle(Colors.teal.rawValue,12),

Sources/StepperView/Views/LineView.swift

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ struct LineView: View {
1414
@Binding var lineXPosition:CGFloat
1515
@Binding var lineYPosition:CGFloat
1616
var options:StepperLineOptions
17-
var alignment:StepperAlignment
17+
var alignments:(StepperAlignment,StepperAlignment)
1818
var body:some View {
1919
switch options {
2020
case .defaults:
@@ -30,27 +30,30 @@ struct LineView: View {
3030
.frame(width: width, height: lineHeight)
3131
// X: subtract one pixel only if the width is 1
3232
// Y: subtract half of the lineYposition to set to it's center position.
33-
.offset(x: width == 1 ? lineXPosition/2 - Utils.halfSpacing - 1 : (lineXPosition/2 - Utils.halfSpacing) , y: getYOffsetPosition(for: self.alignment, and: lineYPosition))
33+
.offset(x: width == 1 ? lineXPosition/2 - Utils.halfSpacing - 1 : (lineXPosition/2 - Utils.halfSpacing),
34+
y: getYOffsetPosition(for: alignments.0, last: alignments.1, and: lineYPosition))
3435
.padding()
3536
.eraseToAnyView()
3637
}
3738
}
3839

39-
func getYOffsetPosition(for alignment: StepperAlignment,and offset: CGFloat ) -> CGFloat {
40-
switch alignment {
41-
case .top, .center:
42-
print(lineYPosition - 2 * lineYPosition / 2)
43-
return (lineYPosition - lineYPosition / 2)
44-
case .bottom:
45-
print(lineYPosition + (lineYPosition / 2))
46-
return lineYPosition + (lineYPosition / 2)
40+
// returns Y offset position based on first and last alignments.
41+
func getYOffsetPosition(for first: StepperAlignment,last: StepperAlignment, and offset: CGFloat ) -> CGFloat {
42+
switch (first, last) {
43+
//top variations
44+
case (.top, .top): return -VerticalAlignment.centerValue
45+
case (.top, .center) : return -(VerticalAlignment.centerValue / 2)
46+
case (.top, .bottom): return (lineYPosition - 2 * lineYPosition / 2)
47+
48+
//center variations
49+
case (.center, .top): return (lineYPosition - 3 * lineYPosition / 2)
50+
case (.center, .center): return (lineYPosition - 2 * lineYPosition / 2)
51+
case (.center, .bottom) : return (lineYPosition - lineYPosition / 2)
52+
53+
//bottom variations
54+
case (.bottom, .top): return (lineYPosition - 2 * lineYPosition / 2)
55+
case (.bottom, .center): return (lineYPosition - 1.5 * lineYPosition / 2)
56+
case (.bottom,.bottom):return (lineYPosition - lineYPosition / 2)
4757
}
4858
}
4959
}
50-
51-
52-
/*
53-
(.center, .center) = (lineYPosition - 2 * lineYPosition / 2)
54-
(.center, .bottom) = (lineYPosition - lineYPosition / 2)
55-
(.top, .bottom) = (lineYPosition - 2 * lineYPosition / 2)
56-
*/

Sources/StepperView/Views/StepperView.swift

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public struct StepperView<Cell>: View where Cell:View {
5353
public var body: some View {
5454
HStack {
5555
//line view to host indicator to point
56-
LineView(lineHeight: $lineHeight, lineXPosition: $lineXPosition, lineYPosition: $lineYPosition, options: self.lineOptions, alignment: self.firstAlignment)
56+
LineView(lineHeight: $lineHeight, lineXPosition: $lineXPosition, lineYPosition: $lineYPosition, options: self.lineOptions, alignments: (self.firstAlignment, self.lastAlignment))
5757
VStack(spacing: verticalSpacing) {
5858
ForEach(self.cells.indices) { index in
5959
HStack(alignment: self.getAlignment(type: self.alignments[index])) {
@@ -79,30 +79,59 @@ public struct StepperView<Cell>: View where Cell:View {
7979
.onPreferenceChange(VerticalHeightPreference.self){
8080
print("Height of Divider \($0)")
8181
let finalHeight = $0.values.max() ?? 0.0
82-
self.lineHeight = finalHeight - self.bisectHeightsForFirstAndLastAlignments()
83-
print("Line Height \(self.lineHeight)")
82+
//print("Heights Based on First and Last alignments \(self.calculateHeightsForFirstAndLastAlignments())")
83+
self.lineHeight = finalHeight - self.calculateHeightsForFirstAndLastAlignments()
84+
print("Final Line Height \(self.lineHeight)")
8485
}
8586
}.padding()
8687
}
8788

88-
/// calculate intermediate heights of the view.
89+
// Calculate intermediate heights of the view.
8990
/// - Parameter value: dictionary to hold the index and height values.
9091
private func calculateIntermediateHeights( value: [Int:CGFloat] ) {
9192
self.columnHeights = value
9293
print("Intermediate Divider Height \(self.columnHeights)")
9394
}
9495

95-
9696
// returns the first alignemnt from the array else .center by default
9797
private var firstAlignment: StepperAlignment {
9898
return self.alignments.first ?? .center
9999
}
100100

101+
// returns the last alignemnt from the array else .center by default
101102
public var lastAlignment: StepperAlignment {
102103
return self.alignments.last ?? .center
103104
}
104-
105-
func bisectHeightsForFirstAndLastAlignments() -> CGFloat {
106-
return (lastAlignment == .bottom) ? self.getYPosition(for: self.firstAlignment) : 2 * self.getYPosition(for: self.firstAlignment)
105+
}
106+
107+
//MARK:- Helper methods for StepperView
108+
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
109+
extension StepperView {
110+
// Calculates the height based on first and last alignments.
111+
func calculateHeightsForFirstAndLastAlignments() -> CGFloat {
112+
if self.alignments.count > 1 {
113+
switch (firstAlignment, lastAlignment) {
114+
//Reduce 3 times to get actual height
115+
case (.center, .top): return 3 * self.getYPosition(for: .center)
116+
//Reduce 2 times to get actual height
117+
case (.center, .center): return 2 * self.getYPosition(for: .center)
118+
//Reduce 1 time to get actual height
119+
case (.center, .bottom): return self.getYPosition(for: .center)
120+
121+
//Reduce 1 time to get actual height
122+
case (.top, .center): return self.getYPosition(for: .center)
123+
case (.top, .bottom): return self.getYPosition(for: firstAlignment)
124+
//Reduce 2 times to get actual height
125+
case (.top, .top): return 2 * self.getYPosition(for: .center)
126+
127+
//Reduce 2 times as it's messured from it's first alignment (.bottom isn this case)
128+
case(.bottom, .top): return 2 * self.getYPosition(for: firstAlignment)
129+
//Reduce 3 times to get actual height
130+
case (.bottom, .center): return 3 * self.getYPosition(for: .center)
131+
case (.bottom, .bottom): return self.getYPosition(for: firstAlignment)
132+
}
133+
} else {
134+
return self.getYPosition(for: self.firstAlignment)
135+
}
107136
}
108137
}

StepperView.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'StepperView'
11-
s.version = '1.1.1'
11+
s.version = '1.1.2'
1212
s.swift_version = '5.0'
1313
s.summary = 'SwiftUI iOS component for Step Indications.'
1414
s.description = 'Stepper View Indication componet for SwiftUI'

images/bottom_bottom_alignment.png

27.1 KB
Loading

images/center_center_alignment.png

27.4 KB
Loading
67.2 KB
Loading

images/top_bottom_alignment.png

27.4 KB
Loading

0 commit comments

Comments
 (0)