1.0.15 • Published 4 years ago

mesan-react-native-components v1.0.15

Weekly downloads
5
License
ISC
Repository
github
Last release
4 years ago

React Native Basic Components

React Native Basic Components

Installation

$ npm i mesan-react-native-components --save

FilterView

Shows a filter view

import React from 'react';
import {View} from 'react-native';

import {FilterView} from 'mesan-react-native-components'

export default function Example(props) {
    const [selectedFilters, setSelectedFilters] = useState([]);
    const [filterVisible, setFilterVisible] = useState(false);
    
    //returns the filters and an array of selected
    const onDone = ({filters, selected}) => setSelectedFilters(selected);
    
    const order_options = [{name: "Name"}, {name: "Age"}, {name: "Price"}];
    const category_options = [{name: "Music"}, {name: "Sport"}, {name: "Theatre"}];
    const filters = [
        {title: "Order By", options: order_options}, 
        {title: "Category", options: category_options}
    ];
    
    return (
        <View>
            <FilterView
                modal={true}
                filters={filters}
                visible={filterVisible}
                onDone={onDone}
                onCancel={() => setFilterVisible(false)}/>
            <Text>{selectedFilters.toString()}</Text>
        </View>
    );

};
propvaluerequired/optionaldescription
modalbooleanoptionalindicates if the filter view will be displayed in a modal or not. if true, view is hidden until triggered
filtersarrayrequiredan array of objects of filters to display
onDonefunctionrequiredthe function called when the 'Done' button is tapped
onCancelfunctionrequiredthe function called when the 'Cancel' button is tapped
visibleobjectoptionalused to trigger the visibility of the Component, used only if 'modal' is true

Panel

Shows a panel

import React from 'react';

import {Panel} from 'mesan-react-native-components'

export default function Example(props) {
    return (
        <View>
            <Panel title={'Panel Header Title'}
                   data={[{}, {}, ...]} 
                   itemWidth={200}
                   margin={12}
                   containerStyle={{paddingTop: 12}}
                   titleStyle={{fontFamily: font,color: "#0E0E27", marginBottom: 4}}
                   renderItem={({item}) => <EventItem item={item} isFeatured={true}/>}/>
        </View>
    );

};
propvaluerequired/optionaldescription
titlestringoptionalThe panel title - Show at the top of panel
dataobjectrequiredthe data to show
itemWidthnumberrequiredthe width of the child components
marginnumberrequiredthe margin between the child components
containerStylefunctionoptionalthe style for the container
titleStylefunctionoptionalthe style for the title
renderItemfunctionrequiredthe component to render for each item

Container

A container with collapsing header and an hidden overlay view.

import React from 'react';

import {Panel} from 'mesan-react-native-components'

export default function Example(props) {
    return (
        <View>
            <Panel title={'Panel Header Title'}
                   data={[{}, {}, ...]} 
                   itemWidth={200}
                   margin={12}
                   containerStyle={{paddingTop: 12}}
                   titleStyle={{fontFamily: font,color: "#0E0E27", marginBottom: 4}}
                   renderItem={({item}) => <EventItem item={item} isFeatured={true}/>}/>
        </View>
    );

};
propvaluerequired/optionaldescription
headerHeightstringoptionalThe height of the header - defaults to 44 for ios and 65 for Android

| showHiddenView | boolean | optional | used to show/hide the hidden overlay view| | renderHiddenView | boolean | optional | used to show/hide the hidden overlay view| | hiddenViewStyle | function | optional | the style for the hidden view wrapper |

| data | object | required | the data to show | | itemWidth | number | required | the width of the child components | | margin | number | required | the margin between the child components | | containerStyle | function | optional | the style for the container | | renderItem | function | required | the component to render for each item |

style: {},
contentContainerStyle: {},

headerTitle: '',
showHeader: true,
fixedHeader: false,
renderHeader: null,
headerBackgroundColor: '#ffffff',

renderFixedHeader: null

Loading

Shows a large view with a centered large loading indicator.

Footer

Shows a small view with a centered small loading indicator.

import React from 'react';

import {Loading, Footer} from 'mesan-react-native-components'

export default function Example(props) {
    const [data, setData] = useState([]);
    const [isFetching, setIsFetching] = useState(true);
    
    //2 - MAIN CODE BEGINS HERE
    useEffect(() => {
        setTimeout(() =>  setIsFetching(false), 3000);
    }, []);

    if (isFetching) return <Loading/>;
    
    return(
        <FlatList
            data={data}
            renderItem={renderItem}
            ListFooterComponent={<Footer/>}/>
    )
};

Error

Shows a view with a error message and a retry button

import React from 'react';
import {View} from 'react-native';

import {Error} from 'mesan-react-native-components'

export default function Example(props) {
    
    const onRetry= () => console.log("Retrying....");
    
    return (
        <View>
            <Error error={error} onRetry={onRetry}/>
        </View>
    );

};
propvaluerequired/optionaldescription
errorobjectrequiredan object with the key 'message'
onRetryfunctionoptionalthe function called when the retry button is tapped
1.0.15

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago