1.4.5 • Published 2 years ago

itkitchen-react-native-ui-lib v1.4.5

Weekly downloads
10
License
ISC
Repository
github
Last release
2 years ago

itkitchen-react-native-ui-lib

itkitchen-react-native-ui-lib is a framework that contains a set of UI components and functions.

Setup

To install open your project in command line and run:

npm install itkitchen-react-native-ui-lib

OR

yarn add itkitchen-react-native-ui-lib

Thats it!

Usage

For use you can import Functions and UI:

import { Functions, UI } from 'itkitchen-react-native-ui-lib'

UI

  • Switch - is UI component of switch:
import { Functions, UI } from 'itkitchen-react-native-ui-lib'

const [switchState, setSwitchState] = useState(false)

//...

return (
    <View style={styles.container}>
        <UI.Switch />
        <UI.Switch
            textStyle={{
                fontSize: 20
            }}
            containderStyle={{
                width: "50%",
                height: 50,
                marginTop: 15
            }}
            circleStyle={{
                width: "50%",
                height: 40,
                borderRadius: 20
            }}
            enabledCircleColor="#4DC861"
            disabledCircleColor="red"
            enabledText="On"
            disabledText="Off"
            enabledBackgroundColor="#ccc"
            disabledBackgroundColor="#ccc"
            onChangeState={switchState => setSwitchState(switchState)}
            initValue={true}
        />
    </View>
)

//...

Props

NameDescriptionDefaultType
activeOpacityopacity level on press0.6from 0 to 1
initValueinitial positionfalsebool
textStyleswitch text styleundefinedstyle
containderStyleswitch container styleundefinedstyle
circleStyleswitch circle styleundefinedstyle
enabledCircleColorcolor for circle of switch when it is on'#4DC861'string
disabledCircleColorcolor for circle of switch when it is off'red'string
enabledTexttext of switch when it is on'On'string
disabledTexttext of switch when it is off'Off'string
enabledBackgroundColorswitch background color when it is on'#ccc'string
disabledBackgroundColorswitch background color when it is off'#ccc'string
onChangeStatecallback when switch is clicked(value) => {callback(value)}func
  • AnimatedHeaderList - is UI component with animated header. This component based on FlatList and support all props of it. //Removed. Maybe in the next update we will refactor and refund it.
  • TextInput - is UI component with animated lable of text input.
//...
import { Functions, UI } from 'itkitchen-react-native-ui-lib'
//...
const [text, setText] = useState("")

return (
    <View style={styles.container}>
        <UI.TextInput
            placeholder="What is not a programming language"
            focusedPlaceholderTextColor="red"
            focusedContainerStyle={{
                borderColor: 'red',
                borderWidth: 1
            }}
            listData={[
                { value: 'js', label: 'JavaScript' },
                { value: 'php', label: 'PHP' },
                { value: 'python', label: 'Python' },
                { value: 'c', label: 'C++' },
                { value: 'ruby', label: 'Ruby' },
                { value: 'html', label: 'HTML' },
                { value: 'dart', label: 'Dart' },
            ]}
            listProps={{
                scrollView: {
                    style: {
                        width: 200
                    }
                },
                emptyText: 'Nothing is here'
            }}
        />
    </View>
)
//...

Props

NameDescriptionDefaultType
valuevalue of TextInput component""string
containerStylestyle of text input container{}object
focusedContainerStylestyle of text input container when it focused{}object
stylestyle of TextInput component{}object
focusedStylestyle of TextInput component when it focused{}object
IconComponenticon component that will render on right side of inputnullReact Component
iconVisiblethe boolean prop that hide or show right icon componentfalsebool
LeftIconComponenticon component that will render on left side of inputnullReact Component
leftIconVisiblethe boolean prop that hide or show left icon componentfalsebool
disableAnimationthe boolean prop that disable animationfalsebool
focusedPlaceholderTextColorif lable color shuld change on focus, pass your color to this propssame with placeholderTextColorstring
listDataarray of object({value: Any, label: String})[]array
listPropsobject of list props {"containerStyle": Object, style of list container. "scrollViewProps": ScrollViewProps, react-native ScrollView properties. "itemStyle": Object, list item style, "itemTextStyle": Object, list item text style, "emptyContainerStyle": Object, container style if list of suggestions is empty, "emptyTextStyle": Object, text style when list of suggestions is empty, "emptyText": Object, style of text when list of suggestions is empty }{}object
onListItemSelectcall back function when list item is pressed() => {}function
and all TextInput component propsany
  • Button - is UI component of button.
