Skip to content

Instantly share code, notes, and snippets.

@nastyakitsune
Created December 3, 2019 14:48
Show Gist options
  • Select an option

  • Save nastyakitsune/4bb8c166fc3091e8fa4a3b0d694974bc to your computer and use it in GitHub Desktop.

Select an option

Save nastyakitsune/4bb8c166fc3091e8fa4a3b0d694974bc to your computer and use it in GitHub Desktop.
React Native Settings Component Layout
import React from 'react';
import {View, Text, TouchableOpacity, StyleSheet} from 'react-native';
import {SimpleLink, SectionTitle} from 'components';
import styles from './styles';
const SettingsView = ({
type = 'creator',
email = '',
minRate = 0,
logout,
onPasswordChange,
onRateChange,
onHelpOpen,
onTermsOpen,
onPrivacyOpen,
onDeleteAccount,
onBillingOpen,
onNotificationsOpen,
}) => (
<>
<View style={styles.container}>
<SectionTitle title={'Settings'} style={styles.titleContainer} />
<SimpleLink title={'Billing details'} action={onBillingOpen} />
{type === 'creator' && (
<SimpleLink
title={'Minimum rate'}
action={onRateChange}
additional={`${minRate} USD`}
/>
)}
<SectionTitle title={'App settings'} style={styles.titleContainer} />
<SimpleLink title={'Notifications'} action={onNotificationsOpen} />
<SimpleLink title={'Contact details'} action={onHelpOpen} />
<SimpleLink title={'Privacy policy'} action={onPrivacyOpen} />
<SimpleLink title={'Terms of use'} action={onTermsOpen} />
{type === config.userTypeMap.creator && (
<SimpleLink title={'Delete account'} action={onDeleteAccount} />
)}
</View>
<TouchableOpacity onPress={logout} style={styles.logoutBtn}>
<Text style={styles.logoutBtnText}>Log out</Text>
</TouchableOpacity>
</>
);
const styles = StyleSheet.create({
titleContainer: {
width: '100%',
paddingLeft: 16,
borderBottomColor: AppColors.black4,
borderBottomWidth: 0.5,
paddingTop: 16,
paddingBottom: 4,
},
logoutBtn: {
marginLeft: 16,
paddingVertical: 13,
borderBottomColor: AppColors.black4,
borderBottomWidth: 0.5,
borderTopColor: AppColors.black4,
borderTopWidth: 0.5,
// marginBottom: 34,
},
logoutBtnText: {
color: AppColors.blue,
fontSize: 16,
fontFamily: AppFonts.regular,
},
container: {
flex: 1,
},
});
export default SettingsView;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment