diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 30904cf..f9fcc45 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -16,6 +16,10 @@ "comment" : "A button that adds a new bike to the list of bikes.", "isCommentAutoGenerated" : true }, + "Betrag" : { + "comment" : "A text field for entering an amount.", + "isCommentAutoGenerated" : true + }, "Bikes" : { "comment" : "The title of the list section in the BikeSwipe tab.", "isCommentAutoGenerated" : true @@ -24,6 +28,10 @@ "comment" : "A word displayed in a list item.", "isCommentAutoGenerated" : true }, + "Check-out" : { + "comment" : "A title for a screen where a user can check out items.", + "isCommentAutoGenerated" : true + }, "count: %lld\nunicode: %lld\nlength: %lld" : { "comment" : "Displays information about the number of characters, Unicode scalars, and bytes in a given string.", "isCommentAutoGenerated" : true, @@ -69,6 +77,14 @@ "comment" : "A button that triggers an alert when pressed.", "isCommentAutoGenerated" : true }, + "split between %lld" : { + "comment" : "A stepper that allows the user to select how many people should split the bill. The argument is a description of the stepper, the second is the binding value for the selected number, and the third is", + "isCommentAutoGenerated" : true + }, + "Summe" : { + "comment" : "A text field for entering the total amount to be split.", + "isCommentAutoGenerated" : true + }, "Swapping %@ <-> %@" : { "comment" : "A label displaying the current state of the swap operation, showing the values of the two variables before and after the swap.", "isCommentAutoGenerated" : true, diff --git a/SplitAppView.swift b/SplitAppView.swift new file mode 100644 index 0000000..8140e7f --- /dev/null +++ b/SplitAppView.swift @@ -0,0 +1,69 @@ +import SwiftUI + +struct SplitAppView: View { + @State var amount: String = "100.0" + @State var tip: Double = 0.0 + @State var people: Int = 1 + + @State private var selectedCurrency: String = "EUR" + + private let currencies = ["EUR", "USD", "GBP", "JPY"] + + private var formattedAmount: String { + // Formatiere den Betrag als Währung + let numberFormatter = NumberFormatter() + numberFormatter.numberStyle = .currency + numberFormatter.currencyCode = selectedCurrency + if let amountDouble = Double(amount) { + return numberFormatter.string(from: NSNumber(value: amountDouble)) ?? "" + } + return "" + } + +// enum Tip: Double, CaseIterable, Identifiable { +// case 0.0,.10,0.15,0.20 +// var id: Double { self.rawValue } +// } + + var body: some View { + VStack { + TextField("Betrag", text: $amount) + .keyboardType(.decimalPad) + .textFieldStyle(RoundedBorderTextFieldStyle()) + .padding() + + } + + + // Picker("Währung wählen:", selection: $selectedCurrency) { + // ForEach(currencies, id: \.self) { currency in + // Text(currency).tag(currency) + // } + // } + // .pickerStyle(MenuPickerStyle()) + // .padding() + + Text("Check-out") + Form { + TextField("Summe", text: $amount) + .keyboardType(.decimalPad) + + + + // Picker("Tip", sources: Tip, selection: $tip) + // .keyboardType(.decimalPad) + // .pickerStyle(.segmented) + + Stepper("split between \(people)", value: $people, in: 1...10) + + // Button("Split") { + // split = (total + (total * tip / 100.0)) / Double(people) + // } + } + } +} + + +#Preview { + SplitAppView() +} diff --git a/TheSwiftWeek.xcodeproj/project.pbxproj b/TheSwiftWeek.xcodeproj/project.pbxproj index 5586cb3..3345335 100644 --- a/TheSwiftWeek.xcodeproj/project.pbxproj +++ b/TheSwiftWeek.xcodeproj/project.pbxproj @@ -28,6 +28,7 @@ FBE1A29D2EAA1B4300081638 /* UniView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBE1A29C2EAA1B4300081638 /* UniView.swift */; }; FBE1A29F2EAA225600081638 /* NewUnicycleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBE1A29E2EAA225600081638 /* NewUnicycleView.swift */; }; FBE1A2A12EAA340F00081638 /* WebAppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBE1A2A02EAA340F00081638 /* WebAppView.swift */; }; + FBE1A2A32EAA635600081638 /* SplitAppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBE1A2A22EAA635600081638 /* SplitAppView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -53,6 +54,7 @@ FBE1A29C2EAA1B4300081638 /* UniView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UniView.swift; sourceTree = ""; }; FBE1A29E2EAA225600081638 /* NewUnicycleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewUnicycleView.swift; sourceTree = ""; }; FBE1A2A02EAA340F00081638 /* WebAppView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebAppView.swift; sourceTree = ""; }; + FBE1A2A22EAA635600081638 /* SplitAppView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SplitAppView.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -70,6 +72,7 @@ isa = PBXGroup; children = ( FBE1A2A02EAA340F00081638 /* WebAppView.swift */, + FBE1A2A22EAA635600081638 /* SplitAppView.swift */, FBA00D742EA7ACDD006F8B9A /* SwapperView.swift */, FBA00D702EA7A830006F8B9A /* PaddingView.swift */, FBA00D6E2EA78850006F8B9A /* Color.swift */, @@ -187,6 +190,7 @@ 0CC14A892E92EEA900271E8D /* Playground.swift in Sources */, FBA6FA642EA7715E00C373EC /* Extentions.swift in Sources */, FB79FE4A2EA906CC0011678F /* UnicycleView.swift in Sources */, + FBE1A2A32EAA635600081638 /* SplitAppView.swift in Sources */, 0CC14A872E92EC7B00271E8D /* App.swift in Sources */, FBE1A29F2EAA225600081638 /* NewUnicycleView.swift in Sources */, FBA00D732EA7A96C006F8B9A /* ContentView.swift in Sources */, diff --git a/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate b/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate index 1c43ec6..4da3d6c 100644 Binary files a/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate and b/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate differ