react-native-language-select
Advanced tools
{ | ||
"extends": ["@commitlint/config-conventional"], | ||
"rules": { | ||
"rules": { | ||
"header-max-length": [0, "always", 150], | ||
@@ -5,0 +5,0 @@ "subject-case": [0, "always", "sentence-case"], |
@@ -1,4 +0,4 @@ | ||
import React from "react"; | ||
import { ViewStyle } from "react-native"; | ||
import { ILanguagePicker } from "../LanguagePicker"; | ||
import React from 'react'; | ||
import { ViewStyle } from 'react-native'; | ||
import { ILanguagePicker } from '../LanguagePicker'; | ||
interface ILanguageItem { | ||
@@ -10,2 +10,3 @@ item: ILanguagePicker; | ||
backgroundColor?: string; | ||
activeBorderColor?: string; | ||
textColor?: string; | ||
@@ -12,0 +13,0 @@ itemContainer?: ViewStyle; |
@@ -1,19 +0,21 @@ | ||
import RNBounceable from "@freakycoder/react-native-bounceable"; | ||
import React from "react"; | ||
import { Dimensions, Image, Text } from "react-native"; | ||
import RNBounceable from '@freakycoder/react-native-bounceable'; | ||
import React from 'react'; | ||
import { Dimensions, Image, Text } from 'react-native'; | ||
/** | ||
* ? Local Imports | ||
*/ | ||
import styles, { _itemContainer, _titleStyle } from "./LanguageItem.style"; | ||
const windowWidth = Dimensions.get("window").width; | ||
const LanguageItem = ({ itemContainer, item, width = windowWidth * 0.9, height = 80, isActive, backgroundColor = "#FFFFFF", textColor = "#2F3452", imageComponent, checkComponent, onSelect, }) => { | ||
const borderColor = isActive ? "#504ED9" : backgroundColor; | ||
return (<RNBounceable style={[ | ||
import styles, { _itemContainer, _titleStyle } from './LanguageItem.style'; | ||
const windowWidth = Dimensions.get('window').width; | ||
const LanguageItem = ({ itemContainer, item, width = windowWidth * 0.9, height = 80, isActive, backgroundColor = '#FFFFFF', textColor = '#2F3452', imageComponent, checkComponent, activeBorderColor = '#504ED9', onSelect, ...rest }) => { | ||
const borderColor = isActive ? activeBorderColor : backgroundColor; | ||
return (<RNBounceable {...rest} style={[ | ||
_itemContainer(backgroundColor, borderColor, width, height), | ||
itemContainer, | ||
]} onPress={() => onSelect && onSelect(item)}> | ||
{imageComponent || (<Image source={item.imageSource} style={styles.imageStyle}/>)} | ||
<Text style={_titleStyle(textColor)}>{item.title}</Text> | ||
{imageComponent || (<Image {...rest} source={item.imageSource} style={styles.imageStyle}/>)} | ||
<Text {...rest} style={_titleStyle(textColor)}> | ||
{item.title} | ||
</Text> | ||
{isActive && | ||
(checkComponent || (<Image source={require("../local-assets/check.png")} style={styles.checkImageStyle}/>))} | ||
(checkComponent || (<Image {...rest} source={require('../local-assets/check.png')} style={styles.checkImageStyle}/>))} | ||
</RNBounceable>); | ||
@@ -20,0 +22,0 @@ }; |
@@ -1,24 +0,14 @@ | ||
import React from "react"; | ||
import { ViewStyle } from "react-native"; | ||
import React from 'react'; | ||
import { ViewStyle } from 'react-native'; | ||
export interface ILanguagePicker { | ||
title: string; | ||
imageSource: any; | ||
initialIndex?: number; | ||
language: string; | ||
language?: string; | ||
} | ||
interface ILanguagePickerProps { | ||
data: ILanguagePicker[]; | ||
container?: ViewStyle; | ||
flatListStyle?: ViewStyle; | ||
containerWidth?: number; | ||
containerHeight?: number; | ||
initialIndex?: number; | ||
item: ILanguagePicker; | ||
width?: number; | ||
height?: number; | ||
isActive: boolean; | ||
backgroundColor?: string; | ||
textColor?: string; | ||
itemContainer?: ViewStyle; | ||
imageComponent?: React.ReactNode | React.ReactNode[]; | ||
checkComponent?: React.ReactNode | React.ReactNode[]; | ||
onSelect?: (selectedItem: ILanguagePicker) => void; | ||
@@ -25,0 +15,0 @@ } |
@@ -1,11 +0,11 @@ | ||
import React, { useState } from "react"; | ||
import { Dimensions, FlatList } from "react-native"; | ||
import React, { useState } from 'react'; | ||
import { Dimensions, FlatList } from 'react-native'; | ||
/** | ||
* ? Local Imports | ||
*/ | ||
import { _container } from "./LanguagePicker.style"; | ||
import LanguageItem from "./language-item/LanguageItem"; | ||
const windowWidth = Dimensions.get("window").width; | ||
const windowHeight = Dimensions.get("window").height; | ||
const LanguagePicker = ({ data, container, initialIndex = -1, containerWidth = windowWidth * 0.9, containerHeight = windowHeight * 0.7, backgroundColor, onSelect, ...rest }) => { | ||
import { _container } from './LanguagePicker.style'; | ||
import LanguageItem from './language-item/LanguageItem'; | ||
const windowWidth = Dimensions.get('window').width; | ||
const windowHeight = Dimensions.get('window').height; | ||
const LanguagePicker = ({ data, flatListStyle, initialIndex = -1, containerWidth = windowWidth * 0.9, containerHeight = windowHeight * 0.7, onSelect, ...rest }) => { | ||
const [selectedItem, setSelectedItem] = useState(data[initialIndex]); | ||
@@ -16,6 +16,6 @@ const handleOnSelectItem = (item) => { | ||
}; | ||
const renderItem = (item) => (<LanguageItem onSelect={handleOnSelectItem} backgroundColor={backgroundColor} isActive={selectedItem === item} item={item}/>); | ||
return (<FlatList data={data} style={[_container(containerWidth, containerHeight), container]} renderItem={({ item }) => renderItem(item)} keyExtractor={(item) => item.title}/>); | ||
const renderItem = (item) => (<LanguageItem onSelect={handleOnSelectItem} isActive={selectedItem === item} item={item} {...rest}/>); | ||
return (<FlatList data={data} style={[_container(containerWidth, containerHeight), flatListStyle]} renderItem={({ item }) => renderItem(item)} keyExtractor={item => item.title}/>); | ||
}; | ||
export default LanguagePicker; | ||
//# sourceMappingURL=LanguagePicker.js.map |
{ | ||
"name": "react-native-language-select", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Useful and customizable language picker", | ||
@@ -14,3 +14,3 @@ "main": "./build/dist/LanguagePicker.js", | ||
"sevval", | ||
"Sevvak", | ||
"Sevval", | ||
"react", | ||
@@ -17,0 +17,0 @@ "react-native", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
370405
-0.09%492
-2.19%