Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/divadretlaw/passcodekit
🔐 Easily add a passcode to your iOS app
https://github.com/divadretlaw/passcodekit
passcode passcode-authentication passcodelock swift swiftui ui-components
Last synced: 3 months ago
JSON representation
🔐 Easily add a passcode to your iOS app
- Host: GitHub
- URL: https://github.com/divadretlaw/passcodekit
- Owner: divadretlaw
- License: mit
- Created: 2023-08-13T08:58:04.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-14T11:10:29.000Z (10 months ago)
- Last Synced: 2024-10-03T07:32:00.534Z (4 months ago)
- Topics: passcode, passcode-authentication, passcodelock, swift, swiftui, ui-components
- Language: Swift
- Homepage:
- Size: 203 KB
- Stars: 7
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PasscodeKit
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdivadretlaw%2FPasscodeKit%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/divadretlaw/PasscodeKit)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fdivadretlaw%2FPasscodeKit%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/divadretlaw/PasscodeKit)Easily add a passcode to your iOS app
## Usage
PasscodeKit is split into two modules and depending on what you need you can use the main or core module.
### PasscodeKit
The default module, with UI and handling already setup. Simply add `.passcode(title:hint:)`, with an optional title and hint view, to your root view.
```swift
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.passcode("Enter Passcode") {
// Optional view as a hint above the code view
}
}
}
}
```The passcode has to be setup by the user in order to be used, you can add this modifier to any view to start the setup.
```swift
.setupPasscode(isPresented: $setupPasscode, type: .numeric(6))
```To remove the passcode again, use the environment variables to access the . You can also set the manager environment variable to override the used Keychain instance and key where the key that is used to store the data.
```swift
@Environment(\.passcode.manager) private var passcodeManager
```Then simply remove the entry for the passcode
```swift
passcodeManager.delete()
```### PasscodeCore
The core module, that handles displaying the passcode window. By default it has no UI to enter a passcode or setting up and storing the passcode, but you can use this as a base to implement your own UI.
```swift
.passcode(mode: PasscodeMode) { dismiss in
// some Passcode input UI, call `dismiss(animated:)` once finished
} background: {
// some optional background view
}
```#### Localization
Customize / Localize the `PasscodeKit` by providing a `Passcode.strings` file in your main app bundle. See the default [Passcode.strings](Sources/PasscodeKit/Resources/Passcode.strings) file for English Strings.
## Installation
### Xcode
Add the following package URL to Xcode
```
https://github.com/divadretlaw/PasscodeKit
```Select the module you need
![Xcode](https://github.com/divadretlaw/PasscodeKit/assets/6899256/081ca701-deb1-4230-9e8e-25d9fe24e803)
### Swift Package Manager
```swift
let package = Package(
dependencies: [
.package(url: "https://github.com/divadretlaw/PasscodeKit.git", from: "0.7.0")
],
targets: [
.target(
name: <#Target Name#>,
dependencies: [
.product(name: "PasscodeKit", package: "PasscodeKit")
]
)
]
)
```## License
See [LICENSE](LICENSE)