Coder Social home page Coder Social logo

passcodeinput's Introduction

SwiftUI PassCode Input

Note: this project is currently under aggressive development, please do not use it in a production application.

This project provides a Two Factor like Pass Code entry widget. It provides a nice user experience where a user can type in a pass code like input (letters or numbers) and provides bindable validation.

Features:

  • Configurable amount of cells
  • Cursor jumps forward as user enters digits
  • Cursor jumps backwards as user clears input
  • Support for user arbitrarily navigating between cells
  • Abstracted data model
  • Built for SwiftUI

Planned Features:

  • Restrict input to nominated character sets
  • Configurable input boxes
  • Group input boxes

Installation

Vendor in the component: If you wish to vendor the library into your project, simply include the following files from a desired release or master:

  • PassCodeModel.swift
  • PassCodeField.swift
  • PassCodeCharField.swift

Swift Package Manager

Running the Demo

Usage

Getting Help

Contact the author of the library directly:

For feature requests and bug reports please use Github issues.

License

PassCode Input is licensed under terms outlined by the MIT License.

passcodeinput's People

Contributors

devraj avatar sangsom avatar willbishop avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

passcodeinput's Issues

Demonstrate working example in NavigationView

Reported Issues:

  • In a secondary pushed in view the app crashes

When prototyped in the app:

  • The model was updating but the cell first responder won't change cells
  • Navigating manually changes the cell index
  • Arbitrarily navigating between cells resets the index to 1

SMS Autofill

Hi,
I want to implement the feature where user receive OTP via text and it Autofills the textfields.
Right now what's happening is I get the OTP via text and it shows up on the NumberPad but when I clicked on it then only first number is filed in textfield.
Could you please suggest something how to achieve autofill the fields just by clicking on received OTP pin ?

Unable to run the project with Xcode Version 15.2 (15C500b)

When I click on the Run button in Xcode, I'm getting the following error message

the Swift tools version specification is missing a label; consider inserting 'swift-tools-version:' between the comment marker and the version specifier

Would you please help? Thank you.

Crashlytics: EXC_BREAKPOINT PassCodeInputCell.updateUIView

I've received a log in my crashlytics console that I have not been able to reproduce. Apparently the app is crashing when executing becomeFirstResponder, have anyone seen this error?.

Here is the full report:

Model: iPhone 11
Orientation: Portrait
RAM free: 370.38 MB
Disk free: 193.53 GB
Version: 13.6.0 (17G68)
Orientation: Portrait
Jailbroken: No

