Skip to content

Commit

Permalink
Extends InputCurrency & InputNumber component props
Browse files Browse the repository at this point in the history
  • Loading branch information
budiadiono committed Sep 25, 2018
1 parent 3b50137 commit ce9ed3c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"homepage": "https://github.com/dokuhero/react-native-components#readme",
"dependencies": {
"react-native-calculator": "^0.2.2",
"react-native-calculator": "^0.2.4",
"react-native-custom-picker": "^0.3.1",
"react-native-elements": "^0.19.1",
"react-native-super-grid": "^2.4.3",
Expand Down
20 changes: 16 additions & 4 deletions src/components/InputCurrency.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { withTheme } from '@dokuhero/react-native-theme'
import React from 'react'
import { CalculatorInput } from 'react-native-calculator'
import { CalculatorInput, CalculatorInputProps } from 'react-native-calculator'
import { globalStyles } from '../styles'
import { FormField, FormFieldProps } from './FormField'

export interface InputCurrencyProps extends FormFieldProps {
export interface InputCurrencyProps
extends FormFieldProps,
CalculatorInputProps {
currency?: string
value: number
onChange: (value: number) => void
}

export const InputCurrency = withTheme<InputCurrencyProps>(
({ currency, value, label, errors, onChange, theme }) => (
({
currency,
value,
label,
errors,
onChange,
theme,
fieldTextStyle,
...rest
}) => (
<FormField label={label} errors={errors}>
<CalculatorInput
value={value}
Expand All @@ -20,7 +31,7 @@ export const InputCurrency = withTheme<InputCurrencyProps>(
paddingBottom: 7,
borderBottomColor: theme.color.lighter
}}
fieldTextStyle={globalStyles.inputText}
fieldTextStyle={[globalStyles.inputText, fieldTextStyle]}
borderColor={theme.color.lighter}
acceptButtonBackgroundColor={theme.color.primary}
calcButtonBackgroundColor={theme.color.secondary}
Expand All @@ -31,6 +42,7 @@ export const InputCurrency = withTheme<InputCurrencyProps>(
}
}}
height={300}
{...rest}
/>
</FormField>
)
Expand Down
9 changes: 5 additions & 4 deletions src/components/InputNumber.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { withTheme } from '@dokuhero/react-native-theme'
import React from 'react'
import { CalculatorInput } from 'react-native-calculator'
import { CalculatorInput, CalculatorInputProps } from 'react-native-calculator'
import { globalStyles } from '../styles'
import { FormField, FormFieldProps } from './FormField'

export interface InputNumberProps extends FormFieldProps {
export interface InputNumberProps extends FormFieldProps, CalculatorInputProps {
value: number
onChange: (value: number) => void
}

export const InputNumber = withTheme<InputNumberProps>(
({ value, label, errors, onChange, theme }) => (
({ value, label, errors, onChange, theme, fieldTextStyle, ...rest }) => (
<FormField label={label} errors={errors}>
<CalculatorInput
value={value}
Expand All @@ -19,7 +19,7 @@ export const InputNumber = withTheme<InputNumberProps>(
paddingBottom: 7,
borderBottomColor: theme.color.lighter
}}
fieldTextStyle={globalStyles.inputText}
fieldTextStyle={[globalStyles.inputText, fieldTextStyle]}
borderColor={theme.color.lighter}
acceptButtonBackgroundColor={theme.color.primary}
calcButtonBackgroundColor={theme.color.secondary}
Expand All @@ -29,6 +29,7 @@ export const InputNumber = withTheme<InputNumberProps>(
}
}}
height={300}
{...rest}
/>
</FormField>
)
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3617,9 +3617,9 @@ react-native-branch@2.2.5:
version "2.2.5"
resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-2.2.5.tgz#4074dd63b4973e6397d9ce50e97b57c77a518e9d"

react-native-calculator@^0.2.2:
version "0.2.2"
resolved "https://registry.yarnpkg.com/react-native-calculator/-/react-native-calculator-0.2.2.tgz#ab3b9bcca934cae090ca859a1f6b79a2414d29aa"
react-native-calculator@^0.2.4:
version "0.2.4"
resolved "https://registry.yarnpkg.com/react-native-calculator/-/react-native-calculator-0.2.4.tgz#b0c9bc1fa1324d96e25d4636605948958ac8be44"

react-native-custom-picker@^0.3.1:
version "0.3.1"
Expand Down

0 comments on commit ce9ed3c

Please sign in to comment.