{"id":20462343,"url":"https://github.com/pearmini/learning-ios","last_synced_at":"2025-03-05T11:45:21.136Z","repository":{"id":260833126,"uuid":"882462421","full_name":"pearmini/learning-ios","owner":"pearmini","description":"My notes, examples, and experiments with IOS development.","archived":false,"fork":false,"pushed_at":"2024-11-26T20:53:09.000Z","size":223,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T00:51:04.946Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pearmini.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-02T20:52:16.000Z","updated_at":"2024-11-26T20:53:13.000Z","dependencies_parsed_at":"2024-11-02T22:25:21.232Z","dependency_job_id":"304962be-33ed-42ff-9cf7-2b878754919b","html_url":"https://github.com/pearmini/learning-ios","commit_stats":null,"previous_names":["pearmini/learning-ios"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearmini%2Flearning-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearmini%2Flearning-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearmini%2Flearning-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pearmini%2Flearning-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pearmini","download_url":"https://codeload.github.com/pearmini/learning-ios/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242023209,"owners_count":20059297,"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-11-15T12:35:28.208Z","updated_at":"2025-03-05T11:45:21.087Z","avatar_url":"https://github.com/pearmini.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learning IOS\n\nThis is my code, notes and blogs for learning IOS development. The tutorial is the official [tutorial](https://developer.apple.com/tutorials/app-dev-training/getting-started-with-scrumdinger).\n\n## Bindings (2024/11/23)\n\n- If the child view can both read and modify the property that you defined as the source of truth, you should define it as @Bindings.\n\n- If the child view has a read-only relationship with the source of truth defined in the parent, you can simply pass the value to the child view.\n\n```swift\n\nimport SwiftUI\n\n\nstruct EditView: View {\n  // the source of truth\n  @State private var scrum: DailyScrum\n\n  // a read-only relationship\n  let name: String = \"Theme\"\n\n  var body: some View {\n    ThemePicker(selection: $scrum.theme, name: name)\n  }\n}\n\nstruct ThemePicker: View {\n  @Binding var selection: Theme\n  let name: String\n\n  var body: some View {\n    Picker(name, selection: $selection) {\n      ForEach(Theme.allCases) { theme in\n        ThemeView(theme: theme)\n          .tag(theme)\n      }\n    }\n    .pickerStyle(.navigationLink)\n  }\n}\n```\n\n- For React, parent component should pass both the value and setter to the child component for two-way connection.\n- For Vue, parent component should listen to the update event emitted by the child component.\n\n## States (2024/11/17)\n\n- Adding a sheet modifier on _List_ will present the specified view using a modal sheet that partially covers the underlying content. This is useful for short, self-contained tasks.\n\n```swift\nList {}\n  .sheet(isPresented: $isPresented) {\n    TextView(\"hello World\")\n  }\n```\n\n- _@State_ to define a state in the view:\n\n```swift\nstruct TextView: View {\n  @State private var name = \"\"\n  var body: some View {\n     TextField(\"Your Name\", text: $name)\n  }\n}\n```\n\n## Navigation (2024/11/07)\n\n- _NavigationStack_, _NavigationLink_ are for navigation between views.\n- $0 referred to index for mapping array: _attendees.map { Attendee(name: $0) }_\n- A strut can be extended multiple time, which is similar to Rust:\n\n```swift\nstruct A {\n\n}\n\nextension A {\n  // ...\n}\n\nextension A {\n // ...\n}\n```\n\n- Within a _List view_, use _ForEach view_:\n\n```swift\nList {\n  ForEach(scrum.attendees) { attendee in\n    Label(attendee.name, systemImage: \"person\")\n  }\n}\n```\n\n- Declare a constant with _let_, while declare a variable with _var_\n\n## Views (2024/11/02)\n\n- Views are the basic building blocks of Swift UI, just like components in React.js.\n- A View contains two structures: the first one is for defining the UI, and the second one is for previewing with mock data.\n- Props are defined by `let a` and passed by `View(a: 1)`\n- Views are sort of like functions when describing the UI:\n\nUsing curly brackets for hierarchy:\n\n```swift\nView {\n  HStack {\n\n  }\n}\n```\n\nThere seems to be two different places for pass props. What's the difference?\n\n```swift\nView {\n  Text(scrum.title) // Props\n    .font(.headline) // Props\n    .accessibilityAddTraits(.isHeader)\n}\n```\n\n- `\\(datum)` is for interpolate data:\n\n```swift\nLabel(\"\\(scrum.attendees.count)\", systemImage: \"person.3\")\n```\n\n- `List` view is for list rendering:\n\n```swift\nList(data, \\.id) { datum in\n  View(datum: datum)\n}\n```\n\nIf datum is `Identifiable`, there is no need to specify id parameter.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpearmini%2Flearning-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpearmini%2Flearning-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpearmini%2Flearning-ios/lists"}