Skip to content

An high customizable and fast verification code view written in SwiftUI

License

Notifications You must be signed in to change notification settings

posix88/CodeVerifier

Repository files navigation

CodeVerifier

Swift: 5.1 Version: 0.1.0 Platforms: iOS – tvOS – watchOS - macOS License: MIT
SwiftPM: Compatible

Icon

An high customizable and fast verification code view, written in SwiftUI.

CodeVerifier is an open-source fully customizable input view built to makes easier and faster the input of a verification code you provided to your users via mail/phone.

System Requirements

iOS 14.0 or above

Features

✅ Embed a Textfield with semantic intent .oneTimeCode

✅ Full customizable style

✅ Keyboard aware

Next Step

⚠️ Dark Mode support

Installation

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into Xcode.

Once you have your Swift package set up, adding FasterVerificationCode as a dependency is very easy. You've just to add it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/posix88/CodeVerifier")
    ]

or you can simply go to File -> Swift Packages -> Add Package Dependency and paste the repo's url: https://github.com/posix88/CodeVerifier

Examples

Using CodeVerifier is very easy and straightforward. Just create it inside your bodypassing as argument the code to be inserted by the user.

You can customize the appearance of the code verifier during initialization using its modifier and the SecureCodeStyle class.

Basic Implementation

  var body: some View {
        SecureCodeVerifier(code: *your code*)
            .onCodeFilled { isCodeCorrect in
                
            }
    }

Customization

You can create your own style creating a new SecureCodeStyle

  var myStyle: SecureCodeStyle {
        SecureCodeStyle(lineWidth: 20, lineHeight: 2, normalLineColor: .black, errorLineColor: .red, labelWidth: 20, labelHeight: 30, labelSpacing: 15, normalTextColor: .black, errorTextColor: .black, carrierHeight: 30, carrierSpacing: 5, carrierColor: .black)
    }

Inject the new style as key / environment variable, on your view

  SecureCodeVerifier(code: vm.verificationCode)
                .onCodeFilled { isCodeCorrect in
                    print("Hello")
                }
                .environment(\.secureCodeStyle, myStyle)

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Acknowledgements

Made with ❤️ in Milan by Antonino Musolino.

CodeVerifier is a SwiftUI porting of FasterVerificationCode

About

An high customizable and fast verification code view written in SwiftUI

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages