diff --git a/types/react-native-elements/README.md b/types/react-native-elements/README.md index 055c740038..a35f188c1d 100644 --- a/types/react-native-elements/README.md +++ b/types/react-native-elements/README.md @@ -9,7 +9,7 @@ List will update as typings are added - [x] Icons - [ ] ~~Side Menu~~ DEPRECATED - [x] Form Elements -- [ ] Search Bar +- [x] SearchBar - [x] ButtonGroup - [x] CheckBoxes - [x] List Element diff --git a/types/react-native-elements/index.d.ts b/types/react-native-elements/index.d.ts index f798dbfb09..3a403fce6c 100644 --- a/types/react-native-elements/index.d.ts +++ b/types/react-native-elements/index.d.ts @@ -20,7 +20,7 @@ import { StatusBarProperties, KeyboardType, KeyboardTypeIOS, - StyleProp, + StyleProp } from 'react-native'; /** @@ -44,7 +44,7 @@ export interface IconObject { color?: string; size?: number; type?: IconType; - style?: any; + style?: StyleProp; } export interface AvatarIcon extends IconObject { @@ -1565,3 +1565,125 @@ export interface RatingProps { * @see https://react-native-training.github.io/react-native-elements/API/rating/ */ export class Rating extends React.Component {} + +export interface SearchBarProps extends TextInputProperties { + /** + * TextInput container styling + */ + containerStyle?: StyleProp; + + /** + * TextInput styling + */ + inputStyle?: StyleProp; + + /** + * @deprecated + * Get ref of TextInput + */ + textInputRef?(ref: TextInput): void; + + /** + * @deprecated + * Get ref of TextInput container + */ + containerRef?(ref: any): void; + + /** + * Specify color, styling, or another Material Icon Name + */ + icon?: IconObject; + + /** + * Remove icon from textinput + * + * @default false + */ + noIcon?: boolean; + + /** + * @default false change theme to light theme + */ + lightTheme?: boolean; + + /** + * Change TextInput styling to rounded corners + * + * @default false + */ + round?: boolean; + + /** + * Specify other than the default transparent underline color + * + * @default 'transparent' + */ + underlineColorAndroid?: string; + + /** + * Specify color, styling of the loading ActivityIndicator effect + * + * @default "{ color: '#86939e' }" + */ + loadingIcon?: IconObject; + + /** + * Show the loading ActivityIndicator effect + * + * @default false + */ + showLoadingIcon?: boolean; + + /** + * Set the placeholder text + * + * @default '' + */ + placeholder?: string; + + /** + * Set the color of the placeholder text + * + * @default '#86939e' + */ + placeholderTextColor?: string; + + /** + * Method to fire when text is changed + */ + onChangeText?(text: string): void; + + /** + * Specify color, styling, or another Material Icon Name + * (Note: pressing on this icon clears text inside the searchbar) + * + * @default "{ color: '#86939e', name: 'search' }" + */ + clearIcon?: IconObject; +} + +/** + * SearchBar component + * @see https://react-native-training.github.io/react-native-elements/API/searchbar/ + */ +export class SearchBar extends React.Component { + /** + * Holds reference to the stored input. + */ + input: TextInput; + + /** + * Call focus on the TextInput + */ + focus(): void; + + /** + * Call blur on the TextInput + */ + blur(): void; + + /** + * Call clear on the TextInput + */ + clearText(): void; +} diff --git a/types/react-native-elements/react-native-elements-tests.tsx b/types/react-native-elements/react-native-elements-tests.tsx index bba3250c67..7316946b35 100644 --- a/types/react-native-elements/react-native-elements-tests.tsx +++ b/types/react-native-elements/react-native-elements-tests.tsx @@ -1,288 +1,297 @@ import * as React from 'react'; import { - ListView, - View, - StyleSheet, - TouchableNativeFeedback, - Image + ListView, + View, + StyleSheet, + TouchableNativeFeedback, + Image, + TextInput } from 'react-native'; import { - Button, - Text, - Badge, - Avatar, - Card, - ButtonGroup, - CheckBox, - Divider, - FormInput, - FormValidationMessage, - FormLabel, - Header, - Icon, - List, - ListItem, - PricingCard, - Rating + Button, + Text, + Badge, + Avatar, + Card, + ButtonGroup, + CheckBox, + Divider, + FormInput, + FormValidationMessage, + FormLabel, + Header, + Icon, + List, + ListItem, + PricingCard, + Rating, + SearchBar } from 'react-native-elements'; class TextTest extends React.Component { - render() { - return ( - - Heading 1 - Heading 2 - Heading 3 - Heading 4 - - ); - } + render() { + return ( + + Heading 1 + Heading 2 + Heading 3 + Heading 4 + + ); + } } class AvatarTest extends React.Component { - render() { - return ( - - - Avatars - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - + render() { + return ( + + + Avatars + console.log('Works!')} + activeOpacity={0.7} + /> + console.log('Works!')} + activeOpacity={0.7} + /> + console.log('Works!')} + activeOpacity={0.7} + /> + console.log('Works!')} + activeOpacity={0.7} + /> + - - Avatar with initials - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - console.log('Works!')} - activeOpacity={0.7} - /> - + + Avatar with initials + console.log('Works!')} + activeOpacity={0.7} + /> + console.log('Works!')} + activeOpacity={0.7} + /> + console.log('Works!')} + activeOpacity={0.7} + /> + console.log('Works!')} + activeOpacity={0.7} + /> + - - Avatar with icons - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ - flex: 2, - marginLeft: 20, - marginTop: 115 - }} - /> - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ flex: 3, marginTop: 100 }} - /> - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ flex: 4, marginTop: 75 }} - /> - console.log('Works!')} - activeOpacity={0.7} - containerStyle={{ flex: 5, marginRight: 60 }} - /> - - - ); - } + + Avatar with icons + console.log('Works!')} + activeOpacity={0.7} + containerStyle={{ + flex: 2, + marginLeft: 20, + marginTop: 115 + }} + /> + console.log('Works!')} + activeOpacity={0.7} + containerStyle={{ flex: 3, marginTop: 100 }} + /> + console.log('Works!')} + activeOpacity={0.7} + containerStyle={{ flex: 4, marginTop: 75 }} + /> + console.log('Works!')} + activeOpacity={0.7} + containerStyle={{ flex: 5, marginRight: 60 }} + /> + + + ); + } } const AvatarStyles = StyleSheet.create({ - title: { - fontSize: 30, - marginBottom: 10 - } + title: { + fontSize: 30, + marginBottom: 10 + } }); class BadgeTest extends React.Component { - render() { - return ( - - + render() { + return ( + + - - User 1 - + + User 1 + - console.log('pressed')} value="5" /> + console.log('pressed')} value="5" /> - - - ); - } + + + ); + } } class ButtonTest extends React.Component { - handleButtonPress() { - console.log('I got pressed'); - } + handleButtonPress() { + console.log('I got pressed'); + } - render() { - return ( - -