Git Product home page Git Product logo

vencalculatorinputview's Introduction

VENCalculatorInputView

Build Status

VENCalculatorInputView is the calculator keyboard that is used in the Venmo iOS app. Available for iOS 6 and beyond. Enjoy.

alt text

Installation

The easiest way to get started is to use CocoaPods. Just add the following line to your Podfile:

pod 'VENCalculatorInputView', '~> 1.5'

Sample Usage

You can choose to use just VENCalculatorInputView (only the keyboard) and define your own behavior or use VENCalculatorInputTextField (keyboard + text field with money calculation built in).

Using just the calculator keyboard

1. Set the input view.

Find the UITextField or UITextView that you want to display the keyboard and set its inputView to an instance of VENCalculatorInputView.

myTextField.inputView = [VENCalculatorInputView new];

This will have VENCalculatorInputView display when myTextField becomes firstResponder instead of the system keyboard.

2. Implement the <VENCalculatorInputViewDelegate> methods.

First, have a class implement the <VENCalculatorInputViewDelegate> protocol and set myTextField.inputView.delegate to an instance of that class.

Next, implement the delegate method that handles keyboard input:

- (void)calculatorInputView:(VENCalculatorInputView *)inputView didTapKey:(NSString *)key {
    NSLog(@"Just tapped key: %@", key);
    // Handle the input. Something like [myTextField insertText:key];
}

Finally, implement the delegate method that handles the backspace key:

- (void)calculatorInputViewDidTapBackspace:(VENCalculatorInputView *)calculatorInputView {
    NSLog(@"Just tapped backspace.");
    // Handle the backspace. Something like [myTextField deleteBackward];
}

Try it!

You can read more about custom keyboards in Apple’s documentation.

Using the calculator text field (optimized for money calculation)

All you need to do is use VENCalculatorInputTextField instead of UITextField and use it like normal text field. It will automagically handle the input and make calculations. Take a look at out our VENCalculatorInputViewSample project.

Localization

Different regions use different symbols as their decimal separator (e.g. ., ,). By default, VENCalculatorInputView and VENCalculatorInputTextField use the current locale of the device. You can change it by setting the locale property.

Testing

We’ve written some tests. You can run them by opening the project in Xcode and hitting Command-U.

Contributing

We’d love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. We’ll do our best to respond to your patch as soon as possible. You can also submit a new GitHub issue if you find bugs or have questions. :octocat:

Please make sure to follow our general coding style and add test coverage for new features!

vencalculatorinputview's People

Contributors

aquarhead avatar ayanonagon avatar dasmer avatar dlackty avatar hyperspacemark avatar marklarr avatar mickeyreiss avatar neil477 avatar xhacker avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

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.