Skip to content

Commit

Permalink
fix: ActionPicker should take Switch + text (#459)
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Feb 17, 2020
1 parent 265415b commit 90e63a4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 51 deletions.
92 changes: 42 additions & 50 deletions App/Screens/Home/Footer/SelectNotifications/SelectNotifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,64 +193,56 @@ export function SelectNotifications(
const isSwitchOn = notif !== 'never';

return (
<View style={[styles.container, style]} {...rest}>
<Switch
backgroundActive={theme.primaryColor}
backgroundInactive={hex2rgba(
theme.secondaryTextColor,
theme.disabledOpacity
)}
circleStyle={{
height: scale(22),
marginHorizontal: scale(3),
width: scale(22)
}}
height={scale(28)}
onSyncPress={(on: boolean): void => {
if (on) {
handleChangeNotif('weekly');
} else {
handleChangeNotif('never');
}
}}
style={styles.switch}
value={isSwitchOn}
width={scale(48)}
/>
{isSwitchOn ? (
<ActionPicker
actionSheetOptions={{
cancelButtonIndex: 3,
options: notificationsValues
.filter(f => f !== 'never') // Don't show never in options
.map(f => i18n.t(`home_frequency_${f}`)) // Translate
.map(capitalize)
.concat(i18n.t('home_frequency_cancel'))
}}
callback={(buttonIndex): void => {
if (buttonIndex === 3) {
// 3 is cancel
return;
}
<ActionPicker
actionSheetOptions={{
cancelButtonIndex: 4,
options: notificationsValues
.map(f => i18n.t(`home_frequency_${f}`)) // Translate
.map(capitalize)
}}
callback={(buttonIndex): void => {
if (buttonIndex === 4) {
// 4 is cancel
return;
}

handleChangeNotif(notificationsValues[buttonIndex + 1]); // +1 because we skipped neve
handleChangeNotif(notificationsValues[buttonIndex]); // +1 because we skipped neve
}}
>
<View style={[styles.container, style]} {...rest}>
<Switch
backgroundActive={theme.primaryColor}
backgroundInactive={hex2rgba(
theme.secondaryTextColor,
theme.disabledOpacity
)}
circleStyle={{
height: scale(22),
marginHorizontal: scale(3),
width: scale(22)
}}
>
<>
height={scale(28)}
style={styles.switch}
value={isSwitchOn}
width={scale(48)}
/>

{isSwitchOn ? (
<View>
<Text style={styles.label}>
{i18n.t('home_frequency_notify_me')}
</Text>
<Text style={styles.labelFrequency}>
{i18n.t(`home_frequency_${notif}`)}{' '}
<FontAwesome name="caret-down" />
</Text>
</>
</ActionPicker>
) : (
<Text style={styles.label}>
{i18n.t('home_frequency_allow_notifications')}
</Text>
)}
</View>
</View>
) : (
<Text style={styles.label}>
{i18n.t('home_frequency_allow_notifications')}
</Text>
)}
</View>
</ActionPicker>
);
}
1 change: 0 additions & 1 deletion App/localization/languages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
"home_swear_word_omg": "OMG",
"home_swear_word_crap": "Crap",
"home_swear_word_arrgh": "Arrgh",
"home_frequency_cancel": "Cancel",
"home_frequency_never": "never",
"home_frequency_daily": "daily",
"home_frequency_weekly": "weekly",
Expand Down

0 comments on commit 90e63a4

Please sign in to comment.