Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4d4ab4f
chore: ProfileHeader added
olafch May 26, 2024
fe6900e
chore: ProfileDetailsForm added
olafch May 27, 2024
783e36d
chore: ProfileDeleteAccountButton added among others
olafch May 27, 2024
5abb315
chore: update test text component styles
MateuszRostkowski May 29, 2024
dc8604e
corrections on ProfileScreen split
olafch May 29, 2024
718fdac
last changes from first pull added to this second pull
olafch May 29, 2024
c9f6149
ProfileDetailsForm working with i18Next on interface
olafch May 29, 2024
bf817cb
ProfileControlledInputs improved
olafch May 29, 2024
c77ed09
first commit on password form branch
olafch May 29, 2024
693aefe
UI of the password form done
olafch May 29, 2024
563bd24
Password form almost done, some code to be reviewed
olafch May 30, 2024
f8503e0
ProfilePasswordForm working
olafch May 30, 2024
8a1db38
Merge remote-tracking branch 'origin/chore/sections-division-ProfileS…
MateuszRostkowski May 31, 2024
79505b3
Merge pull request #61 from binarapps/chore/clean-up-form-inputs
MateuszRostkowski May 31, 2024
d4dc376
Merge remote-tracking branch 'origin/chore/sections-division-ProfileS…
MateuszRostkowski May 31, 2024
5411034
Added changes to pl.json
olafch May 31, 2024
e59f148
first commit on this branch
olafch May 31, 2024
1306d44
Merge pull request #62 from binarapps/feat/password-form
MateuszRostkowski Jun 2, 2024
54b42bf
ProfileEditImage almost done
olafch Jun 2, 2024
77df1ef
ProfileEditImage done without backend logic
olafch Jun 3, 2024
642a3fa
Deleted duplicated files
olafch Jun 3, 2024
efe27c2
Code optimization
olafch Jun 5, 2024
5ea929d
Code optimization
olafch Jun 5, 2024
d617680
Rest operator on props and index.ts for types added
olafch Jun 5, 2024
5f64e30
types imports optimized
olafch Jun 5, 2024
a5cf84d
All comments fixed
olafch Jun 5, 2024
3025dba
Merge pull request #63 from binarapps/feat/profile-image-section
MateuszRostkowski Jun 6, 2024
e235b81
docs: update dcousarus libraries
MateuszRostkowski Jun 17, 2024
85de1e0
chore: Update SignUpScreen.tsx with usePasswordValidation hook
MateuszRostkowski Jun 18, 2024
d1434f0
ProfileEditImage with better alignments
olafch Jun 20, 2024
5b721dc
password with validations done
olafch Jun 20, 2024
5487ad2
small fixes
olafch Jun 20, 2024
9e7636e
Merge branch 'chore/sections-division-ProfileScreen' of github.com:bi…
MateuszRostkowski Jun 24, 2024
693ed5c
fix: get rid of require cycle
MateuszRostkowski Jun 24, 2024
2e8b62d
chore: Update useCheckForAppUpdate to NOT use real app version
MateuszRostkowski Jun 24, 2024
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
6 changes: 2 additions & 4 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
"softwareKeyboardLayoutMode": "pan",
"googleServicesFile": "./google-services.json"
},
"assetBundlePatterns": [
"**/*"
],
"assetBundlePatterns": ["**/*"],
"ios": {
"buildNumber": "20",
"config": {
Expand Down Expand Up @@ -55,4 +53,4 @@
"bundler": "metro"
}
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
"expo-device": "~6.0.2",
"expo-font": "~12.0.5",
"expo-haptics": "~13.0.1",
"expo-image-picker": "~15.0.5",
"expo-linear-gradient": "~13.0.2",
"expo-linking": "~6.3.1",
"expo-local-authentication": "~14.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/FeaturedIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Icon } from '@baca/design-system'
import { IconNames } from '@baca/types/icon'
import { IconNames } from '@baca/types'

type FeatureIconSize = 'sm' | 'md' | 'lg' | 'xl'

Expand Down
7 changes: 7 additions & 0 deletions src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,10 @@ export * from './LanguagePicker'
export * from './Modal'
export * from './StatusBar'
export * from './Version'

export * from './screens/profile/ProfileControlledInput'
export * from './screens/profile/ProfileDeleteAccountButton'
export * from './screens/profile/ProfileDetailsForm'
export * from './screens/profile/ProfileEditImage'
export * from './screens/profile/ProfileHeader'
export * from './screens/profile/ProfilePasswordForm'
37 changes: 37 additions & 0 deletions src/components/screens/profile/ProfileControlledInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { ControlledField } from '@baca/components/organisms/ControlledField'
import { isWeb } from '@baca/constants'
import { Box, Text } from '@baca/design-system'
import { useWeb } from '@baca/hooks'
import { ProfileControlledInputProps } from '@baca/types'

export const ProfileControlledInput = ({
label,
name,
isDisabled = false,
...rest
}: ProfileControlledInputProps) => {
const { shouldApplyMobileStyles } = useWeb()

return (
<Box
justifyContent="space-between"
flexDirection={isWeb && !shouldApplyMobileStyles ? 'row' : 'column'}
mb={isWeb ? 10 : 0}
maxW={800}
>
<Text.SmBold flex={1} color="text.primary" mb={2.5}>
{label}
</Text.SmBold>
<Box flex={isWeb ? 2 : 0}>
<ControlledField.Input
autoCapitalize="none"
inputMode={name === 'email' ? 'email' : 'text'}
name={name}
testID={`${name}Input`}
isDisabled={isDisabled}
{...rest}
/>
</Box>
</Box>
)
}
72 changes: 72 additions & 0 deletions src/components/screens/profile/ProfileDeleteAccountButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { useAuthControllerDelete } from '@baca/api/query/auth/auth'
import { Button, Text, Spacer, Row, Box, useBottomSheet } from '@baca/design-system'
import { useCallback, useTranslation } from '@baca/hooks'
import { signOut } from '@baca/store/auth'
import { showErrorToast } from '@baca/utils'

export const ProfileDeleteAccountButton = () => {
const { t } = useTranslation()
const { mutateAsync: removeUserAccount, isLoading } = useAuthControllerDelete()

const { bottomSheetComponentRenderFunction, closeBottomSheet, presentBottomSheet } =
useBottomSheet({
title: '',
isDivider: false,
})

const handleRemoveUserAccount = useCallback(async () => {
try {
await removeUserAccount()
signOut()
} catch {
showErrorToast({
description: t('errors.something_went_wrong'),
})
}
}, [removeUserAccount, t])

const bottomSheet = bottomSheetComponentRenderFunction(
<Box px={4} pb={10}>
<Text.LgSemibold color="text.primary" pt={4} pb={2}>
{t('profile_screen.are_you_sure')}
</Text.LgSemibold>
<Text.SmRegular color="text.secondary" lineHeight="md">
{t('profile_screen.remove_account_desc')}
</Text.SmRegular>
<Row w="full" justifyContent="space-between" pt={8}>
<Button variant="SecondaryGray" flex={1} borderRadius={8} onPress={closeBottomSheet}>
{t('common.cancel')}
</Button>
<Spacer x={3} />
<Button
onPress={handleRemoveUserAccount}
variant="PrimaryDestructive"
flex={1}
borderRadius={8}
loading={isLoading}
>
{t('profile_screen.remove_account')}
</Button>
</Row>
</Box>,
{
name: 'delete-bin-line',
color: 'featured.icon.light.fg.error',
bgColor: 'bg.error.secondary',
}
)

return (
<Box borderColor="border.secondary" borderTopWidth={1} py={6} alignItems="flex-start">
<Button
leftIconName="delete-bin-line"
variant="SecondaryDestructive"
borderRadius={8}
onPress={presentBottomSheet}
>
{t('profile_screen.remove_account')}
</Button>
{bottomSheet}
</Box>
)
}
62 changes: 62 additions & 0 deletions src/components/screens/profile/ProfileDetailsForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { Box, Button, Spacer, Row } from '@baca/design-system'
import { useUpdateProfileForm } from '@baca/hooks'
import { useRouter } from 'expo-router'
import { useCallback } from 'react'
import { useTranslation } from 'react-i18next'

import { ProfileControlledInput } from './ProfileControlledInput'

export const ProfileDetailsForm = () => {
const { t } = useTranslation()
const { control, errors, setFocus, submit, isSubmitting } = useUpdateProfileForm()
const { back } = useRouter()

const focusLastNameInput = useCallback(() => setFocus('lastName'), [setFocus])

return (
<Box>
<Box borderColor="border.secondary" borderTopWidth={1} py={6}>
<ProfileControlledInput
label={t('form.labels.first_name')}
name="firstName"
placeholder={t('form.placeholders.first_name')}
{...{ control, errors }}
onFocus={focusLastNameInput}
/>
<ProfileControlledInput
label={t('form.labels.last_name')}
name="lastName"
placeholder={t('form.placeholders.last_name')}
{...{ control, errors }}
/>
<ProfileControlledInput
label={t('form.labels.email')}
name="email"
placeholder={t('form.placeholders.email')}
{...{ control, errors }}
isDisabled
onSubmitEditing={submit}
/>
<Row maxW={800} justifyContent="flex-end">
<Button.SecondaryColor
disabled={isSubmitting}
loading={isSubmitting}
onPress={back}
testID="backProfileButton"
>
{t('common.cancel')}
</Button.SecondaryColor>
<Spacer x="4" />
<Button
disabled={isSubmitting}
loading={isSubmitting}
onPress={submit}
testID="saveProfileUpdateButton"
>
{t('common.save')}
</Button>
</Row>
</Box>
</Box>
)
}
79 changes: 79 additions & 0 deletions src/components/screens/profile/ProfileEditImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Box, Text, Button, Row, themeColors } from '@baca/design-system'
import * as ImagePicker from 'expo-image-picker'
import { t } from 'i18next'
import { useState, useCallback } from 'react'
import { Image, StyleSheet } from 'react-native'

