Purii / react-native-tableview-simple

Flexible and lightweight React Native component for UITableView made with pure CSS
https://snack.expo.io/@purii/react-native-tableview-simple
MIT License
535 stars 63 forks source link

add separatorBackgroundColor to Section #785

Open cixio opened 1 month ago

cixio commented 1 month ago

adding separatorBackgroundColor to Section - this is a workaround for https://github.com/Purii/react-native-tableview-simple/issues/784

cixio commented 1 month ago

fixed bug

Purii commented 1 month ago

Hi @cixio, thanks for the PR. As you point out, this is just a workaround. The same issue happens with other props, like hideSeparator, as you mention in #784 . From what you report, I don't see any hard requirement, why you would introduce another react component as layer in between Section and Cell. Therefor I suggest to follow this approach:

https://github.com/Purii/react-native-tableview-simple?tab=readme-ov-file#override-defaults-of-cell-component

Is there anything that speaks against this approach from your point of view?

cixio commented 1 month ago

Hi, yes, I use this as workaround, but its also a new feature. :)

The soluton with the cellPropsCustom is a point, but thats also just a workaround as I think the best solution to use custom settings is this:

import { TableView as TV, Section as S, Cell as C, Separator as Sep } from 'react-native-tableview-simple';

const TableView = (props) => { 
    return (
        <TV
            appearance={'dark'}
            style={ {marginHorizontal: 15} }
            {...props}
        />
    );
}

const Section = (props) => {
    return ( 
        <S
            allowFontScaling={false}
            hideSurroundingSeparators={true}
            roundedCorners={true}
            {...props} 
        /> 
    );
}

[...]

export {TableView, Section, Cell, Separator};

So you only have to include this file on every page:

import { TableView, Section, Cell, Separator } from './myTableView';

And you can use tableview on multiple page without adding custom settings on every line.

The problem is that using this way makes some issues like the separator backgroundcolor and hideSeparator.