{"id":47,"date":"2022-04-09T00:30:23","date_gmt":"2022-04-09T00:30:23","guid":{"rendered":"https:\/\/www.bigbo.at\/?p=47"},"modified":"2022-04-09T00:31:00","modified_gmt":"2022-04-09T00:31:00","slug":"day-19-challenge-day","status":"publish","type":"post","link":"https:\/\/www.bigbo.at\/?p=47","title":{"rendered":"Day 19 &#8211; Challenge Day"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Days 14 &#8211; 18 we covered a few more Swift fundamentals before getting a first look at SwiftUI.  In Day 16, we saw our first SwiftUI project, a utility to split a restaurant bill.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Today, I completed the <a href=\"https:\/\/www.hackingwithswift.com\/100\/swiftui\/19\">Day 19 Challenge<\/a>.  This was my first ever SwiftUI project and I designed it myself.  Getting the UI laid out was no big deal, it was very similar to the WeSplit project.  I broke it into three sections with a TextField, a couple Pickers, and a Text view.  Referring back to the WeSplit project meant it was trivial to get the UI set the way I wanted it.  I did have to resort to the &#8220;Tips&#8221; section of the challenge for some ideas on how to handle the actual conversions.  Below is the main body View and I&#8217;m purposely not including the code for the finalValue computed property.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"swift\" class=\"language-swift\">var body: some View {\n        NavigationView{\n            Form{\n                Section{\n                    TextField(\"Text\", value:$valueToConvert, format:.number)\n                        .keyboardType(.decimalPad)\n                        .focused($keyboardFocus)\n                    \n                } header:{\n                    Text(\"Enter a value to convert\")\n                }\n                Section{\n                    Picker(\"Starting Units\", selection: $initialUnits){\n                        ForEach(listOfUnits, id: \\.self){\n                            Text(\"\\($0)\")\n                        }\n                    }\n                    Picker(\"Ending Units\", selection: $finalUnits){\n                        ForEach(listOfUnits, id: \\.self){\n                            Text(\"\\($0)\")\n                        }\n                    }\n                } header:{\n                    Text(\"Enter Units\")\n                }\n                Section{\n                    Text(finalValue, format:.number)\n                } header:{\n                    Text(\"Converted Value\")\n                }\n            }\n            .navigationTitle(\"Let's Convert\")\n            .toolbar{\n                ToolbarItemGroup(placement: .keyboard){\n                    Spacer()\n                    Button(\"Done\"){\n                        keyboardFocus = false\n                    }\n                }\n            }\n        }\n    }<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Days 14 &#8211; 18 we covered a few more Swift fundamentals before getting a first look at SwiftUI. In Day 16, we saw our first SwiftUI project, a utility to split a restaurant bill. Today, I completed the Day 19 Challenge. This was my first ever SwiftUI project and I<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[5,7,6],"class_list":["post-47","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-100daysofswiftui","tag-code","tag-hackingwithswift"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bigbo.at\/index.php?rest_route=\/wp\/v2\/posts\/47","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bigbo.at\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bigbo.at\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bigbo.at\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bigbo.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=47"}],"version-history":[{"count":2,"href":"https:\/\/www.bigbo.at\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":49,"href":"https:\/\/www.bigbo.at\/index.php?rest_route=\/wp\/v2\/posts\/47\/revisions\/49"}],"wp:attachment":[{"href":"https:\/\/www.bigbo.at\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bigbo.at\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bigbo.at\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}