{"id":15055333,"url":"https://github.com/p-x9/editvalueview","last_synced_at":"2025-04-10T03:36:48.884Z","repository":{"id":61928800,"uuid":"553739672","full_name":"p-x9/EditValueView","owner":"p-x9","description":"Library that makes easy to display property edit screens for SwiftUI.","archived":false,"fork":false,"pushed_at":"2024-03-31T16:19:57.000Z","size":141,"stargazers_count":15,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T13:17:33.143Z","etag":null,"topics":["edit","swift-package-manager","swiftui"],"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/p-x9.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,"dei":null}},"created_at":"2022-10-18T17:34:12.000Z","updated_at":"2024-11-02T09:25:47.000Z","dependencies_parsed_at":"2024-02-08T15:52:45.324Z","dependency_job_id":"d29c3929-8782-46e9-8ebe-6860be1e1e07","html_url":"https://github.com/p-x9/EditValueView","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FEditValueView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FEditValueView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FEditValueView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-x9%2FEditValueView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p-x9","download_url":"https://codeload.github.com/p-x9/EditValueView/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248153617,"owners_count":21056470,"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":["edit","swift-package-manager","swiftui"],"created_at":"2024-09-24T21:40:57.015Z","updated_at":"2025-04-10T03:36:48.855Z","avatar_url":"https://github.com/p-x9.png","language":"Swift","readme":"# EditValueView\n\nLibrary that makes easy to display property edit screens for SwiftUI.\n\n## Demo\n\n|  String  |  Bool  |  Int  |\n| ---- | ---- | ---- |\n|  ![String-light](https://user-images.githubusercontent.com/50244599/197402681-7e3c4ec8-f7c3-4ad7-9e31-8e3cd270342f.png)  |  ![Bool-light](https://user-images.githubusercontent.com/50244599/197402668-973d18c4-9f87-4f2f-9e6c-77072b4a8db6.png)  |  ![Int-light](https://user-images.githubusercontent.com/50244599/197402680-eb91f16f-52db-441a-b923-706889c256f8.png)  |\n\n|  Double  |  Date  |  Color  |\n| ---- | ---- | ---- |\n|  ![Double-light](https://user-images.githubusercontent.com/50244599/197402677-cb2a90ca-58fa-4d2d-8459-fa2539836c36.png) |  ![Date-light](https://user-images.githubusercontent.com/50244599/197402673-414f5b2d-9031-4ad3-81de-300d85e5ad56.png)  |  ![Color-light](https://user-images.githubusercontent.com/50244599/197402671-8a224878-ab39-4471-b072-cbb19a2d38b9.png)  |\n\n|  Image  |  UI/NSImage  |\n| ---- | ---- |\n|  ![Image-light](https://github.com/p-x9/EditValueView/assets/50244599/792faddd-96c8-476c-8d9f-1b8c250972ee)  |  ![UIImage-light](https://github.com/p-x9/EditValueView/assets/50244599/e6f2a27f-5d8f-4aca-a7fd-cfe6a8c1a952)  |\n\n|  Array  |  Dictionary  |\n| ---- | ---- |\n|  ![Array-light](https://user-images.githubusercontent.com/50244599/197402664-fce3326c-824d-4853-9a5b-47903ccdf470.png)  |  ![Dictionary-light](https://user-images.githubusercontent.com/50244599/197402675-d1dd4bdb-6135-4c45-89f9-2f640daf9f3d.png)  |\n\n|  Enum(CaseIterable)  |  Enum(CaseIterable \u0026 RawRepresentable)  |\n| ---- | ---- |\n|  ![Enum(CaseIterable)-light](https://user-images.githubusercontent.com/50244599/197402679-c6be841f-02ca-4db6-81ba-5e5e4893058d.png)  |  ![Enum(CaseIterable   RawRepresentable)-light](https://user-images.githubusercontent.com/50244599/197402678-dc8547ec-add7-436c-8cba-44d950f0d676.png)  |\n\n|  Codable  |\n|  ----  |\n|  ![Codable-light](https://user-images.githubusercontent.com/50244599/197402669-5fe684df-cbbe-4945-b89e-264e00fed733.png)  |\n\n## Supported types\n- String\n- Bool\n- any Numerics\n- Date\n- Color/UIColor/NSColor/CGColor/CIColor\n- Image/UIImage/CGImage/CIImage (iOS Only)\n- Array(Codable)\n- Dictionary(Codable)\n- CaseIterable\n- CaseIterable \u0026 RawRepresentable\n- Codable\n\n## Usage\n\u003e **Note**\n\u003e If you want to use the camera for editing images, you must add a key named `NSCameraUsageDescription` to the info.plist file.\n\n### SwiftUI\n#### Initialize\n- Initialize with key and initial value\n  ```swift\n  var name = \"\"\n  EditValueView(key: \"name\", value: name)\n    .onUpdate { newValue in\n        name = newValue\n    }\n  ```\n- Initialize with keyPath\n  ```swift\n  EditValueView(target, key: \"name\", keyPath: \\Item.name)\n    .onUpdate { newValue in\n        target[keyPath: \\.name] = newValue\n    }\n  ```\n- Initialize with binding\n  ```swift\n  @State var name: String = \"\"\n  EditValueView(key: \"name\", binding: $name)\n  ```\n\n#### Update Handler\nYou can receive an edit callback when you press the `save` button.\n```swift\nEditValueView(target, key: \"name\", keyPath: \\Item.name)\n    .onUpdate { newValue in\n        // update\n    }\n```\n\n#### Input Validation\nYou can validate input values.\n```swift\nEditValueView(target, key: \"name\", keyPath: \\Item.name)\n    .validate { newValue -\u003e Bool in\n        // input validation\n        return !name.isEmpty\n    }\n```\n\n### UIKit\n```swift\nlet vc = EditValueViewController(target, key: \"name\", keyPath: \\Item.name)\nvc.onUpdate = { target, newValue in\n    // update\n}\nvc.validate = { target, newValue -\u003e Bool in\n    // input validation\n}\n```\n\n### Protocol\nWhen using optional types, type hints for Codable cannot be displayed when nil is used.\nTo avoid such problems, provide a default value in accordance with the protocol named `DefaultRepresentable`.\n\n```swift\nstruct Item: Codable {\n    var name: String\n    var date: Date\n}\n\nstruct Message: Codable {\n    var content: String\n    var item: Item?\n}\n```\n```swift\n// Confirm to `DefaultRepresentable` protocol\nextension Item: DefaultRepresentable {\n    static var defaultValue: Self {\n        .init(name: \"name\", date: Date())\n     }\n}\n```\n```swift\n// give default value\nEditValueView(target, key: \"item\", keyPath: \\Message.item, defaultValue: .init(name: \"name\", date: Date()))\n```\n\n## License\nEditValueView is released under the MIT License. See [LICENSE](./LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-x9%2Feditvalueview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp-x9%2Feditvalueview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-x9%2Feditvalueview/lists"}