From aca3e1541340146ab287657feb13713e44e74b4c Mon Sep 17 00:00:00 2001 From: Chennara Nhes Date: Mon, 20 Nov 2023 22:24:19 +0100 Subject: [PATCH 1/7] feat: add edit family member screen --- src/_assets/icons/edit.png | Bin 0 -> 249 bytes src/_assets/icons/edit@2x.png | Bin 0 -> 293 bytes src/_assets/icons/edit@3x.png | Bin 0 -> 348 bytes src/_assets/icons/index.ts | 1 + .../_components/RootStackNavigator.tsx | 25 ++++++ .../_components/TRootStackParamList.ts | 2 + src/_translations/locales/nl.json | 5 ++ src/_utils/imageHelpers.ts | 4 + .../editFamilyMember/EditFamilyMember.tsx | 73 ++++++++++++++++++ .../family/editFamilyMember/style.ts | 49 ++++++++++++ .../family/familyOverview/FamilyOverview.tsx | 46 +++++++---- src/onboarding/family/familyOverview/style.ts | 21 +++-- src/onboarding/family/index.ts | 1 + 13 files changed, 205 insertions(+), 22 deletions(-) create mode 100644 src/_assets/icons/edit.png create mode 100644 src/_assets/icons/edit@2x.png create mode 100644 src/_assets/icons/edit@3x.png create mode 100644 src/onboarding/family/editFamilyMember/EditFamilyMember.tsx create mode 100644 src/onboarding/family/editFamilyMember/style.ts diff --git a/src/_assets/icons/edit.png b/src/_assets/icons/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..f16e7de4d81ff19feb099a72626922dd4205d859 GIT binary patch literal 249 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&k&H|6fVg?3oVGw3ym^DWND9BhG z$u(~mnkY#- z7N28J>Di>jd%{?tdI6W^x$?AU3vOw1(XSJ3X; qC9b^F7JNJTj{A@tlZ{Hf6#JYDr8g`l9ee_G8H1;*pUXO@geCyh)ly&p literal 0 HcmV?d00001 diff --git a/src/_assets/icons/edit@2x.png b/src/_assets/icons/edit@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..31eebf3fb8adc750765ed2e640a002b00f3e0c4d GIT binary patch literal 293 zcmeAS@N?(olHy`uVBq!ia0vp^5+KaM1|%Pp+x`GjoCO|{#S9E$svykh8Km+7D9BhG zJal`(agS~L z!L>!RkMII{7Ul&kcNe(5=@$r^V$$@WnfvAYEE`E^>cUNt7XT$fLSgo0BKKPxSa5m|joAI6v?L7O^Hgd(y_}IGn=06{c zIIe#-yz}_C{=9HsR*$Rh-3MjX&<}f?q<%P`T%?hCt;c3^ykZNZj#9?tZTCGVzm4>8 k)XbW?voX)^u|k1|%Oc%$NbBI14-?iy0UcEkKyjb(&!UP>``W z$lZxy-8q?;Kn_c~qpu?a!^VE@KZ&eB{zp$2$B+ufx7XhCHW>)8J;;8<&~tzz?}1j{ z1CDE)YlL60^&R2>iaeM6z4&6(uY+HIEzU1e+_J@{k(+VB^5?=XHi5d^)+tCb&G~3v zKH-FX56`LQ%79G4Dg2MmTyebB3>+_uX z>XS3)1B7&dlFwv$cXl3Z2}qj3;KlcNjj3+pld5IOLf7*8EX|rX&h|T-@aEX&%?~AZ zwy{rUPCB}z>4u@^0<9Sl0_thojqES=);#uKwYRt~&@1!7iR;2$oowe4eoSwaU3{S5 osKg?Gw{fd^l`mUWmDFkOtc=`8Q4?C3fu3jZboFyt=akR{0CO^h>;M1& literal 0 HcmV?d00001 diff --git a/src/_assets/icons/index.ts b/src/_assets/icons/index.ts index 2ec34eea..ec1aef2c 100644 --- a/src/_assets/icons/index.ts +++ b/src/_assets/icons/index.ts @@ -15,6 +15,7 @@ export const CircledCheck = require('./circledCheck.png'); export const Clock = require('./clock.png'); export const Close = require('./close.png'); export const Copy = require('./copy.png'); +export const Edit = require('./edit.png'); export const External = require('./external.png'); export const Family = require('./family.png'); export const Filter = require('./filter.png'); diff --git a/src/_routing/_components/RootStackNavigator.tsx b/src/_routing/_components/RootStackNavigator.tsx index a720a14f..dffeacf6 100644 --- a/src/_routing/_components/RootStackNavigator.tsx +++ b/src/_routing/_components/RootStackNavigator.tsx @@ -17,6 +17,7 @@ import Login from '../../login/Login'; import { AddFamilyMember, AddFamilyMemberError, + EditFamilyMember, FamilyInformation, FamilyOnboarding, FamilyOverview, @@ -97,10 +98,18 @@ export const RootStackNavigator = () => { headerShown: false, }} /> + { headerShown: false, }} /> + + )} diff --git a/src/_routing/_components/TRootStackParamList.ts b/src/_routing/_components/TRootStackParamList.ts index 3b14f52b..465650f2 100644 --- a/src/_routing/_components/TRootStackParamList.ts +++ b/src/_routing/_components/TRootStackParamList.ts @@ -8,6 +8,7 @@ import { TFilterRewardCategory, TFilterRewardSection } from '../../shop/_hooks/u import { TReward, TRewardType } from '../../shop/_models/reward'; import { TSearchFilters } from '../../shop/_models/searchFilters'; import { TFilterRewardSorting } from '../../shop/_queries/useGetRewards'; +import { TFamilyMember } from '../../profile/_models'; export type TRootRoute = keyof TRootStackParamList; export type TMainRoute = keyof TMainParamsList; @@ -31,6 +32,7 @@ export type TRootStackParamList = { About: undefined; AddFamilyMember: undefined; AddFamilyMemberError: { description: string }; + EditFamilyMember: { member: TFamilyMember }; Error: { gotoAfterClose?: [TRootRoute, TMainRoute] | keyof TRootStackParamList; message: string; diff --git a/src/_translations/locales/nl.json b/src/_translations/locales/nl.json index 58a38daf..1189564e 100644 --- a/src/_translations/locales/nl.json +++ b/src/_translations/locales/nl.json @@ -55,6 +55,11 @@ "BACK_TO_FAMILY_OVERVIEW": "Terug naar gezinsoverzicht" } }, + "EDIT_MEMBER": { + "TITLE": "Gezinslid wijzigen", + "DESCRIPTION": "Kies de weergave van het gezinslid", + "SAVE": "Opslaan" + }, "INFORMATION": { "INFO_TITLE": "Bekijk je gezin via deze knop", "INFO": "Hier kan je snel je gezinssamenstelling raadplegen en alle UiTPAS kaarten raadplegen.", diff --git a/src/_utils/imageHelpers.ts b/src/_utils/imageHelpers.ts index 368b320e..a5b6b60f 100644 --- a/src/_utils/imageHelpers.ts +++ b/src/_utils/imageHelpers.ts @@ -2,6 +2,10 @@ import * as Avatars from '../_assets/images/avatars'; export const DEFAULT_AVATAR_NAME = 'Emoji0'; +export const getValidAvatarNameOrDefault = (name: string) => { + return Avatars[name] ? name : DEFAULT_AVATAR_NAME; +}; + export const getAvatarByNameOrDefault = (name: string) => { return Avatars[name] ?? Avatars[DEFAULT_AVATAR_NAME]; }; diff --git a/src/onboarding/family/editFamilyMember/EditFamilyMember.tsx b/src/onboarding/family/editFamilyMember/EditFamilyMember.tsx new file mode 100644 index 00000000..f9f1e971 --- /dev/null +++ b/src/onboarding/family/editFamilyMember/EditFamilyMember.tsx @@ -0,0 +1,73 @@ +import { useMemo, useState } from 'react'; +import { useTranslation } from 'react-i18next'; +import { FlatList } from 'react-native'; +import { useSafeAreaInsets } from 'react-native-safe-area-context'; + +import * as Avatars from '../../../_assets/images/avatars'; +import { Button, SafeAreaView, Typography } from '../../../_components'; +import { TRootStackRouteProp } from '../../../_routing'; +import { applyBarcodeMask, getAvatarByNameOrDefault, getValidAvatarNameOrDefault } from '../../../_utils'; +import * as Styled from './style'; + +type TProps = { + route: TRootStackRouteProp<'EditFamilyMember'>; +}; + +export const EditFamilyMember = ({ route }: TProps) => { + const { member } = route.params; + + const [selectedAvatar, setSelectedAvatar] = useState(getValidAvatarNameOrDefault(member.icon)); + const sortedAvatars = useMemo(() => { + const avatars = Object.keys(Avatars).slice(); + avatars.sort((item, item2) => { + if (item.includes('Emoji') && !item2.includes('Emoji')) { + return -1; + } + if (item2.includes('Emoji') && !item.includes('Emoji')) { + return 1; + } + return item.localeCompare(item2); + }); + return avatars; + }, []); + + const { bottom } = useSafeAreaInsets(); + const { t } = useTranslation(); + + return ( + + + + + {member.firstName} + + + {applyBarcodeMask(member.uitpasNumber)} + + + + {t('ONBOARDING.FAMILY.EDIT_MEMBER.DESCRIPTION')} + + + } + columnWrapperStyle={{ padding: 8 }} + contentContainerStyle={{ alignItems: 'center', paddingHorizontal: 8 }} + data={sortedAvatars} + numColumns={5} + renderItem={({ item: avatar }) => ( + setSelectedAvatar(avatar)}> + + + + + )} + /> + + +