Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add switch profile UI #3307

Merged
Merged
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
11 changes: 1 addition & 10 deletions app/assets/icons/switch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/components/atomic/galoy-icon/galoy-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import Note from "@app/assets/icons/note.svg"
import People from "@app/assets/icons/people.svg"
import Rank from "@app/assets/icons/rank.svg"
import Refresh from "@app/assets/icons/refresh.svg"
import Switch from "@app/assets/icons/switch.svg"
import { makeStyles, useTheme } from "@rneui/themed"

export const icons = {
Expand Down Expand Up @@ -106,6 +107,7 @@ export const icons = {
"payment-error": PaymentError,
"bell": Bell,
"refresh": Refresh,
"switch": Switch,
} as const

export type IconNamesType = keyof typeof icons
Expand Down
6 changes: 6 additions & 0 deletions app/i18n/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,7 @@ const en: BaseTranslation = {
tapToAddPhoneNumber: "Tap to add phone number",
loginMethods: "Login Methods",
level: "Level {level: string}",
switch: "switch",
accountLevel: "Account Level",
upgrade: "Upgrade your account",
logOutAndDeleteLocalData: "Log out and clear all local data",
Expand Down Expand Up @@ -2423,6 +2424,10 @@ const en: BaseTranslation = {
accountId: "Account ID",
copy: "Copy"
},
ProfileScreen: {
addNew : "Add new",
logout: "Logout",
},
TotpRegistrationInitiateScreen: {
title: "Two-factor authentication",
content:
Expand Down Expand Up @@ -2681,6 +2686,7 @@ const en: BaseTranslation = {
phone: "Phone",
phoneNumber: "Phone Number",
preimageProofOfPayment: "Preimage / Proof of Payment",
profile: "Profiles",
rate: "Rate",
reauth: "Your session has expired. Please log in again.",
restart: "Restart",
Expand Down
36 changes: 36 additions & 0 deletions app/i18n/i18n-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7407,6 +7407,10 @@ type RootTranslation = {
* @param {string} level
*/
level: RequiredParams<'level'>
/**
* s​w​i​t​c​h
*/
'switch': string
/**
* A​c​c​o​u​n​t​ ​L​e​v​e​l
*/
Expand Down Expand Up @@ -7577,6 +7581,16 @@ type RootTranslation = {
*/
copy: string
}
ProfileScreen: {
/**
* A​d​d​ ​n​e​w
*/
addNew: string
/**
* L​o​g​o​u​t
*/
logout: string
}
TotpRegistrationInitiateScreen: {
/**
* T​w​o​-​f​a​c​t​o​r​ ​a​u​t​h​e​n​t​i​c​a​t​i​o​n
Expand Down Expand Up @@ -8395,6 +8409,10 @@ type RootTranslation = {
* P​r​e​i​m​a​g​e​ ​/​ ​P​r​o​o​f​ ​o​f​ ​P​a​y​m​e​n​t
*/
preimageProofOfPayment: string
/**
* P​r​o​f​i​l​e​s
*/
profile: string
/**
* R​a​t​e
*/
Expand Down Expand Up @@ -16418,6 +16436,10 @@ export type TranslationFunctions = {
* Level {level}
*/
level: (arg: { level: string }) => LocalizedString
/**
* switch
*/
'switch': () => LocalizedString
/**
* Account Level
*/
Expand Down Expand Up @@ -16582,6 +16604,16 @@ export type TranslationFunctions = {
*/
copy: () => LocalizedString
}
ProfileScreen: {
/**
* Add new
*/
addNew: () => LocalizedString
/**
* Logout
*/
logout: () => LocalizedString
}
TotpRegistrationInitiateScreen: {
/**
* Two-factor authentication
Expand Down Expand Up @@ -17385,6 +17417,10 @@ export type TranslationFunctions = {
* Preimage / Proof of Payment
*/
preimageProofOfPayment: () => LocalizedString
/**
* Profiles
*/
profile: () => LocalizedString
/**
* Rate
*/
Expand Down
8 changes: 7 additions & 1 deletion app/i18n/raw-i18n/source/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,7 @@
"tapToAddPhoneNumber": "Tap to add phone number",
"loginMethods": "Login Methods",
"level": "Level {level: string}",
"switch": "switch",
"accountLevel": "Account Level",
"upgrade": "Upgrade your account",
"logOutAndDeleteLocalData": "Log out and clear all local data",
Expand Down Expand Up @@ -2342,6 +2343,10 @@
"accountId": "Account ID",
"copy": "Copy"
},
"ProfileScreen": {
"addNew": "Add new",
"logout": "Logout"
},
"TotpRegistrationInitiateScreen": {
"title": "Two-factor authentication",
"content": "Scan this QR code with your authenticator app. Alternatively, you can manually copy/paste the secret into your authenticator app."
Expand Down Expand Up @@ -2578,6 +2583,7 @@
"phone": "Phone",
"phoneNumber": "Phone Number",
"preimageProofOfPayment": "Preimage / Proof of Payment",
"profile": "Profiles",
"rate": "Rate",
"reauth": "Your session has expired. Please log in again.",
"restart": "Restart",
Expand Down Expand Up @@ -2728,7 +2734,7 @@
"drivingAdoption": "I'm driving Bitcoin adoption using Blink.",
"connectOnSocial": "Connect on social: ",
"fullDetails": "Full details at ",
"learnMore": "Learn more about Adopting Bitcoin at ",
"learnMore": "Learn more about Adopting Bitcoin at",
"mayChallenge": {
"title": "May Challenge!",
"description": "Grow your inner circle by 6 for a chance to win a set of Pizzas on your next Bitcoin Meetup.",
Expand Down
9 changes: 8 additions & 1 deletion app/navigation/root-navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import SendBitcoinCompletedScreen from "@app/screens/send-bitcoin-screen/send-bi
import SendBitcoinConfirmationScreen from "@app/screens/send-bitcoin-screen/send-bitcoin-confirmation-screen"
import SendBitcoinDestinationScreen from "@app/screens/send-bitcoin-screen/send-bitcoin-destination-screen"
import SendBitcoinDetailsScreen from "@app/screens/send-bitcoin-screen/send-bitcoin-details-screen"
import { AccountScreen } from "@app/screens/settings-screen/account"
import { AccountScreen, ProfileScreen } from "@app/screens/settings-screen/account"
import { DefaultWalletScreen } from "@app/screens/settings-screen/default-wallet"
import { DisplayCurrencyScreen } from "@app/screens/settings-screen/display-currency-screen"
import { NotificationSettingsScreen } from "@app/screens/settings-screen/notifications-screen"
Expand Down Expand Up @@ -335,6 +335,13 @@ export const RootStack = () => {
title: LL.common.account(),
}}
/>
<RootNavigator.Screen
name="profileScreen"
component={ProfileScreen}
options={{
title: LL.common.profile(),
}}
/>
<RootNavigator.Screen
name="notificationSettingsScreen"
component={NotificationSettingsScreen}
Expand Down
1 change: 1 addition & 0 deletions app/navigation/stack-param-lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export type RootStackParamList = {
transactionHistory?: undefined
Earn: undefined
accountScreen: undefined
profileScreen: undefined
notificationSettingsScreen: undefined
transactionLimitsScreen: undefined
acceptTermsAndConditions: NewAccountFlowParamsList
Expand Down
22 changes: 21 additions & 1 deletion app/screens/settings-screen/account/banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* If the user isn't logged in, it shows Login or Create Account
* Later on, this will support switching between accounts
*/
import { View } from "react-native"
import { TouchableOpacity, View } from "react-native"
import { TouchableWithoutFeedback } from "react-native-gesture-handler"

import { GaloyIcon } from "@app/components/atomic/galoy-icon"
Expand All @@ -19,6 +19,9 @@ import { Text, makeStyles, useTheme, Skeleton } from "@rneui/themed"
export const AccountBanner = () => {
const styles = useStyles()
const { LL } = useI18nContext()
const {
theme: { colors },
} = useTheme()

const navigation = useNavigation<StackNavigationProp<RootStackParamList>>()

Expand All @@ -31,6 +34,10 @@ export const AccountBanner = () => {

if (loading) return <Skeleton style={styles.outer} animation="pulse" />

const handleSwitchPress = () => {
navigation.navigate("profileScreen")
}

return (
<TouchableWithoutFeedback
onPress={() =>
Expand All @@ -46,6 +53,12 @@ export const AccountBanner = () => {
<Text type="p2">
{isUserLoggedIn ? usernameTitle : LL.SettingsScreen.logInOrCreateAccount()}
</Text>
<TouchableOpacity style={styles.switch} onPress={handleSwitchPress}>
<GaloyIcon name="switch" size={20} />
<Text type="p2" style={{ color: colors.primary }}>
{LL.AccountScreen.switch()}
</Text>
</TouchableOpacity>
</View>
</TouchableWithoutFeedback>
)
Expand All @@ -67,4 +80,11 @@ const useStyles = makeStyles(() => ({
alignItems: "center",
columnGap: 12,
},
switch: {
display: "flex",
flexDirection: "row",
alignItems: "center",
columnGap: 4,
marginLeft: "auto",
},
}))
1 change: 1 addition & 0 deletions app/screens/settings-screen/account/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./account-screen"
export * from "./profile"
117 changes: 117 additions & 0 deletions app/screens/settings-screen/account/profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { ScrollView } from "react-native-gesture-handler"
import { Screen } from "@app/components/screen"
import { GaloyPrimaryButton } from "@app/components/atomic/galoy-primary-button"
import { useI18nContext } from "@app/i18n/i18n-react"
import { TouchableOpacity, View } from "react-native"
import { GaloyIcon } from "@app/components/atomic/galoy-icon"
import { makeStyles, Text } from "@rneui/themed"

export const ProfileScreen: React.FC = () => {
const styles = useStyles()
const { LL } = useI18nContext()

const data = [
{
username: "User 1",
selected: true,
},
{
username: "User 2",
selected: false,
},
{
username: "User 3",
selected: false,
},
]
Prakhar-Agarwal-byte marked this conversation as resolved.
Show resolved Hide resolved

return (
<Screen keyboardShouldPersistTaps="handled">
<ScrollView contentContainerStyle={styles.outer}>
{data.map((profile, index) => {
return <Profile key={index} {...profile} />
})}
<GaloyPrimaryButton onPress={() => {}} containerStyle={styles.addNewButton}>
<GaloyIcon name="user" size={30} style={styles.icon} />
<Text>{LL.ProfileScreen.addNew()}</Text>
</GaloyPrimaryButton>
</ScrollView>
</Screen>
)
}

const Profile: React.FC<{ username: string; selected?: boolean }> = ({
username,
selected,
}) => {
const styles = useStyles()
const { LL } = useI18nContext()

return (
<TouchableOpacity>
<View style={styles.profile}>
<View style={styles.iconContainer}>
{selected && (
<GaloyIcon name="check-circle" size={30} style={styles.checkIcon} />
)}
</View>
<Text>{username}</Text>
{!selected && (
<TouchableOpacity style={styles.logoutButton} onPress={() => {}}>
<Text style={styles.logoutButtonText}>{LL.ProfileScreen.logout()}</Text>
</TouchableOpacity>
)}
</View>
<View style={styles.divider}></View>
</TouchableOpacity>
)
}

const useStyles = makeStyles(({ colors }) => ({
outer: {
marginTop: 4,
paddingBottom: 20,
display: "flex",
flexDirection: "column",
rowGap: 12,
},
iconContainer: {
height: 30,
width: 30,
marginRight: 10,
justifyContent: "center",
alignItems: "center",
},
icon: {
marginRight: 10,
},
addNewButton: {
marginVertical: 20,
marginHorizontal: "auto",
width: 150,
},
divider: {
borderWidth: 1,
borderColor: colors.grey4,
},
profile: {
display: "flex",
flexDirection: "row",
alignItems: "center",
marginBottom: 10,
marginHorizontal: 10,
},
checkIcon: {
color: colors._green,
margin: 10,
},
logoutButton: {
marginLeft: "auto",
marginRight: 10,
},
logoutButtonText: {
color: colors.primary,
fontSize: 20,
fontWeight: "bold",
},
}))