export const ProfileEditImage: React.FC = () => {
const [image, setImage] = useState<string | null>(null)

const pickImage = useCallback(async () => {
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
allowsEditing: true,
aspect: [4, 3],
quality: 1,
})

if (!result.canceled && result.assets && result.assets.length > 0) {
setImage(result.assets[0].uri)
}
}, [])

return (
<Row style={styles.container}>
<Box style={styles.textContainer}>
<Text.SmBold color="text.primary">{t('profile_screen.your_photo')}</Text.SmBold>
<Text.SmRegular color="text.secondary">
{t('profile_screen.your_photo_description')}
</Text.SmRegular>
</Box>
<Box style={styles.imageContainer}>
{image ? (
<Image source={{ uri: image }} style={styles.image} />
) : (
<Box style={styles.placeholder}>
<Text fontSize={11} color="Gray modern.600">
{t('profile_screen.photo_innerText')}
</Text>
</Box>
)}
</Box>
<Button onPress={pickImage}>{t('common.upload')}</Button>
</Row>
)
}

const styles = StyleSheet.create({
container: {
alignItems: 'flex-start',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'space-between',
maxWidth: 800,
},
image: {
height: '100%',
width: '100%',
},
imageContainer: {
borderRadius: 32,
height: 64,
marginBottom: 10,
marginRight: 82,
overflow: 'hidden',
width: 64,
},
placeholder: {
alignItems: 'center',
backgroundColor: themeColors.primitives['Gray neutral']['50'],
height: '100%',
justifyContent: 'center',
},
textContainer: {
flex: 1,
marginBottom: 30,
maxWidth: 260,
minWidth: 260,
},
})
14 changes: 14 additions & 0 deletions src/components/screens/profile/ProfileHeader.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Box, Text } from '@baca/design-system'
import { useTranslation } from '@baca/hooks'