//...
import { Functions, UI } from 'itkitchen-react-native-ui-lib'
//...
return (
    <View style={styles.container}>
        <UI.Button 
            text="Button"
            style={{
                width: '95%',
                height: 40,
            }}
        />
    </View>
)

Props

NameDescriptionDefaultType
stylestyle of Button componentobjectstyle
textStylestyle of button textobjectstyle
onPressfunction that call when button pressedonPress={()=>{}}func
activeOpacitydetermines what the opacity of the wrapped view should be when touch is active. From 0 to 10.6float
texttext that will display on button"ItKitchenButton"string
loadingboolean props that show or hide spinner, also if loading true function "onPress" will not be calledfalsebool
loadingColorcolor of loading spinner"#ffffff"string
  • RadioButton - is UI component of radio button.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'
//...
const [value, setValue] = useState(false)
const [value1, setValue1] = useState(false)
//...
return (
    <View style={styles.container}>
        <UI.RadioButton
            value={value}
            title="Title"
            onPress={() => setValue(!value)}
            activeTintColor="red"
            inactiveTontColor="black"
        />
        <UI.RadioButton
            value={value1}
            title="Title 1"
            onPress={() => setValue1(!value1)}
            activeTintColor="red"
            inactiveTontColor="black"
        />
    </View>
)

Props

NameDescriptionDefaultType
containerStylestyle of the component containerobjectstyle
radioButtonStylestyle of the outer circleobjectstyle
circleStylestyle of the inner circleobjectstyle
valuevalue of button, if true button is checkedfalsebool
onPressfunction that call when button pressedonPress={()=>{}}func
activeOpacitydetermines what the opacity of the wrapped view should be when touch is active. From 0 to 10.6float
titletext that will display on right side of button""string
activeTintColorcolor when button is checked"#494043"string
inactiveTontColorcolor when button is unchecked"#494043"string
  • DropDown - is UI component of drop down list.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'
//...
const styles = StyleSheet.create({
    container: {
        flex: 1,
        width,
        alignItems: "center",
        justifyContent: "center"
    },
    dropdown: {
        width: "80%",
        borderRadius: 5,
        borderColor: "grey",
        borderWidth: 1,
        paddingHorizontal: 5
    }
})
//...
const [state, setState] = useState("")

const stringData = ["value 1", "value 2"]
const odjData = [{value: 1, label: "value 1"}, {value: 2, label: "value 2"}]

return (
    <View style={styles.container}>
        <UI.DropDown
            data={stringData}
            value={state}
            placeholder="Select value"
            onDataChange={value => setState(value)}
            style={styles.dropdown}
        />
    </View>
)

Props

NameDescriptionDefaultType
dataarray of strings that will display on drop down list[]array
valuevalue that will display on button""string
onDataChangefunction that call when selected new valueonDataChange={value => {}}func
stylestyle of the component containerobjectstyle
textStylestyle of the component textobjectstyle
placeholderTextStylestyle of the component placeholderobjectstyle
menuStylestyle of the menu containerobjectstyle
itemStylestyle of the menu item containerobjectstyle
itemTextStylestyle of the menu item textobjectstyle
placeholdervalue that will display when "value" property is empty""string
  • Avatar - is UI component of image for lists to profile screens.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'
//...
const styles = StyleSheet.create({
    container: {
        flex: 1,
        width,
        alignItems: "center",
        justifyContent: "center"
    }
})
//...

return (
    <View style={styles.container}>
        <UI.Avatar
            imageUrl="https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSsb3dnwW7TWK8zRGaCQ_ThqeLRWTZKXsWAL5z6rI_9UAwM0NqH"
            nameString="Tit Hardwood"
            badge={100}
            style={{ marginBottom: 15 }}
        />
        <UI.Avatar
            nameString="Tit Hardwood"
            badge={5}
        />
    </View>
)

Props

