This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct StarsRating: View { | |
| @State var rating : [Rating] = [] | |
| func addStars (index : Int) { | |
| var currentRating : Rating = .oneStar | |
| rating.removeAll() | |
| for _ in 0 ... index { | |
| rating.append(currentRating) | |
| currentRating = currentRating.next() | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum Rating : Int, CaseIterable { | |
| case oneStar = 1 | |
| case twoStars = 2 | |
| case threeStars = 3 | |
| case fourStars = 4 | |
| case fiveStars = 5 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum OrderState : String, CaseIterable { | |
| case shoppingCart = "cart" | |
| case payment = "creditcard.fill" | |
| case shippingLocation = "mappin.and.ellipse" | |
| case complete = "shippingbox.fill" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct PurchasingSteps: View { | |
| @State var orderStatus : [OrderState] = [.shoppingCart] | |
| @State var currentStatus : OrderState = .shoppingCart | |
| var body: some View { | |
| ZStack { | |
| VStack { | |
| // MULTI-STEPS View |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct FoodDeliveryDetailed: View { | |
| let icon : String | |
| let color : Color | |
| let text : String | |
| var body: some View { | |
| VStack { | |
| Spacer() | |
| ZStack { | |
| Circle().fill(.ultraThinMaterial.opacity(0.3)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum FoodDeliveryState : String, CaseIterable { | |
| case orderReceived = "checkmark.circle" | |
| case preparingOrder = "takeoutbag.and.cup.and.straw" | |
| case onItsWay = "bicycle" | |
| case delivered = "house" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct FoodDelivery: View { | |
| @State var foodDeliveryStatus : [FoodDeliveryState] = [.orderReceived] | |
| @State var currentStatus : FoodDeliveryState = .orderReceived | |
| @State var currentColor : Color = .teal | |
| @State var accentColor : Color = .teal | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct MultiStepsView <T, Content: View> : View where T: Swift.CaseIterable { | |
| @Binding var steps: [T] | |
| let extraContent : [String]? | |
| let extraContentPosition : ExtraContentPosition? | |
| let extraContentSize : CGSize? | |
| let action : (Int) -> Void | |
| @ViewBuilder let content: () -> Content | |
| @State var numberOfSteps : Int = 0 | |
| @State var widthOfLastItem = 0.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum ExtraContentPosition { | |
| case above | |
| case inline | |
| case onTop | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct ExtraStepContent: View { | |
| let index : Int | |
| let color : Color | |
| let extraContent : [String] | |
| let extraContentSize : CGSize? | |
| var body: some View { | |
| ZStack { | |
| if let extra = extraContent[index] { | |
| if UIImage(systemName: extra) != nil { | |
| Image(systemName: extra) |
NewerOlder