Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const data: SettingsData = [
{
type: 'SECTION',
header: 'My Section'.toUpperCase(),
visible: true,
footer:
'Donec sed odio dui. Integer posuere erat a ante venenatis dapibus posuere velit aliquet.',
rows: [
Expand All @@ -41,6 +42,7 @@ const data: SettingsData = [
title: 'This row has a',
subtitle: 'Subtitle',
showDisclosureIndicator: true,
visible: myPermissionCheckFunction(),
},
{
title: 'Long title. So long long long long long long long',
Expand Down
5 changes: 4 additions & 1 deletion SettingsScreenExample/lib/Row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export interface RowData {
subtitleStyle?: TextStyle
onPress?: () => void
showDisclosureIndicator?: boolean
renderAccessory?: () => React.ReactElement<any>
renderAccessory?: () => React.ReactElement<any>,
visible?: boolean,
}

export interface Props extends RowData {
Expand All @@ -27,13 +28,15 @@ export const Row = ({
onPress,
showDisclosureIndicator,
renderAccessory,
visible,

titleStyles,
subtitleStyles,
isFirst,
isLast,
}: Props) => {
let ContentContainer = onPress ? TouchableOpacity : View
if (visible === false) return null;

return (
<Container height={subtitle ? 56 : 46}>
Expand Down
2 changes: 2 additions & 0 deletions SettingsScreenExample/lib/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface SectionData {
key?: string
header?: string
footer?: string | (() => React.ReactElement<any>)
visible?: boolean,
rows: RowData[]
}

Expand Down Expand Up @@ -41,6 +42,7 @@ export const Section = ({ section, globalTextStyle }: SectionProps) => {
subtitleStyles={[globalTextStyle, rowData.subtitleStyle]}
isFirst={isFirst}
isLast={isLast}
visible={rowData.visible}
/>,
)
}
Expand Down
3 changes: 2 additions & 1 deletion SettingsScreenExample/lib/SettingsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type SettingsDatum = CustomViewData | SectionData
export interface CustomViewData {
type: 'CUSTOM_VIEW'
key?: string
visible?: boolean,
render: () => React.ReactElement<any>
}

Expand All @@ -24,7 +25,7 @@ export class SettingsScreen extends React.Component<Props> {
state = { refreshing: false }

render() {
const elements = this.props.data.map((item, i) => {
const elements = this.props.data.filter(x => x.visible !== false).map((item, i) => {
switch (item.type) {
case 'CUSTOM_VIEW':
return <View key={item.key || i}>{item.render()}</View>
Expand Down