NameDescriptionDefaultType
imageUrlurl to image""String
nameStringstring of user name or description""string
onPressfunction that call when avatar pressedonPress={()=>{}}func
badgeused if you need to render badge on avatar0number
stylestyle of the component container{}style
imageStylestyle of the image{}style
badgeStylestyle of the badge{}style
badgeTextStylestyle of the badge{}style
letterStylestyle of letters of nameString when imageUrl is empty{}style
  • Badge - is UI component used to render a numerical value.
    import { Functions, UI } from 'itkitchen-react-native-ui-lib'
    //...
    const styles = StyleSheet.create({
        container: {
            flex: 1,
            width,
            alignItems: "center",
            justifyContent: "center"
        }
    })
    //...
    return (
        <View style={styles.container}>
            <UI.Badge badge={1} />
            <UI.Badge badge={12} />
            <UI.Badge badge={123} />
        </View>
    )

Props

NameDescriptionDefaultType
badgeused if you need to render badge on avatar0number
stylestyle of the component containerobjectstyle
textStylestyle of the badge valueobjectstyle
  • Card - is UI component used to render some information.
  1. cardType - default
    import { Functions, UI } from 'itkitchen-react-native-ui-lib'
    //...
    const styles = StyleSheet.create({
        container: {
            flex: 1,
            width
        }
    })
    //...
    const arr = new Array(10).fill({
        imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSsb3dnwW7TWK8zRGaCQ_ThqeLRWTZKXsWAL5z6rI_9UAwM0NqH',
        title: "Cat",
        subTitle: "Sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping"
    })
    //...
    return (
        <ScrollView
            style={styles.container}
            contentContainerStyle={{ alignItems: 'center' }}
        >
            {
                arr.map((item, index) => (
                    <UI.Card
                        key={index}
                        title={item.title}
                        description={item.description}
                        imageUrl={item.imageUrl}
                        containerStyle={{ marginBottom: 15 }}
                    />
                ))
            }
        </ScrollView>
    )

Props

NameDescriptionDefaultType
titletitle of card""string
descriptionsubtitle of card""string
imageUrlurl to image""string
onPressfunction that call when card pressedonPress={()=>{}}func
titleNumberOfLinesnumber of title lines. React-Native Text component property3number
descriptionNumberOfLinesnumber of description lines. React-Native Text component property3number
FooterComponent that will render on bottom of cardnullReact-Native Component
containerStylestyle of component container{}style
imageStylestyle of the image{}style
imageContainerStylestyle of image container{}style
infoContainerStylestyle of info container(title and subtitle){}style
titleStylestyle of card title{}style
descriptionStylestyle of card subtitle{}style
loadingColorcolor of ActivityIndicator while image loading"#000"string
loadingSizesize of ActivityIndicator while image loading'small''small' or 'large'
imagePropsImage component propsany
  1. cardType - animated //Removed.

  2. cardType - background

    import { Functions, UI } from 'itkitchen-react-native-ui-lib'
    //...
    const styles = StyleSheet.create({
        container: {
            flex: 1,
            width,
            alignItems: "center",
            justifyContent: "center"
        }
    })
    //...
    const arr = new Array(10).fill({
        imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSsb3dnwW7TWK8zRGaCQ_ThqeLRWTZKXsWAL5z6rI_9UAwM0NqH',
        title: "Cat",
        subTitle: "Sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping"
    })
    //...
    return (
        <ScrollView
            style={styles.container}
            contentContainerStyle={{ alignItems: 'center' }}
        >
            {
                arr.map((item, index) => (
                    <UI.Card
                        cardType="background"
                        key={index}
                        title={item.title}
                        description={item.subTitle}
                        imageUrl={item.imageUrl}
                        containerStyle={{ marginBottom: 15 }}
                    />
                ))
            }
        </ScrollView>
    )

Props

NameDescriptionDefaultType
titletitle of card""string
descriptionsubtitle of card""string
imageUrlurl to image""string
onPressfunction that call when card pressedonPress={()=>{}}func
titleNumberOfLinesnumber of title lines. React-Native Text component property3number
descriptionNumberOfLinesnumber of description lines. React-Native Text component property3number
FooterComponent that will render on bottom of cardnullReact-Native Component
containerStylestyle of component container{}style
imageStylestyle of the image{}style
maskStylestyle of mask view container{ ...StyleSheet.absoluteFillObject, backgroundColor: "rgba(0,0,0,0.4)" }style
infoContainerStylestyle of info container(title and subtitle){}style
titleStylestyle of card title{}style
descriptionStylestyle of card subtitle{}style
imageBackgroundPropsImageBackground component propsany
  • FlatList - is modified React-Native FlatList component.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'