export const ProfileHeader = () => {
const { t } = useTranslation()
return (
<Box>
<Text.LgBold color="text.primary">{t('profile_screen.profile')}</Text.LgBold>
<Text.MdRegular color="text.secondary">
{t('profile_screen.update_your_details')}
</Text.MdRegular>
</Box>
)
}
54 changes: 54 additions & 0 deletions src/components/screens/profile/ProfilePasswordForm.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Box, Button, Row } from '@baca/design-system'
import { useCallback } from '@baca/hooks'
import { useUpdatePasswordForm } from '@baca/hooks/forms'
import { usePasswordValidation } from '@baca/hooks/usePasswordValidation'
import { useTranslation } from 'react-i18next'
import { Keyboard } from 'react-native'

import { ProfileControlledInput } from './ProfileControlledInput'

export const ProfilePasswordForm = () => {
const { t } = useTranslation()
const { control, errors, submit, isSubmitting, setFocus } = useUpdatePasswordForm()

const { isPasswordError, passwordSuggestions, validationFn } = usePasswordValidation()

const focusNewPasswordInput = useCallback(() => setFocus('password'), [setFocus])

return (
<Box borderColor="border.secondary" borderTopWidth={1} py={6}>
<ProfileControlledInput
control={control}
errors={errors}
label={t('form.labels.old_password')}
name="oldPassword"
onSubmitEditing={focusNewPasswordInput}
placeholder={t('form.placeholders.old_password')}
type="password"
/>
<ProfileControlledInput
control={control}
errors={{}}
isInvalid={isPasswordError}
isRequired
label={t('form.labels.new_password')}
name="password"
onSubmitEditing={Keyboard.dismiss}
placeholder={t('form.placeholders.new_password')}
rules={{ validate: { validationFn } }}
type="password"
/>
{passwordSuggestions}
<Row maxW={800} justifyContent="flex-end">
<Button
disabled={isSubmitting}
loading={isSubmitting}
onPress={submit}
testID="changePasswordButton"
>
{t('common.change')}
</Button>
</Row>
</Box>
)
}
2 changes: 1 addition & 1 deletion src/design-system/bottomSheets/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconNames } from '@baca/types/icon'
import { IconNames } from '@baca/types'
import { BottomSheetModal } from '@gorhom/bottom-sheet'
import { RefObject } from 'react'

Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTheme } from '@baca/hooks'
import { IconNames } from '@baca/types/icon'
import { IconNames } from '@baca/types'
import { getColorValue } from '@baca/utils'
import {
useMemo,
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useTheme } from '@baca/hooks'
import { IconNames } from '@baca/types/icon'
import { IconNames } from '@baca/types'
import { getColorValue } from '@baca/utils'
import { createIconSetFromIcoMoon } from '@expo/vector-icons'
import iconJson from 'assets/icomoon/selection.json'
Expand Down
2 changes: 1 addition & 1 deletion src/design-system/components/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FontWeight, TextFontSize, _appTheme } from '@baca/design-system'
import { IconNames } from '@baca/types/icon'
import { IconNames } from '@baca/types'
import { DimensionValue, TextStyle, ViewProps, ViewStyle, TextInputProps } from 'react-native'

import { BoxProps } from './Box'
Expand Down
1 change: 1 addition & 0 deletions src/hooks/forms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from './useSignInForm'
export * from './useSignUpForm'
export * from './useTestForm'
export * from './useUpdateProfileForm'
export * from './useUpdatePasswordForm'
Loading