import React from "react"; import { StyleSheet, FlatList, TouchableOpacity, View } from "react-native"; import { Block, Text, theme, Icon } from "galio-framework"; import { Switch } from "../components"; import argonTheme from "../constants/Theme"; export default class Settings extends React.Component { state = {}; toggleSwitch = switchNumber => this.setState({ [switchNumber]: !this.state[switchNumber] }); renderItem = ({ item }) => { const { navigate } = this.props.navigation; switch (item.type) { case "switch": return ( {item.title} this.toggleSwitch(item.id)} value={this.state[item.id]} /> ); case "button": return ( (item.id !== 'Payment' && item.id !== 'gift') && navigate(item.id)}> {item.title} ); default: break; } }; render() { const recommended = [ { title: "Use FaceID to sign in", id: "face", type: "switch" }, { title: "Auto-Lock security", id: "autolock", type: "switch" }, { title: "Notifications", id: "NotificationsSettings", type: "button" } ]; const payment = [ { title: "Manage Payment Options", id: "Payment", type: "button" }, { title: "Manage Gift Cards", id: "gift", type: "button" } ]; const privacy = [ { title: "User Agreement", id: "Agreement", type: "button" }, { title: "Privacy", id: "Privacy", type: "button" }, { title: "About", id: "About", type: "button" } ]; return ( item.id} renderItem={this.renderItem} ListHeaderComponent={ Recommended Settings These are the most important settings } /> Payment Settings These are also important settings item.id} renderItem={this.renderItem} /> Privacy Settings Third most important settings item.id} renderItem={this.renderItem} /> ); } } const styles = StyleSheet.create({ settings: { paddingVertical: theme.SIZES.BASE / 3 }, title: { paddingTop: theme.SIZES.BASE, paddingBottom: theme.SIZES.BASE / 2 }, rows: { height: theme.SIZES.BASE * 2, paddingHorizontal: theme.SIZES.BASE, marginBottom: theme.SIZES.BASE / 2 } });