const { width } = Dimensions.get("window")

const arr = new Array(10).fill({
    imageUrl: 'https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcSsb3dnwW7TWK8zRGaCQ_ThqeLRWTZKXsWAL5z6rI_9UAwM0NqH',
    title: "Cat",
    description: "Sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping sleeping"
})
const loading = true

//...

return(
    <UI.FlatList
        data={arr}
        renderItem={({ item }) => (
            <View style={{ width, paddingHorizontal: 15, paddingTop: 15 }}>
                <UI.Card
                    title={item.title}
                    description={item.description}
                    imageUrl={item.imageUrl}
                />
            </View>
        )}
        loading={loading}
        useRefreshControl={false}
        LoadinComponent={
            <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
                <ActivityIndicator animating size={"large"} />
            </View>
        }
    />
)

Props

NameDescriptionDefaultType
loadingif this property is true refresh controll or LoadingConponent is showing upfalsebool
onRefreshRefreshControl onRefresh property() => {}function
LoadinComponentcomponent that will be showing up instead of ListEmptyComponent if loading truenullReact-Native component
useRefreshControlif true used RefreshControll component to FlatListtruebool
emptyComponenTextDefault ListEmptyComponent text"There is nothing here"string
and all FlatList component propsany

Functions

  • normalize - is a function which normalizes the font size of the text relative to the screen size.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'

//...

return (
    <View style={styles.container}>
        <Text style={{ fontSize: Functions.normalize(14), color: "#000000", marginBottom: 15 }}>Some text</Text>
    </View>
);

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
});
  • wordsFromUpperCase - is a regex function that replace words first lower case character to upper.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'

//...

return (
    <View style={styles.container}>
        <Text style={{ fontSize: 14, color: "#000000" }}>{"some text without upper case"}</Text>
        <Text style={{ fontSize: 14, color: "#000000" }}>{Functions.wordsFromUpperCase("some text without upper case")}</Text>
    </View>
);

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
});
  • emailValid - is a regex function that return true if email is valid and return false if is not.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'

//...

const [email, setEmail] = useState("")

const checkEmail = () => {
    let check = Functions.emailValid(email)
    alert(check)
}

return (
    <View style={styles.container}>
        <UI.TextInput
            value={email}
            onChangeText={email => setEmail(email)}
            placeholder="Введите ваше имя"
            style={styles.textInput}
        />
        <TouchableOpacity onPress={checkEmail} style={styles.buttonContainer}>
            <Text style={{ color: "#ffffff" }}>Check email</Text>
        </TouchableOpacity>
    </View>
)

//...

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    buttonContainer: {
        width: "90%",
        height: 50,
        alignItems: "center",
        justifyContent: "center",
        backgroundColor: "blue",
        borderRadius: 24,
    },
    textInput: {
        height: 45,
        width: "90%",
        borderRadius: 24,
        backgroundColor: '#e8e8e8',
        justifyContent: "center",
        paddingHorizontal: 15,
        marginBottom: 15
    }
});
  • hexToRgba - is a function that can convert color hex value to rgb or rgba.
import { Functions, UI } from 'itkitchen-react-native-ui-lib'
//...
const color = "#c260b5"
const alpha = 0.2
return (
    <View style={styles.container}>
        <Text>{color}</Text>
        <Text>{Functions.hexToRgba(color)}</Text>
        <Text>{Functions.hexToRgba(color, alpha)}</Text>
    </View>
)
1.3.7

2 years ago

1.4.5

2 years ago

1.4.4

2 years ago

1.4.3

2 years ago

1.4.2

2 years ago

1.4.1

2 years ago

1.4.0

2 years ago

1.3.9

2 years ago

1.3.8

2 years ago

1.3.6

3 years ago

1.3.5

3 years ago

1.3.4

3 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.9

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

4 years ago

1.2.3

4 years ago

1.2.2

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago