{"id":13536752,"url":"https://github.com/alexpaul/SwiftUI-Landmarks","last_synced_at":"2025-04-02T03:31:04.799Z","repository":{"id":151898692,"uuid":"190131713","full_name":"alexpaul/SwiftUI-Landmarks","owner":"alexpaul","description":"Introducing SwiftUI. A declarative way to create User Interfaces with Swift.","archived":false,"fork":false,"pushed_at":"2019-06-06T05:30:23.000Z","size":2939,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-03T01:33:21.376Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alexpaul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-06-04T04:58:23.000Z","updated_at":"2024-08-15T13:36:20.000Z","dependencies_parsed_at":"2023-06-17T10:30:52.559Z","dependency_job_id":null,"html_url":"https://github.com/alexpaul/SwiftUI-Landmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpaul%2FSwiftUI-Landmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpaul%2FSwiftUI-Landmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpaul%2FSwiftUI-Landmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alexpaul%2FSwiftUI-Landmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alexpaul","download_url":"https://codeload.github.com/alexpaul/SwiftUI-Landmarks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246751011,"owners_count":20827817,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T09:00:48.796Z","updated_at":"2025-04-02T03:31:02.752Z","avatar_url":"https://github.com/alexpaul.png","language":"Swift","funding_links":[],"categories":["Samples","Swift","🌎 by the community"],"sub_categories":[],"readme":"# SwiftUI - Landmarks\n\nIntroducing SwiftUI. A declarative way to create User Interfaces with Swift.\n\nSwiftUI was introduced at WWDC 2019 by Apple. It is their declarative platform for create user interfaces for apps across their platforms. It can be seen as similar to React-Navtive or Flutter without being cross-platform at the moment, hopefully with Swift being open-sourced it can be in the future. With SwiftUI there isn't an existing Storyboard or View Controller present. SwiftUI views are constructed and can be composed of other SwiftUI views. Those views are rendered as code as written automatically via a **Live View** or **Static View** . So far SwiftUI is being heavily pushed by the Apple team and heading into the fall's release of iOS 13 to production SwiftUI will be fully ready for production as well. \n\nSwiftUI is the following: \n- Declarative\n- Automatic \n- Compositional \n- Consistent\n\n\n## Vocabulary\n\n- View protocol   \n- PreviewProvider protocol   \n- Resume  \n- **body** _property_   \n- structured editing popover \n- stacks\n- VStack \n- HStack \n- ZStack\n- Spacer\n- embed views e.g emben in VStack \n- padding \n- UIViewRepresentable - a view that represents a UIKit view \n- static preview (fully renders SwiftUI views)\n- live view (to fully render UIKit views) \n\n## Readings \n\n- [SwiftUI Essentials: Creating and Combining Views](https://developer.apple.com/tutorials/swiftui/creating-and-combining-views)\n\n\n```swift \nstruct ContentView : View {\n    var body: some View {\n        Text(\"Hello San Jose, Welcome to WWDC 2019\")\n    }\n}\n```\n\nFor debugging in preview \n\n```swift \n#if DEBUG\nstruct ContentView_Previews : PreviewProvider {\n    static var previews: some View {\n        ContentView()\n    }\n}\n#endif\n```\n\nCustomizing the Text View \n\n```swift\nstruct ContentView : View {\n    var body: some View {\n        Text(\"Turtle Rock\")\n        .font(.title)\n        .color(.orange)\n    }\n}\n```\n\n## Combine Views using Stacks\n\nThe **body** property only returns a single view. \n\n```swift \nstruct ContentView : View {\n  var body: some View {\n    VStack (alignment: .leading) {\n      Text(\"Turtle Rock\")\n        .font(.title)\n        .color(.green)\n      HStack {\n        Text(\"Joshua Tree National Park\")\n          .font(.subheadline)\n        Spacer()\n        Text(\"California\")\n          .font(.subheadline)\n      }\n    }\n    .padding()\n  }\n}\n```\n\n\n## Create a Custom Image View\n\n```swift\nimport SwiftUI\n\nstruct CircleImage : View {\n    var body: some View {\n        Image(\"turtlerock\")\n          .clipShape(Circle())\n          .overlay(Circle().stroke(Color.white, lineWidth: 4))\n          .shadow(radius: 10)\n    }\n}\n\n#if DEBUG\nstruct CircleImage_Previews : PreviewProvider {\n    static var previews: some View {\n        CircleImage()\n    }\n}\n#endif\n```\n\n## Using UIView and SwiftUI together \n\n```swift \nstruct MapView : View, UIViewRepresentable {\n  func updateUIView(_ view: MKMapView, context: UIViewRepresentableContext\u003cMapView\u003e) {\n    let coordinate = CLLocationCoordinate2D(\n      latitude: 34.011286, longitude: -116.166868)\n    let span = MKCoordinateSpan(latitudeDelta: 2.0, longitudeDelta: 2.0)\n    let region = MKCoordinateRegion(center: coordinate, span: span)\n    view.setRegion(region, animated: true)\n  }\n  \n  func makeUIView(context: Context) -\u003e MKMapView {\n    MKMapView(frame: CGRect.zero)\n  }\n}\n\n#if DEBUG\nstruct MapView_Previews : PreviewProvider {\n    static var previews: some View {\n        MapView()\n    }\n}\n#endif\n```\n\n## Compose the Detail View\n\n```swift \nstruct ContentView : View {\n  var body: some View {\n    VStack {\n      MapView()\n        .edgesIgnoringSafeArea(.top)\n        .frame(height: 300)\n      CircleImage()\n        .offset(y: -130)\n        .padding(.bottom, -130)\n      VStack (alignment: .leading) {\n        Text(\"Turtle Rock\")\n          .font(.title)\n          .color(.green)\n        HStack {\n          Text(\"Joshua Tree National Park\")\n            .font(.subheadline)\n          Spacer()\n          Text(\"California\")\n            .font(.subheadline)\n        }\n      }\n      .padding()\n      \n      Spacer()\n    }\n  }\n}\n\n#if DEBUG\nstruct ContentView_Previews : PreviewProvider {\n  static var previews: some View {\n    ContentView()\n    \n    //ContentView()\n  }\n}\n#endif\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexpaul%2FSwiftUI-Landmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexpaul%2FSwiftUI-Landmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexpaul%2FSwiftUI-Landmarks/lists"}