Skip to content

Commit

Permalink
use StyleProp for all style props
Browse files Browse the repository at this point in the history
  • Loading branch information
budiadiono committed Sep 25, 2018
1 parent e35debe commit 011cbb8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
10 changes: 8 additions & 2 deletions src/Calculator.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import * as React from 'react'
import { LayoutRectangle, StyleSheet, View, ViewStyle } from 'react-native'
import {
LayoutRectangle,
StyleProp,
StyleSheet,
View,
ViewStyle
} from 'react-native'
import { Button } from './Button'
import { Display } from './Display'
import { CalculatorCommonProps, DefaultCommonProps } from './interface'
Expand Down Expand Up @@ -29,7 +35,7 @@ export interface CalculatorProps extends CalculatorCommonProps {
/**
* Container style.
*/
style?: ViewStyle
style?: StyleProp<ViewStyle>

/**
* Calculate button click event.
Expand Down
7 changes: 4 additions & 3 deletions src/CalculatorInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'
import {
Dimensions,
Modal,
StyleProp,
StyleSheet,
Text,
TextStyle,
Expand Down Expand Up @@ -38,17 +39,17 @@ export interface CalculatorInputProps extends CalculatorCommonProps {
/**
* Style of modal backdrop.
*/
modalBackdropStyle?: ViewStyle
modalBackdropStyle?: StyleProp<ViewStyle>

/**
* Text field container style.
*/
fieldContainerStyle?: ViewStyle
fieldContainerStyle?: StyleProp<ViewStyle>

/**
* Text style.
*/
fieldTextStyle?: TextStyle
fieldTextStyle?: StyleProp<TextStyle>

/**
* Prefix text.
Expand Down
5 changes: 4 additions & 1 deletion src/Display.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
findNodeHandle,
NativeModules,
Platform,
StyleProp,
StyleSheet,
Text,
TextStyle,
Expand All @@ -24,7 +25,7 @@ export interface DisplayProps {
height: number
width: number
value: string
style: TextStyle
style: StyleProp<TextStyle>
}

export class Display extends React.Component<DisplayProps, State> {
Expand Down Expand Up @@ -132,6 +133,7 @@ export class Display extends React.Component<DisplayProps, State> {
fontSize: height,
height,
lineHeight: height,
// @ts-ignore
color: style.color
}
]}
Expand Down Expand Up @@ -163,6 +165,7 @@ export class Display extends React.Component<DisplayProps, State> {
fontSize: fixSize,
height,
top: (height - fontHeight) / 2,
// @ts-ignore
color: ready ? style.color : 'transparent'
}
]}
Expand Down

0 comments on commit 011cbb8

Please sign in to comment.