Crashed: com.apple.main-thread
0  SwiftUI                        0x1d847c358 ViewRendererHost.render(interval:updateDisplayList:) + 520
1  SwiftUI                        0x1d85adbd8 _UIHostingView.layoutSubviews() + 164
2  SwiftUI                        0x1d85adc08 @objc _UIHostingView.layoutSubviews() + 28
3  UIKitCore                      0x1a405f2bc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2160
4  QuartzCore                     0x1a66b0978 -[CALayer layoutSublayers] + 292
5  QuartzCore                     0x1a66b0db8 CA::Layer::layout_if_needed(CA::Transaction*) + 472
6  UIKitCore                      0x1a404ac8c -[UIView(Hierarchy) layoutBelowIfNeeded] + 556
7  UIKitCore                      0x1a344de58 -[_UISheetPresentationController _sheetLayoutInfoLayout:] + 52
8  UIKitCore                      0x1a344b510 -[_UISheetLayoutInfo _layout] + 316
9  UIKitCore                      0x1a344ed60 __74-[_UISheetPresentationController _handleKeyboardNotification:aboutToHide:]_block_invoke + 56
10 UIKitCore                      0x1a4051620 +[UIView(Animation) performWithoutAnimation:] + 104
11 UIKitCore                      0x1a344eb38 -[_UISheetPresentationController _handleKeyboardNotification:aboutToHide:] + 148
12 UIKitCore                      0x1a344ef00 -[_UISheetPresentationController _keyboardAboutToShow:] + 180
13 CoreFoundation                 0x19f9bd824 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 28
14 CoreFoundation                 0x19f9bd874 ___CFXRegistrationPost1_block_invoke + 68
15 CoreFoundation                 0x19f9bcb64 _CFXRegistrationPost1 + 396
16 CoreFoundation                 0x19f9bc818 ___CFXNotificationPost_block_invoke + 92
17 CoreFoundation                 0x19f936058 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1420
18 CoreFoundation                 0x19f9bc158 _CFXNotificationPost + 1260
19 Foundation                     0x19fd2fe2c -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
20 UIKitCore                      0x1a3962adc __68-[UIInputWindowController postValidatedStartNotifications:withInfo:]_block_invoke + 1216
21 UIKitCore                      0x1a396260c -[UIInputWindowController postValidatedStartNotifications:withInfo:] + 160
22 UIKitCore                      0x1a3965e88 __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke.907 + 608
23 UIKitCore                      0x1a4052d90 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 552
24 UIKitCore                      0x1a405330c +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delay:options:animations:start:completion:] + 132
25 UIKitCore                      0x1a355e868 -[_UIViewControllerKeyboardAnimationStyle _launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 496
26 UIKitCore                      0x1a40516bc +[UIView(Animation) _performWithAnimation:] + 104
27 UIKitCore                      0x1a355e534 -[_UIViewControllerKeyboardAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 164
28 UIKitCore                      0x1a3965960 -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 1916
29 UIKitCore                      0x1a396aa68 -[UIInputWindowController setInputViewSet:] + 1152
30 UIKitCore                      0x1a3964e1c -[UIInputWindowController performOperations:withAnimationStyle:] + 60
31 UIKitCore                      0x1a366a07c -[UIInputResponderController setKeyWindowSceneInputViews:animationStyle:] + 2192
32 UIKitCore                      0x1a36697c4 -[UIInputResponderController setInputViews:animationStyle:] + 216
33 UIKitCore                      0x1a366a8e0 -[UIInputResponderController setInputViews:animated:] + 100
34 UIKitCore                      0x1a366a950 -[UIInputResponderController setInputViews:] + 80
35 UIKitCore                      0x1a3668428 -[UIInputResponderController _reloadInputViewsForKeyWindowSceneResponder:] + 3152
36 UIKitCore                      0x1a36677b8 -[UIInputResponderController _reloadInputViewsForResponder:] + 164
37 UIKitCore                      0x1a3bc128c -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 132
38 UIKitCore                      0x1a3bbc160 -[UIResponder becomeFirstResponder] + 804
39 UIKitCore                      0x1a404932c -[UIView(Hierarchy) becomeFirstResponder] + 164
40 UIKitCore                      0x1a3e74220 -[UITextField becomeFirstResponder] + 204
41 MyApp                          0x102cc91b4 PassCodeInputCell.updateUIView(_:context:) + 63 (PassCodeInputField.swift:63)
42 MyApp                          0x102cc9a24 protocol witness for UIViewRepresentable.updateUIView(_:context:) in conformance PassCodeInputCell + 4338031140 (<compiler-generated>:4338031140)
43 SwiftUI                        0x1d85758b8 PlatformViewRepresentableAdaptor.updateViewProvider(_:context:) + 388
44 SwiftUI                        0x1d8311d50 closure #1 in closure #1 in PlatformViewChild.update(context:) + 300
45 SwiftUI                        0x1d847bdd8 ViewRendererHost.performExternalUpdate(_:) + 196
46 SwiftUI                        0x1d8311224 perform #1 <A>(work:) in closure #1 in PlatformViewChild.update(context:) + 264
47 SwiftUI                        0x1d8310064 closure #1 in PlatformViewChild.update(context:) + 2772
48 SwiftUI                        0x1d8309dec PlatformViewChild.update(context:) + 664
49 SwiftUI                        0x1d83122ec protocol witness for static UntypedAttribute._update(_:graph:attribute:) in conformance PlatformViewChild<A> + 40
50 AttributeGraph                 0x1cc229274 partial apply + 40
51 AttributeGraph                 0x1cc210ec0 AG::Graph::UpdateStack::update() + 448
52 AttributeGraph                 0x1cc21137c AG::Graph::update_attribute(unsigned int, bool) + 376
53 AttributeGraph                 0x1cc2162e0 AG::Subgraph::update(unsigned int) + 728
54 SwiftUI                        0x1d81cfefc ViewGraph.runTransaction(in:) + 216
55 SwiftUI                        0x1d81d027c closure #1 in ViewGraph.updateOutputs(at:) + 120
56 SwiftUI                        0x1d81cffb8 ViewGraph.updateOutputs(at:) + 128
57 SwiftUI                        0x1d8486674 closure #1 in closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 852
58 SwiftUI                        0x1d8485aa0 closure #1 in ViewRendererHost.render(interval:updateDisplayList:) + 588
59 SwiftUI                        0x1d847c29c ViewRendererHost.render(interval:updateDisplayList:) + 332
60 SwiftUI                        0x1d85adbd8 _UIHostingView.layoutSubviews() + 164
61 SwiftUI                        0x1d85adc08 @objc _UIHostingView.layoutSubviews() + 28
62 UIKitCore                      0x1a405f2bc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2160
63 QuartzCore                     0x1a66b0978 -[CALayer layoutSublayers] + 292
64 QuartzCore                     0x1a66b0db8 CA::Layer::layout_if_needed(CA::Transaction*) + 472
65 QuartzCore                     0x1a66c321c CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 144
66 QuartzCore                     0x1a6607e10 CA::Context::commit_transaction(CA::Transaction*, double) + 304
67 QuartzCore                     0x1a66328c4 CA::Transaction::commit() + 684
68 UIKitCore                      0x1a3bb7f24 _afterCACommitHandler + 144
69 CoreFoundation                 0x19f9e011c __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
70 CoreFoundation                 0x19f9dae4c __CFRunLoopDoObservers + 420
71 CoreFoundation                 0x19f9db2dc __CFRunLoopRun + 1004
72 CoreFoundation                 0x19f9dabc8 CFRunLoopRunSpecific + 480
73 GraphicsServices               0x1a9dbc5cc GSEventRunModal + 164
74 UIKitCore                      0x1a3b8d744 UIApplicationMain + 1936
75 MyApp                          0x102c8dbc4 main + 19 (SomeXViewModel.swift:19)
76 libdyld.dylib                  0x19f857384 start + 4

Replace existing value with already populated input when the user navigates back to the cell

  • User enters a character is navigated to the next cell
  • User presses back space or touches an arbitrary cell to enter text
  • The cell would already have a value in the field and the cell would restrict entry to a single character
  • If the user enters an acceptable character the cell should replace the old character with the new one
  • Note that if the user presses backspace it should function as expected

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.