{"id":23268696,"url":"https://github.com/abcincs/applock","last_synced_at":"2025-04-06T08:46:36.655Z","repository":{"id":104283434,"uuid":"398899878","full_name":"abcincs/AppLock","owner":"abcincs","description":"AppLock is a simple SwiftUI framework that makes it easy to create a PinCode user interface. It provides a struct, AppLockView, that can be shown inside a view or a sheet for better user experience.","archived":false,"fork":false,"pushed_at":"2023-01-12T20:41:22.000Z","size":596,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-12T14:23:02.658Z","etag":null,"topics":["applock","applocker","code","passcode","pin","pincode","spm","swift","swiftui"],"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/abcincs.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":"2021-08-22T20:57:15.000Z","updated_at":"2024-05-11T01:55:53.000Z","dependencies_parsed_at":"2023-03-11T18:00:25.603Z","dependency_job_id":null,"html_url":"https://github.com/abcincs/AppLock","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abcincs%2FAppLock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abcincs%2FAppLock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abcincs%2FAppLock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abcincs%2FAppLock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abcincs","download_url":"https://codeload.github.com/abcincs/AppLock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247457742,"owners_count":20941906,"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":["applock","applocker","code","passcode","pin","pincode","spm","swift","swiftui"],"created_at":"2024-12-19T17:29:00.157Z","updated_at":"2025-04-06T08:46:36.636Z","avatar_url":"https://github.com/abcincs.png","language":"Swift","readme":"# AppLock\n\u003cp align=\"center\" \u003e\n  \u003cimg src=\"https://github.com/ABCIncs/AppLock/blob/main/main.logo.png\" title=\"AppLock logo\" float=left\u003e\n\u003c/p\u003e\n\n\u003cp\u003e\n    \u003cimg src=\"https://img.shields.io/badge/iOS-14.0+-blue.svg\" /\u003e\n    \u003cimg src=\"https://img.shields.io/badge/Swift-5.3-red.svg\" /\u003e\n      \u003cimg src=\"https://img.shields.io/badge/SwiftPM-compatible-brightgreen.svg\" /\u003e\n    \u003ca href=\"https://twitter.com/cedricbahirwe\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Contact-@cedricbahirwe-lightgrey.svg?style=flat\" alt=\"Twitter: @cedricbahirwe\" /\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\nAppLock is a simple SwiftUI framework that makes it easy to create a PinCode user interface. It provides a struct, `AppLockView`, that can be shown inside a view or a sheet for better user experience.\n\n Natively, Apple only provides \u003cb\u003eTouch ID\u003c/b\u003e and \u003cb\u003eFace ID\u003c/b\u003e as authentication mechanisms and only brings \u003cb\u003ePasscode\u003c/b\u003e when authentication with those ones have failed. The goal here was to provide a fully fledged Component that can be customized and reuse with ease.\n\n\n## Usage\n\nYou should create an instance of `AppLockView` with three parameters: the pin to check against, a boolean flag to indicate whether or not you want AppLockView to provide an Error UI, and a closure that will be called when a result is ready. This closure must accept a `Result\u003cBool, UnlockError\u003e`, where the bool is the indicator of a matching that was found on success and `UnlockError` will be either `badPin`.\n\n**Important:** AppLockView *requires* a project with a version greater or equal to `14.0`\n\n\n## Examples\n\nHere's some example code to create an AppLock view that prints when the pin matched code.\n\n```swift\nAppLockView(pincode: .init(\"1975\")) { result  in\n    switch result {\n    case .success(_):\n        print(\"Match pin code\")\n    case .failure(let error):\n        print(error.localizedDescription)\n    }\n}\n```\n\nYour completion closure is probably where you want to dismiss the `AppLockView`.\n\nHere's an example on how to present the AppLockview as a sheet and how we can pass to the next view in a NavigationView when pin code has matched:\n\n```swift\nstruct AppLockExampleView: View {\n    @State var isPresentingLocker = false\n    @State var matchedCode: Bool = false\n\n    var body: some View {\n        NavigationView {\n            VStack(spacing: 10) {\n                if matchedCode {\n                    NavigationLink(\"Next page\", destination: NextView(), isActive: .constant(true)).hidden()\n                }\n                Button(\"Unlock App\") {\n                    self.isPresentingLocker = true\n                }\n                .sheet(isPresented: $isPresentingLocker) {\n                    self.appLockSheet\n                }\n                Text(\"Unlock the app to begin\")\n            }\n\n        }\n    }\n\n    var appLockSheet : some View {\n        AppLockView(\n            pincode: .init(\"2021\"),\n            completion: { result in\n                if case .success(_) = result {\n                    self.matchedCode = true\n                    self.isPresentingLocker = false\n                }\n            }\n        )\n    }\n}\n```\n\n\n## Credits\n\nAppLock was made by [Cédric Bahirwe](https://twitter.com/cedricbahirwe). It’s available under the MIT license, which permits commercial use, modification, distribution, and private use.\n\n\n## License\n\nMIT License.\n\nCopyright (c) 2021 Cédric Bahirwe\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabcincs%2Fapplock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabcincs%2Fapplock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabcincs%2Fapplock/lists"}