diff --git a/App.swift b/App.swift index 7bbb898..19b512a 100644 --- a/App.swift +++ b/App.swift @@ -11,10 +11,7 @@ struct TheSwiftWeek: App { VStack{ - Text(.myVehicle) - TrainView(train: train) - TrainView(train: train2) - Spacer() + CountView() } } diff --git a/CountView.swift b/CountView.swift new file mode 100644 index 0000000..e906df0 --- /dev/null +++ b/CountView.swift @@ -0,0 +1,34 @@ +// +// CountView.swift +// TheSwiftWeek +// +// Created by Ingo Rohlf on 21.10.25. +// + +import SwiftUI + +struct CountView: View, TabContent { + static var title = "Count" + static var image = "42.circle" + + @State var text = "" + + var body: some View { + TextField("Enter Emoji", text: $text) + .padding() + + Text(""" + Zeichenzahl: \(text.count) + Unicode: \(text.unicodeScalars.count) + UTF-8 Bytes: \(text.lengthOfBytes(using: .utf8)) + """) + + Spacer() + } +} + + + +#Preview { + CountView() +} diff --git a/ListView.swift b/ListView.swift new file mode 100644 index 0000000..88a0be6 --- /dev/null +++ b/ListView.swift @@ -0,0 +1,48 @@ +// +// ListView.swift +// TheSwiftWeek +// +// Created by Ingo Rohlf on 21.10.25. +// + +import SwiftUI + +//import Playgrounds +import Foundation + +struct ListView: View , TabContent{ + static var title = "List" + static var image = "list.bullet" + + @State var bikes = Bike.all + var body: some View { + List { + Text(bikes[0].name) + Text(bikes[1].name) + Text(bikes[2].name) + } + List(bikes, id: \.name){ bike in + HStack { + Color(bike.color) + Text(String(bike.name)) + } + } + List(bikes, id: \.name){ + Text(String($0.price)) + + + } + + } +} + + +//#Playground { +// var students = ["Bill", "Linus"] +// let size = [1.65, 1.79] +//} + + +#Preview { + ListView() +} diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 6e4d3bc..2da0d9e 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -1,10 +1,26 @@ { "sourceLanguage" : "en", "strings" : { + " Zeichenzahl: %lld\n Unicode: %lld\n UTF-8 Bytes: %lld" : { + "comment" : "A block of text showing the number of characters, Unicode scalars, and UTF-8 bytes in the text entered by the user.", + "isCommentAutoGenerated" : true, + "localizations" : { + "en" : { + "stringUnit" : { + "state" : "new", + "value" : " Zeichenzahl: %1$lld\n Unicode: %2$lld\n UTF-8 Bytes: %3$lld" + } + } + } + }, "drücken" : { "comment" : "A tab label for a tab that prints something.", "isCommentAutoGenerated" : true }, + "Enter Emoji" : { + "comment" : "A label for an text field where the user can enter an emoji.", + "isCommentAutoGenerated" : true + }, "Hello, World!" : { "comment" : "A simple text view with padding applied to it.", "isCommentAutoGenerated" : true diff --git a/Models.swift b/Models.swift index 30b8247..235eb3b 100644 --- a/Models.swift +++ b/Models.swift @@ -58,4 +58,9 @@ struct Bike: Vehicle, CustomStringConvertible { func emptyBasket() { print("emptied", Date()) } + static let all = [ + Bike(name: "Specialized",price: 100000.00, color: .purple ), + Bike(name: "Giant",price: 120000.00, color: .red ), + Bike(name: "Cannondale",price: 110000.00, color: .green ) + ] } diff --git a/Playground.swift b/Playground.swift index 5933237..67f5d34 100644 --- a/Playground.swift +++ b/Playground.swift @@ -14,5 +14,8 @@ let train = Train { Bike.trek } #Playground { // bike.price // train.makeSomeNoise("Choo Choo!") - train.content.name + for bike in Bike.all { + bike + } + } diff --git a/TheSwiftWeek.xcodeproj/project.pbxproj b/TheSwiftWeek.xcodeproj/project.pbxproj index 573c905..8357cb1 100644 --- a/TheSwiftWeek.xcodeproj/project.pbxproj +++ b/TheSwiftWeek.xcodeproj/project.pbxproj @@ -9,11 +9,13 @@ /* Begin PBXBuildFile section */ 0CC14A872E92EC7B00271E8D /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CC14A842E92EC7A00271E8D /* App.swift */; }; 0CC14A892E92EEA900271E8D /* Playground.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CC14A882E92EEA900271E8D /* Playground.swift */; }; + FB2F07E92EA7CB25002BD499 /* ListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FB2F07E82EA7CB25002BD499 /* ListView.swift */; }; FBA00D6D2EA78411006F8B9A /* Localizable.xcstrings in Resources */ = {isa = PBXBuildFile; fileRef = FBA00D6C2EA78411006F8B9A /* Localizable.xcstrings */; }; FBA00D6F2EA78853006F8B9A /* Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D6E2EA78850006F8B9A /* Color.swift */; }; FBA00D712EA7A839006F8B9A /* PaddingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D702EA7A830006F8B9A /* PaddingView.swift */; }; FBA00D732EA7A96C006F8B9A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D722EA7A96C006F8B9A /* ContentView.swift */; }; FBA00D752EA7ACE1006F8B9A /* SwapperView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D742EA7ACDD006F8B9A /* SwapperView.swift */; }; + FBA00D772EA7C235006F8B9A /* CountView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA00D762EA7C235006F8B9A /* CountView.swift */; }; FBA6FA5E2EA63EA300C373EC /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA6FA5D2EA63EA300C373EC /* Models.swift */; }; FBA6FA602EA66C2E00C373EC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = FBA6FA5F2EA66C2E00C373EC /* Assets.xcassets */; }; FBA6FA622EA76AAD00C373EC /* BikeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FBA6FA612EA76AAD00C373EC /* BikeView.swift */; }; @@ -25,11 +27,13 @@ 0CC14A762E92EC4700271E8D /* TheSwiftWeek.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TheSwiftWeek.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0CC14A842E92EC7A00271E8D /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = ""; }; 0CC14A882E92EEA900271E8D /* Playground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Playground.swift; sourceTree = ""; }; + FB2F07E82EA7CB25002BD499 /* ListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListView.swift; sourceTree = ""; }; FBA00D6C2EA78411006F8B9A /* Localizable.xcstrings */ = {isa = PBXFileReference; lastKnownFileType = text.json.xcstrings; path = Localizable.xcstrings; sourceTree = ""; }; FBA00D6E2EA78850006F8B9A /* Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Color.swift; sourceTree = ""; }; FBA00D702EA7A830006F8B9A /* PaddingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaddingView.swift; sourceTree = ""; }; FBA00D722EA7A96C006F8B9A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; FBA00D742EA7ACDD006F8B9A /* SwapperView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwapperView.swift; sourceTree = ""; }; + FBA00D762EA7C235006F8B9A /* CountView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountView.swift; sourceTree = ""; }; FBA6FA5D2EA63EA300C373EC /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = ""; }; FBA6FA5F2EA66C2E00C373EC /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; FBA6FA612EA76AAD00C373EC /* BikeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BikeView.swift; sourceTree = ""; }; @@ -57,10 +61,12 @@ FBA6FA632EA7715000C373EC /* Extentions.swift */, 0CC14A842E92EC7A00271E8D /* App.swift */, FBA00D722EA7A96C006F8B9A /* ContentView.swift */, + FBA00D762EA7C235006F8B9A /* CountView.swift */, FBA6FA5F2EA66C2E00C373EC /* Assets.xcassets */, 0CC14A882E92EEA900271E8D /* Playground.swift */, FBA6FA612EA76AAD00C373EC /* BikeView.swift */, FBA6FA652EA7725A00C373EC /* TrainView.swift */, + FB2F07E82EA7CB25002BD499 /* ListView.swift */, FBA6FA5D2EA63EA300C373EC /* Models.swift */, FBA00D6C2EA78411006F8B9A /* Localizable.xcstrings */, 0CC14A772E92EC4700271E8D /* Products */, @@ -158,8 +164,10 @@ 0CC14A872E92EC7B00271E8D /* App.swift in Sources */, FBA00D732EA7A96C006F8B9A /* ContentView.swift in Sources */, FBA00D6F2EA78853006F8B9A /* Color.swift in Sources */, + FB2F07E92EA7CB25002BD499 /* ListView.swift in Sources */, FBA00D712EA7A839006F8B9A /* PaddingView.swift in Sources */, FBA6FA622EA76AAD00C373EC /* BikeView.swift in Sources */, + FBA00D772EA7C235006F8B9A /* CountView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate b/TheSwiftWeek.xcodeproj/project.xcworkspace/xcuserdata/rohing73.xcuserdatad/UserInterfaceState.xcuserstate index b3b53cd..8de98bd 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