badrinathvm / StepperView

SwiftUI iOS component for Step Indications.
https://badrinathvm.github.io/StepperView/
MIT License
1.27k stars 61 forks source link

First and last steps do not appear on line when displayed vertically #61

Closed jeffgrann closed 3 years ago

jeffgrann commented 3 years ago

Describe the bug Display issue with the first and last steps when displayed vertically where the indicator and text is indented to the right from the line.

To Reproduce Use the code from the readme and change .horizontal to .vertical:

struct MyMain: View {
    let steps = [ Text("Cart").font(.caption),
                  Text("Delivery Address").font(.caption),
                  Text("Order Summary").font(.caption),
                  Text("Payment Method").font(.caption),
                  Text("Track").font(.caption)]

    let indicationTypes = [StepperIndicationType.custom(NumberedCircleView(text: "1")),
                            .custom(NumberedCircleView(text: "2")),
                            .custom(NumberedCircleView(text: "3")),
                            .custom(NumberedCircleView(text: "4")),
                            .custom(NumberedCircleView(text: "5"))]

    var body: some View {
        StepperView()
            .addSteps(steps)
            .indicators(indicationTypes)
            .stepIndicatorMode(StepperMode.vertical)
            .spacing(50)
            .lineOptions(StepperLineOptions.custom(1, Colors.blue(.teal).rawValue))
    }
}

Expected behavior Indicators should line up.

Screenshots Stepper Issue

Info (please complete the following information):

Additional context N/A

badrinathvm commented 3 years ago

Hi, @jeffgrann thank you so much for checking out the library, Instead of using the Text( try using StepTextView(text: which aligns as expected.

Below is the code

 let steps = [ StepTextView(text: "Cart"),
                  StepTextView(text: "Delivery Address"),
                  StepTextView(text: "Order Summary"),
                  StepTextView(text: "Payment Method"),
                  StepTextView(text: "Track")]

    let indicationTypes = [StepperIndicationType.custom(NumberedCircleView(text: "1")),
                            .custom(NumberedCircleView(text: "2")),
                            .custom(NumberedCircleView(text: "3")),
                            .custom(NumberedCircleView(text: "4")),
                            .custom(NumberedCircleView(text: "5"))]

    var body: some View {
        StepperView()
            .addSteps(steps)
            .indicators(indicationTypes)
            .stepIndicatorMode(StepperMode.vertical)
            .spacing(50)
            .lineOptions(StepperLineOptions.custom(1, Colors.blue(.teal).rawValue))
    }

Screen Shot 2020-12-04 at 11 47 35 AM

jeffgrann commented 3 years ago

Thanks!