{"id":25457951,"url":"https://github.com/cuadros-code/project-8-swiftui-moonshot","last_synced_at":"2025-11-02T13:30:27.165Z","repository":{"id":262542061,"uuid":"885574442","full_name":"cuadros-code/Project-8-SwiftUI-moonshot","owner":"cuadros-code","description":"MoonShot project","archived":false,"fork":false,"pushed_at":"2024-12-05T20:01:22.000Z","size":54803,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-05T21:18:18.227Z","etag":null,"topics":["dateformatter","extension","generics","griditem","lazyvgrid","lazyvstack","navigationlink"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cuadros-code.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-08T21:24:56.000Z","updated_at":"2024-12-05T20:01:27.000Z","dependencies_parsed_at":"2024-11-18T09:30:49.428Z","dependency_job_id":null,"html_url":"https://github.com/cuadros-code/Project-8-SwiftUI-moonshot","commit_stats":null,"previous_names":["cuadros-code/project-8-swiftui-moonshot"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuadros-code%2FProject-8-SwiftUI-moonshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuadros-code%2FProject-8-SwiftUI-moonshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuadros-code%2FProject-8-SwiftUI-moonshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cuadros-code%2FProject-8-SwiftUI-moonshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cuadros-code","download_url":"https://codeload.github.com/cuadros-code/Project-8-SwiftUI-moonshot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239394661,"owners_count":19631122,"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":["dateformatter","extension","generics","griditem","lazyvgrid","lazyvstack","navigationlink"],"created_at":"2025-02-18T02:19:34.596Z","updated_at":"2025-11-02T13:30:27.118Z","avatar_url":"https://github.com/cuadros-code.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Moonshot\n\n- LazyVStack \n- NavigationLink\n- LazyVGrid\n- GridItem\n- Generics\n- extension\n- DateFormatter\n\n### Resizing images to fit the available space \n\n```swift\nImage(.colombia)\n    .resizable()\n    .scaledToFit()\n    .containerRelativeFrame(.horizontal) { size, axis in\n        size * 0.8\n    }\n```\n---\n\n### How ScrollView lets us work with scrolling data\n\n\n```swift\nimport SwiftUI\n\nstruct CustomText: View {\n    let text: String\n    \n    var body: some View {\n        Text(text)\n    }\n    \n    init(text: String) {\n        print(\"Creating a CustomText\")\n        self.text = text\n    }\n}\n\nstruct ContentView: View {\n    var body: some View {\n        ScrollView {\n            LazyVStack(spacing: 10) {\n                ForEach(0..\u003c100) {\n                    CustomText( text: \"Item \\($0)\")\n                        .font(.title)\n                }\n            }\n            .frame(maxWidth: .infinity)\n        }\n    }\n}\n```\n---\n\n### Pushing new views onto the stack using NavigationLink\n\n```swift\nimport SwiftUI\n\nstruct ContentView: View {\n    var body: some View {\n        NavigationStack {\n            List(0..\u003c10) { row in\n                NavigationLink(\"Row \\(row)\") {\n                    Text(\"Detail \\(row)\")\n                }\n            }\n            \n            NavigationLink {\n                Text(\"Detail View\")\n            } label: {\n                VStack {\n                    Text(\"This is a label\")\n                    Text(\"So is this\")\n                    Image(systemName: \"face.smiling\")\n                }\n            }\n            \n            .navigationTitle(\"SwiftUI\")\n        }\n    }\n}\n```\n---\n\n### Working with hierarchical Codable data\n\n```swift \nimport SwiftUI\n\nstruct User: Codable {\n    let name: String\n    let address: Address\n}\n\nstruct Address: Codable {\n    let street: String\n    let city: String\n}\n\nstruct ContentView: View {\n    var body: some View {\n        Button(\"Decode JSON\") {\n            let input = \"\"\"\n                {\n                    \"name\": \"Taylor Swift\",\n                    \"address\": {\n                        \"street\": \"555, Taylor Swift Avenue\",\n                        \"city\": \"Nashville\"\n                    }\n                }\n                \"\"\"\n            \n            let data = Data(input.utf8)\n            \n            if let user = try? JSONDecoder().decode(User.self, from: data) {\n                print(user.address.street)\n            }\n        }\n    }\n}\n```\n---\n\n### How to lay out views in a scrolling grid\n\n```swift\nimport SwiftUI\n\n\nstruct ContentView: View {\n    let layout = [\n        GridItem(.adaptive(minimum: 80, maximum: 120))\n//        GridItem(.fixed(80)),\n//        GridItem(.fixed(80)),\n//        GridItem(.fixed(80)),\n    ]\n    \n    var body: some View {\n        ScrollView {\n            LazyVGrid(columns: layout) {\n                ForEach(0..\u003c1000) {\n                    Text(\"Item \\($0)\")\n                }\n            }\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuadros-code%2Fproject-8-swiftui-moonshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuadros-code%2Fproject-8-swiftui-moonshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuadros-code%2Fproject-8-swiftui-moonshot/lists"}