diff --git a/types/react-native-settings-list/index.d.ts b/types/react-native-settings-list/index.d.ts new file mode 100644 index 0000000000..0ba14c9562 --- /dev/null +++ b/types/react-native-settings-list/index.d.ts @@ -0,0 +1,149 @@ +// Type definitions for react-native-settings-list 1.8 +// Project: https://github.com/evetstech/react-native-settings-list +// Definitions by: MrLuje +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.6 + +import { Component, ReactNode } from "react"; +import { TextStyle, StyleProp, ImageStyle, ViewStyle } from "react-native"; + +interface SettingsListProps { + /** + * default: white + */ + backgroundColor?: string; + /** + * default: black + */ + borderColor?: string; + /** + * default: 50 + */ + defaultItemSize?: number; + /** + * default: transparent + */ + underlayColor?: string; + /** + * default: {fontSize: 16} + */ + defaultTitleStyle?: StyleProp; + defaultTitleInfoPosition?: string; + scrollViewProps?: object; +} +declare class SettingsList extends Component {} + +interface HeaderProps { + headerText?: string; + headerStyle?: StyleProp; + headerRef?: () => void; + /** + * default: 1 + */ + headerNumberOfLines?: number; +} + +interface ItemProps { + /** + * Title being displayed + */ + title?: string; + titleStyle?: StyleProp; + /** + * Icon displayed on the left of the settings item + */ + icon?: ReactNode; + + /** + * Item Box Style + */ + itemBoxStyle?: StyleProp; + /** + * Title Box Style + */ + titleBoxStyle?: StyleProp; + /** + * Right Side Style + */ + rightSideStyle?: StyleProp; + /** + * Editable Right Side Style + */ + editableTextStyle?: StyleProp; + + /** + * Individual item width. Can be globally set in the parent. Will become deprecated + */ + itemWidth?: number; + /** + * Allows for the item to become an auth item + */ + isAuth?: boolean; + authPropsUser?: object; + authPropsPW?: object; + /** + * Individual background color. Can be globally set in the parent. Will become Deprecated + */ + backgroundColor?: string; + + /** + * Individual underlay click color. Can be globally set in the parent. + */ + underlayColor?: string; + /** + * Item on press callback. + */ + onPress?: () => void; + /** + * Item on long press callback. + */ + onLongPress?: () => void; + /** + * Enable or disable the > arrow at the end of the setting item. + * Default: true + */ + hasNavArrow?: boolean; + arrowIcon?: ReactNode; + + arrowStyle?: StyleProp; + /** + * Enable or disable a Switch component + */ + hasSwitch?: boolean; + /** + * Switch state + */ + switchState?: boolean; + /** + * Switch props + */ + switchProps?: object; + /** + * On value change callback + */ + switchOnValueChange?: () => void; + /** + * Right side information on the setting item + */ + titleInfo?: string; + titleInfoStyle?: StyleProp; + /** + * If 'Bottom'; info is placed beneath the title + */ + titleInfoPosition?: string; + /** + * Right side content + */ + rightSideContent?: ReactNode; + /* Gives opens to hide specific borders */ + borderHide?: "Top" | "Bottom" | "Both"; + + itemRef?: () => void; +} + +declare namespace SettingsList { + class Header extends Component {} + class Item extends Component {} +} + +export default SettingsList; diff --git a/types/react-native-settings-list/react-native-settings-list-tests.tsx b/types/react-native-settings-list/react-native-settings-list-tests.tsx new file mode 100644 index 0000000000..4cb31905e8 --- /dev/null +++ b/types/react-native-settings-list/react-native-settings-list-tests.tsx @@ -0,0 +1,219 @@ +"use strict"; +import { AppRegistry, StyleSheet, Text, Image, View } from "react-native"; + +import SettingsList from "react-native-settings-list"; +import { Component } from "react"; + +class SettingsListExample extends Component { + render() { + return ( + + + + Settings + + + + + + + + + } + hasNavArrow={false} + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + title="Data usage" + /> + + + + } + title="More" + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + hasNavArrow={false} + /> + + + + + + } + title="Display" + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + hasNavArrow={false} + /> + + + + } + title="Sound & notification" + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + hasNavArrow={false} + /> + + + + } + title="Apps" + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + hasNavArrow={false} + /> + + + + } + title="Storage & USB" + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + hasNavArrow={false} + /> + + + + } + title="Battery" + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + hasNavArrow={false} + /> + + + + } + title="Memory" + itemWidth={70} + titleStyle={{ color: "black", fontSize: 16 }} + hasNavArrow={false} + /> + + + + + ); + } +} + +const styles = StyleSheet.create({ + imageStyle: { + marginLeft: 15, + marginRight: 20, + alignSelf: "center", + width: 20, + height: 24, + justifyContent: "center" + } +}); + +AppRegistry.registerComponent("SettingsListExample", () => SettingsListExample); diff --git a/types/react-native-settings-list/tsconfig.json b/types/react-native-settings-list/tsconfig.json new file mode 100644 index 0000000000..aef7cfc242 --- /dev/null +++ b/types/react-native-settings-list/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react-native" + }, + "files": [ + "index.d.ts", + "react-native-settings-list-tests.tsx" + ] +} diff --git a/types/react-native-settings-list/tslint.json b/types/react-native-settings-list/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/react-native-settings-list/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }