Created
March 8, 2023 16:38
-
-
Save DarrenHurst/7ef6c15824f2edd96501dcd62ce2602a to your computer and use it in GitHub Desktop.
visioning bill pay app.
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 Foundation | |
import SwiftUI | |
struct basicPadding: ViewModifier { | |
func body(content: Content) -> some View { | |
content.padding(10) | |
} | |
} | |
extension View { | |
func standardPadding() -> some View { | |
modifier(basicPadding()) | |
} | |
} | |
@available(iOS 16.0, *) | |
struct SplitIt: View { | |
@ObservedObject var viewModel = SplitItModel() | |
@State var runAnimation: Bool = false | |
@State var selection: Int? = nil | |
@State var makePayment: Bool = false | |
@State var tableBill : String = "" | |
let headerHeight: CGFloat = 88 | |
let currencyFormatter = NumberFormatter() | |
init() { | |
currencyFormatter.usesGroupingSeparator = true | |
currencyFormatter.numberStyle = .currency | |
// localize Currency to your grouping and decimal separator | |
currencyFormatter.locale = Locale.current | |
} | |
func calculateBill() { | |
self.tableBill = "Total: \( currencyFormatter.string(from: viewModel.order.totalBill as NSNumber) ?? "0.00" )" | |
} | |
var body: some View { | |
NavigationStack { | |
GeometryReader { r in | |
List { | |
Section { | |
//paymentHeaderControl() | |
paymentMenu().onAppear() { | |
self.calculateBill() | |
} | |
// Guest List | |
ForEach(viewModel.table.guests) { guest in | |
let index = viewModel.table.guests.firstIndex(of: guest) | |
tableUser(guest, false, index ?? 0).frame(height:80) | |
} | |
} | |
header: { | |
paymentSectionHeader() | |
.background(.green.opacity(0.5)) | |
.foregroundColor(.white) | |
} | |
} | |
.listStyle(.plain) | |
.padding(.top, headerHeight) | |
} | |
.background(Color.gray.opacity(0.3)) | |
.background(Color.brown.opacity(0.6)) | |
.backButtonRoot() | |
.ignoresSafeArea() | |
} | |
.fullScreenCover(isPresented: $makePayment) { | |
ZStack { | |
callServer().frame(width: 380, alignment: .leading) | |
.zIndex(2) | |
.offset(x: 15, y: 20) | |
.ignoresSafeArea() | |
.frame(height: 58).zIndex(1) | |
}.frame(alignment: .leading) | |
} | |
} | |
} | |
@available(iOS 16.0, *) | |
struct SpiltItPreview: PreviewProvider { | |
static var previews: some View { | |
SplitIt() | |
} | |
} | |
protocol SpitItData { | |
func loadData() | |
} | |
@available(iOS 16.0, *) | |
extension SplitIt { | |
class SplitItModel : ObservableObject, SpitItData { | |
@Published var primaryUser = SplitUser() | |
@Published var order:SplitItViewModel = SplitItViewModel() | |
@Published var primaryImage = Image(Users.snoopy.rawValue) | |
@Published var table: Table | |
init(){ | |
table = Table(tableNumber: 5, guests: [ .snoopy, .charlie, .lucy, .sally ]) | |
} | |
func loadData() { | |
} | |
} | |
} | |
Author
DarrenHurst
commented
Mar 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment