0.5.2 • Published 5 years ago

react-native-calculator v0.5.2

Weekly downloads
117
License
MIT
Repository
github
Last release
5 years ago

React Native Calculator

npm version build status

Simple react native calculator and calculator input component.

Installation

Using npm:

npm i -S react-native-calculator

or yarn:

yarn add react-native-calculator

Demo

Calculator Component

Usage

import React from 'react'
import { View } from 'react-native'
import { Calculator } from 'react-native-calculator'

export default class App extends React.Component {
  render() {
    return (
      <View style={{ flex: 1 }}>
        <Calculator style={{ flex: 1 }} />
      </View>
    )
  }
}

Props

All props in common props and...

Prop NameData TypeDefault ValueDescription
hasAcceptButtonbooleanfalseShow accept button after calculate.
styleViewStyleContainer style.
onCalc(value : number , text : string ) => voidCalculate button click event.
onAccept(value : number , text : string ) => voidAccept button click event.
hideDisplaybooleanfalseHide display text field.

Calculator Input Component

Usage

import React from 'react'
import { View } from 'react-native'
import { CalculatorInput } from 'react-native-calculator'

export default class App extends React.Component {
  render() {
    return (
      <View>
        <CalculatorInput
          fieldTextStyle={{ fontSize: 24 }}
          fieldContainerStyle={{ height: 36 }}
        />
      </View>
    )
  }
}

Props

All props in common props and...

Prop NameData TypeDefault ValueDescription
modalAnimationType'none''slide''fade'slideModal animation type.
modalBackdropStyleViewStyleStyle of modal backdrop.
fieldContainerStyleViewStyleText field container style.
fieldTextStyleTextStyleText style.
onChange(value : number , text : string ) => voidValue change event.
prefixstringPrefix.
suffixstringSuffix.
onBeforeChange(value : number , text : string ) => booleanCalled before changes applied. Return true if changes are accepted.
onBeforeChangeAsync(value : number , text : string ) => Promise<boolean>Called asynchronously before changes applied. Resolve with true if changes are accepted.

Common Props

Prop NameData TypeDefault ValueDescription
decimalSeparatorstring.Decimal separator sign.
thousandSeparatorstring,Thousand separator sign.
numericButtonBackgroundColorstring#ffffffNumeric button background color.
numericButtonColorstring#aaaaaaNumeric text button color.
actionButtonBackgroundColorstring#e7e5e3Action button background color.
actionButtonColorstring#000000Action text button color.
calcButtonBackgroundColorstring#ff8d00Calculate button background color.
calcButtonColorstring#ffffffCalculator text button color.
acceptButtonBackgroundColorstring#14CC60Accept button background color.
acceptButtonColorstring#ffffffAccept text button color.
displayBackgroundColorstring#ffffffDigit display background color.
displayColorstring#000000Digit display text color.
borderColorstring#52525BBorder color.
fontSizenumber18Button text font size.
valuenumber0Initial value.
widthnumber(auto)Calculator component width.
heightnumber(auto)Calculator component height.
displayHeightnumber(auto)Digit display container height.
keyboardHeightnumber(auto)Keyboard container height.
onTextChange(text: string) => voidText change event.
displayTextAlign"auto" / "left" / "right" / "center" / "justify""left"Digit align display.
noDecimalbooleanfalseHide decimal separator button to disable decimal value.
roundTonumber2How many decimal places to round the value

License

MIT

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.0

5 years ago

0.3.0

6 years ago

0.2.4

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago