-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e08c32
commit c22a9ea
Showing
6 changed files
with
221 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Binary file modified
BIN
+15.2 KB
(230%)
...roj/project.xcworkspace/xcuserdata/joaocamargo.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
// AddressUIView.swift | ||
// CupcakeCorner | ||
// | ||
// Created by joao camargo on 04/06/21. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct AddressView: View { | ||
|
||
@ObservedObject var order : Order | ||
|
||
var body: some View { | ||
Form { | ||
Section { | ||
TextField("Name", text: $order.name) | ||
TextField("Street Address", text: $order.streetAddress) | ||
TextField("City", text: $order.city) | ||
TextField("Zip", text: $order.zip) | ||
} | ||
|
||
Section { | ||
NavigationLink(destination: CheckoutView(order: order)) { | ||
Text("Checkout") | ||
} | ||
}.disabled(!order.hasValidAddress) | ||
} .navigationBarTitle("Delivery details", displayMode: .inline) | ||
} | ||
} | ||
|
||
struct AddressUIView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
AddressView(order: Order()) | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// CheckoutView.swift | ||
// CupcakeCorner | ||
// | ||
// Created by joao camargo on 04/06/21. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CheckoutView: View { | ||
|
||
@ObservedObject var order: Order | ||
|
||
var body: some View { | ||
Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) | ||
} | ||
} | ||
|
||
struct CheckoutView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
CheckoutView(order: Order()) | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// Order.swift | ||
// CupcakeCorner | ||
// | ||
// Created by joao camargo on 04/06/21. | ||
// | ||
|
||
import Foundation | ||
|
||
class Order: ObservableObject { | ||
static let types = ["Vanilla", "Strawberry","Chocolate","Rainbow"] | ||
|
||
|
||
@Published var type = 0 | ||
@Published var quantity = 3 | ||
|
||
@Published var specialRequestEnabled = false { | ||
didSet { | ||
if !specialRequestEnabled { | ||
extraFrosting = false | ||
addSprinkles = false | ||
} | ||
} | ||
} | ||
@Published var extraFrosting = false | ||
@Published var addSprinkles = false | ||
|
||
@Published var name = "" | ||
@Published var streetAddress = "" | ||
@Published var city = "" | ||
@Published var zip = "" | ||
|
||
var hasValidAddress: Bool { | ||
if name.isEmpty || streetAddress.isEmpty || city.isEmpty || zip.isEmpty { | ||
return false | ||
} | ||
return true | ||
} | ||
|
||
} |