Skip to content

Commit

Permalink
inputText global styles
Browse files Browse the repository at this point in the history
  • Loading branch information
budiadiono committed Sep 21, 2018
1 parent b5b040f commit dba63a6
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/components/Busy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const styles = createStyleSheet({
textAlign: 'center',
marginTop: 10,
color: ColorKeys.white,
fontStyle: FontSizesKeys.medium,
fontSize: FontSizesKeys.medium,
fontFamily: FontNameKeys.regular
}
})
5 changes: 2 additions & 3 deletions src/components/CheckBox.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { withTheme } from '@dokuhero/react-native-theme'
import React from 'react'
import { CheckBox as RNCheckBox, CheckBoxProps } from 'react-native-elements'
import { globalStyles } from '../styles'

export const CheckBox = withTheme<CheckBoxProps>(({ theme, ...rest }) => {
return (
Expand All @@ -9,9 +10,7 @@ export const CheckBox = withTheme<CheckBoxProps>(({ theme, ...rest }) => {
borderWidth: 0,
backgroundColor: theme.color.transparent
}}
textStyle={{
fontWeight: 'normal'
}}
textStyle={globalStyles.inputText}
{...rest}
/>
)
Expand Down
12 changes: 9 additions & 3 deletions src/components/DropdownPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from 'react'
import { StyleProp, TextStyle, ViewStyle } from 'react-native'
import { CustomPicker } from 'react-native-custom-picker'
import { Icon, IconObject, ListItem } from 'react-native-elements'
import { globalStyles } from '../styles'
import { Utils } from '../utils'
import { ItemIdentity, ItemIdentityAvatar } from './ItemIdentity'

Expand Down Expand Up @@ -137,20 +138,25 @@ export function DropdownPicker<T>(props: DropdownPickerProps<T>) {
fieldTpl(
item,
optionContainerStyle,
[{ fontFamily: theme.fontName.regular }, optionTextStyle],
[globalStyles.inputText, optionTextStyle],
undefined,
smMargin
)
}
fieldTemplate={({ selectedItem, defaultText, clear }) => {
return selectedItem !== null && selectedItem !== undefined ? (
fieldTpl(selectedItem, fieldContainerStyle, fieldTextStyle, clear)
fieldTpl(
selectedItem,
fieldContainerStyle,
[globalStyles.inputText, fieldTextStyle],
clear
)
) : (
<ListItem
title={defaultText}
titleStyle={[
globalStyles.inputText,
{
fontFamily: theme.fontName.regular,
color: theme.color.lighter,
marginLeft: 0,
marginRight: 0
Expand Down
4 changes: 2 additions & 2 deletions src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export const Input = withTheme<InputProps & FormFieldProps>(
{
paddingHorizontal: 5,
color: theme.color.darker,
width: '100%',
fontFamily: theme.fontName.regular
width: '100%'
},
globalStyles.inputText,
inputStyle
]}
containerStyle={[globalStyles.container, rest.containerStyle]}
Expand Down
3 changes: 2 additions & 1 deletion src/components/InputCurrency.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { withTheme } from '@dokuhero/react-native-theme'
import React from 'react'
import { CalculatorInput } from 'react-native-calculator'
import { globalStyles } from '../styles'
import { FormField, FormFieldProps } from './FormField'

export interface InputCurrencyProps extends FormFieldProps {
Expand All @@ -19,7 +20,7 @@ export const InputCurrency = withTheme<InputCurrencyProps>(
paddingBottom: 7,
borderBottomColor: theme.color.lighter
}}
fieldTextStyle={{ fontSize: theme.fontSize.medium }}
fieldTextStyle={globalStyles.inputText}
borderColor={theme.color.lighter}
acceptButtonBackgroundColor={theme.color.primary}
calcButtonBackgroundColor={theme.color.secondary}
Expand Down
8 changes: 3 additions & 5 deletions src/components/InputPercent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react'
import { InjectedTranslateProps } from 'react-i18next'
import { Alert } from 'react-native'
import { CalculatorInput } from 'react-native-calculator'
import { globalStyles } from '../styles'
import { FormField, FormFieldProps } from './FormField'

export interface InputPercentProps
Expand All @@ -22,7 +23,7 @@ export const InputPercent = withLocale<InputPercentProps>('common')(

return (
<ThemeConsumer>
{({ color, fontSize, fontName }) => (
{({ color }) => (
<FormField label={label} errors={errors}>
<CalculatorInput
value={value}
Expand All @@ -31,10 +32,7 @@ export const InputPercent = withLocale<InputPercentProps>('common')(
paddingBottom: 7,
borderBottomColor: color.lighter
}}
fieldTextStyle={{
fontSize: fontSize.medium,
fontFamily: fontName.regular
}}
fieldTextStyle={globalStyles.inputText}
borderColor={color.lighter}
acceptButtonBackgroundColor={color.primary}
calcButtonBackgroundColor={color.secondary}
Expand Down
11 changes: 10 additions & 1 deletion src/styles/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { createStyleSheet } from '@dokuhero/react-native-theme'
import {
createStyleSheet,
FontNameKeys,
FontSizesKeys
} from '@dokuhero/react-native-theme'

export const globalStyles = createStyleSheet({
container: {
Expand All @@ -8,5 +12,10 @@ export const globalStyles = createStyleSheet({
alignItems: 'center',
flexDirection: 'column',
justifyContent: 'center'
},
inputText: {
fontFamily: FontNameKeys.regular,
fontSize: FontSizesKeys.medium,
fontWeight: 'normal'
}
})

0 comments on commit dba63a6

Please sign in to comment.