From cfded411c50c6442d73399b9f1547d619a8d3dc2 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 19:54:18 -0600 Subject: [PATCH 01/22] =?UTF-8?q?Se=20cre=C3=B3=20la=20nueva=20versi=C3=B3?= =?UTF-8?q?n=20de=20la=20pantalla=20principal=20de=20la=20aplicaci=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../state_selection/state_selection_page.tsx | 61 ++++++++++++++----- 1 file changed, 47 insertions(+), 14 deletions(-) diff --git a/mobile/src/screens/state_selection/state_selection_page.tsx b/mobile/src/screens/state_selection/state_selection_page.tsx index 358e2ab7..c46901e1 100644 --- a/mobile/src/screens/state_selection/state_selection_page.tsx +++ b/mobile/src/screens/state_selection/state_selection_page.tsx @@ -2,16 +2,24 @@ import { View, ActivityIndicator, Text } from "react-native"; import { pageStyles } from "../page_styles"; import { useGetStates } from "../../hooks/useGetStates"; import { ApiRequestStatus } from "../../common/constants/api_request_states"; -import { Caroussel } from "../../common/components/caroussel/caroussel"; +import { + Caroussel +} from "../../common/components/caroussel/caroussel"; import { router } from "expo-router"; import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; import { AnimatedBackground } from "../../common/components/animated_background"; import { ErrorPage } from "../error_page/error_page"; +import { LinearGradient } from "expo-linear-gradient"; +import { LIGHT_THEME } from "../../common/constants/theme"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useAuth } from "../../auth/contexts/auth_context"; +import { CARROUSEL_HEIGHT, CARROUSEL_WIDTH } from "../../common/constants/caroussel"; export const StateSelectionPage = () => { const { data, requestStatus, refresh } = useGetStates(); const { selectedStateIndex, onIndexChange, backgroundImageAnimation } = useAnimatedSelectedIndex(200, 200); + const { user } = useAuth(); if (requestStatus === ApiRequestStatus.LOADING) { return ( @@ -22,9 +30,7 @@ export const StateSelectionPage = () => { } if (requestStatus === ApiRequestStatus.ERROR || !data) { - return ( - - ); + return ; } const handleOnPress = (id: number) => { @@ -32,16 +38,43 @@ export const StateSelectionPage = () => { }; return ( - - - + + + {`Hola, ${user?.name} ${user?.lastName}!`} + + + + + + ); }; -- GitLab From 899f7903161227478dee0f5a1862f28b2b0253a7 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 19:55:30 -0600 Subject: [PATCH 02/22] =?UTF-8?q?Se=20elimin=C3=B3=20momentaneamente=20el?= =?UTF-8?q?=20requisito=20de=20la=20fecha=20de=20nacimiento=20para=20el=20?= =?UTF-8?q?formulario=20de=20setup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/screens/first_time_config_screen.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mobile/src/profile/screens/first_time_config_screen.tsx b/mobile/src/profile/screens/first_time_config_screen.tsx index d5fa6022..16b7bf21 100644 --- a/mobile/src/profile/screens/first_time_config_screen.tsx +++ b/mobile/src/profile/screens/first_time_config_screen.tsx @@ -15,15 +15,13 @@ import { useSlideControl } from "../hooks/useSlideControl"; import { router } from "expo-router"; export const FirstTimeComfigScreen = () => { - const { onSubmit, toogleInterest, interests, control } = useSetUpProfile(); + const { onSubmit, toogleInterest, interests } = useSetUpProfile(); const onFinishCallback = () => { onSubmit(); }; - console.log('render'); const { onFinish, onNext, onPrevious, currentSlide } = useSlideControl(onFinishCallback); const slides = [ , - , ]; return ( -- GitLab From 5ae371d1c1b2b088c6b213c202d80bc7b1174d07 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 19:56:50 -0600 Subject: [PATCH 03/22] =?UTF-8?q?Se=20agreg=C3=B3=20el=20metodo=20para=20o?= =?UTF-8?q?btener=20los=20intereses=20actuales=20del=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/domain/datasources/profile_datasource.ts | 1 + mobile/src/profile/domain/repositories/profile_repository.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/mobile/src/profile/domain/datasources/profile_datasource.ts b/mobile/src/profile/domain/datasources/profile_datasource.ts index 50ae7669..6a9e0a3a 100644 --- a/mobile/src/profile/domain/datasources/profile_datasource.ts +++ b/mobile/src/profile/domain/datasources/profile_datasource.ts @@ -2,6 +2,7 @@ import { IOption } from "../../../common/domain/entities/option"; export interface ProfileDataSource { getInterests: () => Promise; + getUserInterests: () => Promise; saveInterests: (options: IOption[]) => Promise; setUpProfile: (birthdate: string, interests: IOption[]) => Promise; changePassword: (oldPassword: string, newPassword: string) => Promise; diff --git a/mobile/src/profile/domain/repositories/profile_repository.ts b/mobile/src/profile/domain/repositories/profile_repository.ts index 98634810..728307e2 100644 --- a/mobile/src/profile/domain/repositories/profile_repository.ts +++ b/mobile/src/profile/domain/repositories/profile_repository.ts @@ -2,6 +2,7 @@ import { IOption } from "../../../common/domain/entities/option"; export interface ProfileRepository { getInterests: () => Promise; + getUserInterests: () => Promise; saveInterests: (options: IOption[]) => Promise; setUpProfile: (birthdate: string, interests: IOption[]) => Promise; changePassword: (oldPassword: string, newPassword: string) => Promise; -- GitLab From a1222c791d50ec25b818e92604462f1d0e46c398 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 19:57:22 -0600 Subject: [PATCH 04/22] =?UTF-8?q?Se=20cre=C3=B3=20un=20hook=20para=20obten?= =?UTF-8?q?er=20los=20intereses=20del=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/hooks/useGetUserInterests.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 mobile/src/profile/hooks/useGetUserInterests.ts diff --git a/mobile/src/profile/hooks/useGetUserInterests.ts b/mobile/src/profile/hooks/useGetUserInterests.ts new file mode 100644 index 00000000..a14556c1 --- /dev/null +++ b/mobile/src/profile/hooks/useGetUserInterests.ts @@ -0,0 +1,12 @@ +import { useDataContext } from "../../common/contexts/data_context" +import { IOption } from "../../common/domain/entities/option" +import { useGet } from "../../hooks/useGet" + +export const useGetUserInterests = () => { + const { profileRepository } = useDataContext() + const callback = async () => { + return profileRepository!.getUserInterests(); + } + const { data, requestStatus } = useGet(callback); + return { data, requestStatus }; +} \ No newline at end of file -- GitLab From 78ed43166b4e2cdc3b66cfe4ac8c7d3669dabe12 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 19:57:55 -0600 Subject: [PATCH 05/22] =?UTF-8?q?Se=20cre=C3=B3=20el=20modelo=20para=20una?= =?UTF-8?q?=20categoria=20proveniente=20de=20la=20api?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/infrastructure/model/categorie_model.ts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 mobile/src/profile/infrastructure/model/categorie_model.ts diff --git a/mobile/src/profile/infrastructure/model/categorie_model.ts b/mobile/src/profile/infrastructure/model/categorie_model.ts new file mode 100644 index 00000000..c4697509 --- /dev/null +++ b/mobile/src/profile/infrastructure/model/categorie_model.ts @@ -0,0 +1,4 @@ +export interface CategoryModel { + idCategory: number; + name: string; +} -- GitLab From 458f4e4680ee33240b3f04af8d1beb004b06fc1d Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 19:59:08 -0600 Subject: [PATCH 06/22] =?UTF-8?q?Se=20implement=C3=B3=20el=20metodo=20para?= =?UTF-8?q?=20obtener=20los=20intereses=20del=20usuario=20en=20el=20dataso?= =?UTF-8?q?urce=20de=20produccion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datasources/prod/profile_datasource.ts | 70 +++++++++++++++---- 1 file changed, 55 insertions(+), 15 deletions(-) diff --git a/mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts b/mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts index eee7b181..7384f5e7 100644 --- a/mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts +++ b/mobile/src/profile/infrastructure/datasources/prod/profile_datasource.ts @@ -2,25 +2,65 @@ import axios from "axios"; import { IOption } from "../../../../common/domain/entities/option"; import { ProfileDataSource } from "../../../domain/datasources/profile_datasource"; import { API_URL } from "../../../../common/constants/api"; +import { CategoryModel } from "../../model/categorie_model"; +import { categoryModelToOption } from "../../utils/category"; export class ProfileDataSourceProd implements ProfileDataSource { - async getInterests(): Promise { - throw new Error('Method not implemented.'); + private readonly lang: string; + constructor(lang: string) { + this.lang = lang; + } + async getUserInterests(): Promise { + const {data, status} = await axios.get(`${API_URL}/user/prefered-categories?lang=${this.lang}`); + if (status !== 200) { + throw new Error("Error getting user interests"); } - - async saveInterests(options: IOption[]): Promise { - throw new Error('Method not implemented.'); + const categories = data.map(categoryModelToOption); + return categories.map((category) => ({ + ...category, + isSelected: true, + })); + } + async getInterests(): Promise { + //TODO: Implement this method + const { status, data } = await axios.get( + `${API_URL}/category?lang=${this.lang}` + ); + if (status !== 200) { + throw new Error("Error getting interests"); } + return data.map(categoryModelToOption); + } - async setUpProfile(birthdate: string, interests: IOption[]): Promise { - throw new Error('Method not implemented.'); - } - - async changePassword(oldPassword: string, newPassword: string): Promise { - const {status, data} = await axios.patch(`${API_URL}/user/change-password`, { - prevPassword: oldPassword, - newPassword: newPassword - }) - console.log(status, data); + async saveInterests(options: IOption[]): Promise { + const payload = { + idCategories: options.map((option) => option.id), + }; + const { status } = await axios.patch( + `${API_URL}/user/update-prefered-categories`, + payload + ); + + if (status !== 200) { + throw new Error("Error updating interests"); } + } + + async setUpProfile(birthdate: string, interests: IOption[]): Promise { + throw new Error("Method not implemented."); + } + + async changePassword( + oldPassword: string, + newPassword: string + ): Promise { + const { status, data } = await axios.patch( + `${API_URL}/user/change-password`, + { + prevPassword: oldPassword, + newPassword: newPassword, + } + ); + console.log(status, data); + } } -- GitLab From 2c7efc7e70eea64ca2c41dd40a3a6de30afedfd8 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:01:31 -0600 Subject: [PATCH 07/22] =?UTF-8?q?Se=20implement=C3=B3=20el=20metodo=20para?= =?UTF-8?q?=20obtener=20los=20intereses=20del=20usuario=20en=20el=20dataso?= =?UTF-8?q?urce=20de=20desarrollo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/datasources/dev/profile_datasource.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts b/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts index f7e598af..863a94fe 100644 --- a/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts +++ b/mobile/src/profile/infrastructure/datasources/dev/profile_datasource.ts @@ -1,6 +1,13 @@ import { IOption } from '../../../../common/domain/entities/option'; import { ProfileDataSource } from '../../../domain/datasources/profile_datasource'; export class ProfileDataSourceDev implements ProfileDataSource { + async getUserInterests(): Promise { + const interests = await this.getInterests(); + interests[0].isSelected = true; + interests[1].isSelected = true; + interests[2].isSelected = true; + return interests; + } async getInterests(): Promise { return [ { id: 1, name: 'Tecnología', isSelected: false }, -- GitLab From 4dfec4e9d724bb433df6f271415c5dc9aafc6c72 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:02:39 -0600 Subject: [PATCH 08/22] =?UTF-8?q?Se=20implement=C3=B3=20el=20metodo=20para?= =?UTF-8?q?=20obtener=20los=20datos=20del=20usuario=20en=20la=20implementa?= =?UTF-8?q?cion=20del=20repositorio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../profile/infrastructure/repositories/profile_repository.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mobile/src/profile/infrastructure/repositories/profile_repository.ts b/mobile/src/profile/infrastructure/repositories/profile_repository.ts index 4dea3985..8ca0c033 100644 --- a/mobile/src/profile/infrastructure/repositories/profile_repository.ts +++ b/mobile/src/profile/infrastructure/repositories/profile_repository.ts @@ -6,6 +6,9 @@ export class ProfileRepositoryImpl implements ProfileRepository { constructor( private dataSource: ProfileDataSource ){} + getUserInterests(): Promise{ + return this.dataSource.getUserInterests(); + } async changePassword (oldPassword: string, newPassword: string): Promise { return this.dataSource.changePassword(oldPassword, newPassword); }; -- GitLab From 28368057837c38cb34ddedb72e5d125924bf2692 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:05:24 -0600 Subject: [PATCH 09/22] [FIX] se arreglo un error que mostraba un fondo incorrecto al cambiar de slide --- mobile/src/hooks/useAnimatedSelectedIndex.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mobile/src/hooks/useAnimatedSelectedIndex.ts b/mobile/src/hooks/useAnimatedSelectedIndex.ts index 4f56c218..4c2f8549 100644 --- a/mobile/src/hooks/useAnimatedSelectedIndex.ts +++ b/mobile/src/hooks/useAnimatedSelectedIndex.ts @@ -9,6 +9,8 @@ export const useAnimatedSelectedIndex = (startMilliseconds: number = 500, endMil const onIndexChange = useCallback((index: number) => { if (index !== selectedState.current) { + setTimeout(() => {}, 100); + if (index == selectedState.current) return; console.log("Index changed to: ", index); selectedState.current = index; Animated.timing(backgroundImageAnimation, { -- GitLab From cfd082d96f86e3d135af6cf57b165e0857f67a9c Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:06:45 -0600 Subject: [PATCH 10/22] Se agregaron las categorias de forma opcional a una actividad --- mobile/src/infrastructure/models/prod/activity_model.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mobile/src/infrastructure/models/prod/activity_model.ts b/mobile/src/infrastructure/models/prod/activity_model.ts index 228e187d..6327e300 100644 --- a/mobile/src/infrastructure/models/prod/activity_model.ts +++ b/mobile/src/infrastructure/models/prod/activity_model.ts @@ -10,4 +10,11 @@ export interface ActivityModel { closeAt: number; startDate: Date | null; endDate: Date | null; + categories?: TagModel[]; +} + +export interface TagModel { + idCategory: number; + language: string; + name: string; } -- GitLab From a0100bf2666bb352ec76635d7cd6e1870e542fbf Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:07:47 -0600 Subject: [PATCH 11/22] =?UTF-8?q?Se=20agreg=C3=B3=20un=20gradiente=20al=20?= =?UTF-8?q?fondo=20animado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/components/animated_background.tsx | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/mobile/src/common/components/animated_background.tsx b/mobile/src/common/components/animated_background.tsx index 7c208a9e..b06ea8e6 100644 --- a/mobile/src/common/components/animated_background.tsx +++ b/mobile/src/common/components/animated_background.tsx @@ -1,13 +1,18 @@ import { Animated, Image, View } from "react-native"; import { PlaceInfoEntity } from "../../domain/entities/place_info_entity"; import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; +import { LinearGradient } from "expo-linear-gradient"; +import { LIGHT_THEME } from "../constants/theme"; interface AnimatedBackgroundProps { - imageUri?: string; - backgroundImageAnimation: Animated.Value; -}; + imageUri?: string; + backgroundImageAnimation: Animated.Value; +} -export const AnimatedBackground = ({ imageUri, backgroundImageAnimation }: AnimatedBackgroundProps) => { +export const AnimatedBackground = ({ + imageUri, + backgroundImageAnimation, +}: AnimatedBackgroundProps) => { return ( - ); }; -- GitLab From 2ba2566315517a4cf3f73640199624d82a906f1b Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:09:12 -0600 Subject: [PATCH 12/22] =?UTF-8?q?[FIX]=20Se=20refactoriz=C3=B3=20el=20carr?= =?UTF-8?q?usel=20para=20hacer=20mas=20sencillo=20los=20imports=20en=20los?= =?UTF-8?q?=20archivos=20y=20prevenir=20dependencias=20circulares?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/components/caroussel/caroussel.tsx | 115 ++++++++++-------- .../components/caroussel/caroussel_tile.tsx | 5 +- mobile/src/common/constants/caroussel.ts | 7 ++ 3 files changed, 69 insertions(+), 58 deletions(-) create mode 100644 mobile/src/common/constants/caroussel.ts diff --git a/mobile/src/common/components/caroussel/caroussel.tsx b/mobile/src/common/components/caroussel/caroussel.tsx index b78eee75..edcdd508 100644 --- a/mobile/src/common/components/caroussel/caroussel.tsx +++ b/mobile/src/common/components/caroussel/caroussel.tsx @@ -1,9 +1,18 @@ -import { View, Animated, Text, Dimensions, Image, NativeSyntheticEvent, NativeScrollEvent } from "react-native"; +import { + View, + Animated, + Text, + Dimensions, + Image, + NativeSyntheticEvent, + NativeScrollEvent, +} from "react-native"; import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; import { useRef } from "react"; import { StateDataSource } from "../../../domain/datasources/state_datasource"; import { CarousselTile } from "./caroussel_tile"; import { router } from "expo-router"; +import { BLANK_ITEM_WIDTH, ITEM_WIDTH } from "../../constants/caroussel"; interface CarousselProps { data: PlaceInfoEntity[]; @@ -11,9 +20,6 @@ interface CarousselProps { onIndexChange?: (index: number) => void; } -const ITEM_WIDTH = Dimensions.get("window").width * 0.7; -const BLANK_ITEM_WIDTH = Dimensions.get("window").width * 0.15; - export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { const scrollX = useRef(new Animated.Value(0)).current; const finalData = [ @@ -36,57 +42,58 @@ export const Caroussel = ({ data, onPress, onIndexChange }: CarousselProps) => { onIndexChange && onIndexChange(index); }); return ( - item.id.toString()} - horizontal - showsHorizontalScrollIndicator={false} - decelerationRate={0} - initialNumToRender={1} - - bounces={false} - snapToInterval={ITEM_WIDTH} - onScroll={Animated.event([{ nativeEvent: { contentOffset: { x: scrollX } } }], { - useNativeDriver: true, - })} - renderItem={({ item, index }) => { - if (item.id === -1 || item.id === -2) { - return ; - } - const inputRange = [ - (index - 2) * ITEM_WIDTH, - (index - 1) * ITEM_WIDTH, - index * ITEM_WIDTH, - ]; + item.id.toString()} + horizontal + showsHorizontalScrollIndicator={false} + decelerationRate={0} + initialNumToRender={1} + bounces={false} + snapToInterval={ITEM_WIDTH} + onScroll={Animated.event( + [{ nativeEvent: { contentOffset: { x: scrollX } } }], + { + useNativeDriver: true, + } + )} + renderItem={({ item, index }) => { + if (item.id === -1 || item.id === -2) { + return ; + } + const inputRange = [ + (index - 2) * ITEM_WIDTH, + (index - 1) * ITEM_WIDTH, + index * ITEM_WIDTH, + ]; - const translateY = scrollX.interpolate({ - inputRange, - outputRange: [100, 0, 100], - }); + const translateY = scrollX.interpolate({ + inputRange, + outputRange: [100, 0, 100], + }); - const opacity = scrollX.interpolate({ - inputRange, - outputRange: [0.6, 1, 0.6], - }); - const scale = scrollX.interpolate({ - inputRange, - outputRange: [0.8, 1, 0.8], - }); - return ( - { - if (item.id !== -1 && item.id !== -2) { - onPress && onPress(item.id); - } - } - } - /> - ); - }} - /> + const opacity = scrollX.interpolate({ + inputRange, + outputRange: [0.6, 1, 0.6], + }); + const scale = scrollX.interpolate({ + inputRange, + outputRange: [0.8, 1, 0.8], + }); + return ( + { + if (item.id !== -1 && item.id !== -2) { + onPress && onPress(item.id); + } + }} + /> + ); + }} + /> ); }; diff --git a/mobile/src/common/components/caroussel/caroussel_tile.tsx b/mobile/src/common/components/caroussel/caroussel_tile.tsx index 65a61985..e4caa023 100644 --- a/mobile/src/common/components/caroussel/caroussel_tile.tsx +++ b/mobile/src/common/components/caroussel/caroussel_tile.tsx @@ -9,6 +9,7 @@ import { } from "react-native"; import { PlaceInfoEntity } from "../../../domain/entities/place_info_entity"; import { Link } from "expo-router"; +import { ITEM_HEIGHT, ITEM_WIDTH } from "../../constants/caroussel"; interface CarousselTileProps { onPress?: () => void; @@ -18,10 +19,6 @@ interface CarousselTileProps { opacity: Animated.AnimatedInterpolation; } -const ITEM_WIDTH = Dimensions.get("window").width * 0.7; -const BLANK_ITEM_WIDTH = Dimensions.get("window").width * 0.15; -const ITEM_HEIGHT = Dimensions.get("window").height * 0.7; - export const CarousselTile = memo( ({ translateY, scale, opacity, item, onPress }: CarousselTileProps) => { return ( diff --git a/mobile/src/common/constants/caroussel.ts b/mobile/src/common/constants/caroussel.ts new file mode 100644 index 00000000..b508be41 --- /dev/null +++ b/mobile/src/common/constants/caroussel.ts @@ -0,0 +1,7 @@ +import { Dimensions } from "react-native"; + +export const CARROUSEL_HEIGHT = Dimensions.get("window").height * 0.5; +export const CARROUSEL_WIDTH = Dimensions.get("window").width; +export const ITEM_WIDTH = CARROUSEL_WIDTH * 0.8; +export const BLANK_ITEM_WIDTH = CARROUSEL_WIDTH * 0.1; +export const ITEM_HEIGHT = CARROUSEL_HEIGHT * 0.7; \ No newline at end of file -- GitLab From 52f022cbcd85a9ec0d28a39a7f636ad753a9ee46 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:09:55 -0600 Subject: [PATCH 13/22] Se agregaron las categorias reales a una actividad y se eliminaron las de prueba --- .../components/activity_bottom_sheet/activity_bottom_sheet.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/components/activity_bottom_sheet/activity_bottom_sheet.tsx b/mobile/src/components/activity_bottom_sheet/activity_bottom_sheet.tsx index 4fd826d2..ae97e81a 100644 --- a/mobile/src/components/activity_bottom_sheet/activity_bottom_sheet.tsx +++ b/mobile/src/components/activity_bottom_sheet/activity_bottom_sheet.tsx @@ -58,7 +58,7 @@ export const ActivityBottomSheet = ({ item} ItemSeparatorComponent={() => } -- GitLab From b4ba9495f7a87cd0c3d26637e419874c5a68578b Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:10:37 -0600 Subject: [PATCH 14/22] =?UTF-8?q?Se=20simplific=C3=B3=20la=20l=C3=B3gica?= =?UTF-8?q?=20para=20pasar=20del=20contexto=20de=20produccion=20al=20de=20?= =?UTF-8?q?desarrollo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/common/contexts/data_context.tsx | 51 ++++++++++----------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/mobile/src/common/contexts/data_context.tsx b/mobile/src/common/contexts/data_context.tsx index 85b25dee..1dc6dc08 100644 --- a/mobile/src/common/contexts/data_context.tsx +++ b/mobile/src/common/contexts/data_context.tsx @@ -43,37 +43,32 @@ const DataContext = createContext({ profileRepository: null }); +const getProductionContext = (language: string): DataContextType => { + return { + statesRepository: new StateRepositoryImpl(new StateDataSourceProd(language)), + authRepository: new AuthRepositoryImpl(new AuthDatasourceProd()), + activityRepository: new ActivityRepositoryDev(new ActivityDatasourceProd()), + travelRepository: new TravelRepositoryImpl(new TravelDatasourceDev()), + routeRepository: new RouteRepositoryImpl(new RouteDataSourceDev()), + profileRepository: new ProfileRepositoryImpl(new ProfileDataSourceProd(language)) + }; +} + +const getDevelopmentContext = (): DataContextType => { + return { + statesRepository: new StateRepositoryImpl(new StateDataSourceDev()), + authRepository: new AuthRepositoryImpl(new AuthDataSourceDev()), + activityRepository: new ActivityRepositoryDev(new ActivityDatasourceDev()), + travelRepository: new TravelRepositoryImpl(new TravelDatasourceDev()), + routeRepository: new RouteRepositoryImpl(new RouteDataSourceDev()), + profileRepository: new ProfileRepositoryImpl(new ProfileDataSourceDev()) + }; +} + export const DataContextProvider = ({ children }: DataContextProviderProps) => { const { i18n:{ language } } = useTranslation(); - const statesDataSource = new StateDataSourceDev(); - //const statesDataSource = new StateDataSourceProd(language); - const statesRepository = new StateRepositoryImpl(statesDataSource); - // - const authDataSource = new AuthDataSourceDev(); - //const authDataSource = new AuthDatasourceProd(); - const authRepository = new AuthRepositoryImpl(authDataSource); - // - const activityDataSource = new ActivityDatasourceDev(); - //const activityDataSource = new ActivityDatasourceProd(); - const activityRepository = new ActivityRepositoryDev(activityDataSource); - // - const travelDatasource = new TravelDatasourceDev(); - const travelRepository = new TravelRepositoryImpl(travelDatasource); - // - const routeDatasource = new RouteDataSourceDev(); - const routeRepository = new RouteRepositoryImpl(routeDatasource); - // - const profileDataSource = new ProfileDataSourceProd(); - const profileRepository = new ProfileRepositoryImpl(profileDataSource); - const value = { - statesRepository, - authRepository, - activityRepository, - travelRepository, - routeRepository, - profileRepository - }; + const value = getDevelopmentContext(); return ( -- GitLab From 8bbca92bf1fdc5ee0207ac796e0923b01e134dbe Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:11:17 -0600 Subject: [PATCH 15/22] =?UTF-8?q?Se=20agregaron=20las=20categor=C3=ADas=20?= =?UTF-8?q?a=20la=20tarjeta=20de=20una=20actividad?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/activity_tile/activity_tile.tsx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/mobile/src/components/activity_tile/activity_tile.tsx b/mobile/src/components/activity_tile/activity_tile.tsx index bea8a19d..73471a4d 100644 --- a/mobile/src/components/activity_tile/activity_tile.tsx +++ b/mobile/src/components/activity_tile/activity_tile.tsx @@ -1,6 +1,7 @@ import { View, Text, StyleSheet, Image, TouchableOpacity } from "react-native"; import { ActivityInfoEntity } from "../../domain/entities/activity_info_entity"; import { LIGHT_THEME } from "../../common/constants/theme"; +import { ScrollView } from "react-native-gesture-handler"; interface ActivityTileProps { activity: ActivityInfoEntity; @@ -21,6 +22,11 @@ export const ActivityTile = ({ activity, onPress }: ActivityTileProps) => { {activity.name} {activity.location} + + { + activity.tags?.map(tag => {tag}) + } + ); @@ -28,7 +34,7 @@ export const ActivityTile = ({ activity, onPress }: ActivityTileProps) => { const styles = StyleSheet.create({ container: { - height: 300, + height: 320, width: "100%", backgroundColor: LIGHT_THEME.color.white, elevation: 5, @@ -44,4 +50,13 @@ const styles = StyleSheet.create({ fontSize: 18, fontWeight: "bold", }, + tag: { + backgroundColor: LIGHT_THEME.color.primary, + color: LIGHT_THEME.color.white, + height: 30, + paddingVertical: 5, + paddingHorizontal: 10, + borderRadius: 15, + marginHorizontal: 5, + }, }); -- GitLab From 4dcf8038d36f9f7892e3c286e0d77db6d0ce7c36 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:12:15 -0600 Subject: [PATCH 16/22] =?UTF-8?q?Se=20agregaron=20las=20categorias=20a=20l?= =?UTF-8?q?a=20funcion=20que=20transforma=20de=20modelo=20de=20api=20a=20e?= =?UTF-8?q?ntidad=20de=20aplicaci=C3=B3n=20para=20las=20actividades?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/infrastructure/utils/place_utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mobile/src/infrastructure/utils/place_utils.ts b/mobile/src/infrastructure/utils/place_utils.ts index 3e16b116..d0937a3b 100644 --- a/mobile/src/infrastructure/utils/place_utils.ts +++ b/mobile/src/infrastructure/utils/place_utils.ts @@ -10,6 +10,6 @@ export const placeModelToEntity = (placeModel: ActivityModel): ActivityInfoEntit location: placeModel.coords, townId: placeModel.idTown, available: 'open', - tags: undefined, + tags: placeModel.categories?.map(tag => tag.name) || undefined, } } \ No newline at end of file -- GitLab From a21cbc70e3755b51dfd911c286a476680f4b6f45 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:13:31 -0600 Subject: [PATCH 17/22] =?UTF-8?q?Se=20agreg=C3=B3=20una=20funcion=20que=20?= =?UTF-8?q?transforma=20de=20modelo=20de=20api=20a=20entidad=20de=20aplica?= =?UTF-8?q?ci=C3=B3n=20para=20las=20categor=C3=ADas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/infrastructure/utils/category.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 mobile/src/profile/infrastructure/utils/category.ts diff --git a/mobile/src/profile/infrastructure/utils/category.ts b/mobile/src/profile/infrastructure/utils/category.ts new file mode 100644 index 00000000..2b51d315 --- /dev/null +++ b/mobile/src/profile/infrastructure/utils/category.ts @@ -0,0 +1,8 @@ +import { IOption } from "../../../common/domain/entities/option"; +import { CategoryModel } from "../model/categorie_model"; + +export const categoryModelToOption = (category: CategoryModel): IOption => ({ + id: category.idCategory, + name: category.name, + isSelected: false, +}); -- GitLab From c43dcf6f0df09e6a96f7d7cef0a2ae0dbbfcd2d1 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:14:47 -0600 Subject: [PATCH 18/22] =?UTF-8?q?Se=20cre=C3=B3=20un=20hook=20para=20cambi?= =?UTF-8?q?ar=20los=20intereses=20del=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/profile/hooks/useChangeInterests.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 mobile/src/profile/hooks/useChangeInterests.ts diff --git a/mobile/src/profile/hooks/useChangeInterests.ts b/mobile/src/profile/hooks/useChangeInterests.ts new file mode 100644 index 00000000..cb1449f7 --- /dev/null +++ b/mobile/src/profile/hooks/useChangeInterests.ts @@ -0,0 +1,33 @@ +import { useEffect, useState } from "react"; +import { useGetInterests } from "./useGetInterests"; +import { IOption } from "../../common/domain/entities/option"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; +import { useDataContext } from "../../common/contexts/data_context"; + + +export const useChangeInterests = () => { + const { profileRepository } = useDataContext(); + const [interests, setInterests] = useState([]); + + const toogleInterest = (id: number) => { + const newInterests = interests.map((interest) => { + if (interest.id === id) { + return { ...interest, isSelected: !interest.isSelected }; + } + return interest; + }); + setInterests(newInterests); + }; + + const onSubmit = async () => { + const selectedInterests = interests + .filter((interest) => interest.isSelected); + await profileRepository!.saveInterests(selectedInterests); + }; + + const setAllInterests = (interests: IOption[]) => { + setInterests(interests); + }; + + return { toogleInterest, interests, onSubmit, setAllInterests }; +}; -- GitLab From dddb7e42e7fc3b719649667e87540cb6122ef41a Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:16:13 -0600 Subject: [PATCH 19/22] =?UTF-8?q?Se=20cre=C3=B3=20un=20hook=20para=20actua?= =?UTF-8?q?lizar=20los=20intereses=20del=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/profile/hooks/useUpdateInterests.ts | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 mobile/src/profile/hooks/useUpdateInterests.ts diff --git a/mobile/src/profile/hooks/useUpdateInterests.ts b/mobile/src/profile/hooks/useUpdateInterests.ts new file mode 100644 index 00000000..fdee8444 --- /dev/null +++ b/mobile/src/profile/hooks/useUpdateInterests.ts @@ -0,0 +1,51 @@ +import { useEffect, useState } from "react"; +import { useChangeInterests } from "./useChangeInterests"; +import { useGetUserInterests } from "./useGetUserInterests"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; +import { useGetInterests } from "./useGetInterests"; +import { router } from "expo-router"; + +export const useUpdateInterests = () => { + const { data: userCategories, requestStatus: userInterestsRequest } = + useGetUserInterests(); + const { interests: allCategories, requestStatus: changeInterestsRequest } = + useGetInterests(); + const { + interests, + toogleInterest, + onSubmit: onSubmitInterests, + setAllInterests, + } = useChangeInterests(); + const [requestStatus, setRequestStatus] = useState( + ApiRequestStatus.LOADING + ); + + useEffect(() => { + const requests = [changeInterestsRequest, userInterestsRequest]; + if (requests.every((request) => request === ApiRequestStatus.SUCCESS)) { + setAllInterests( + allCategories!.map((category) => ({ + ...category, + isSelected: userCategories!.some( + (userCategory) => userCategory.id === category.id + ), + })) + ); + setRequestStatus(ApiRequestStatus.SUCCESS); + } + }, [changeInterestsRequest, userInterestsRequest]); + + const onSubmit = async () => { + /* await handleSubmit((data) => { + + })(); */ + + try { + await onSubmitInterests(); + router.back(); + } catch (error) { + console.log(error); + } + }; + return { onSubmit, toogleInterest, interests, requestStatus }; +}; -- GitLab From 2072a38da94b28deaa23c74f84f5b9df0b9e1c0b Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:17:10 -0600 Subject: [PATCH 20/22] =?UTF-8?q?Se=20cre=C3=B3=20un=20hook=20para=20inici?= =?UTF-8?q?alizar=20los=20datos=20del=20usuario?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/profile/hooks/useSetUpProfile.ts | 53 ++++++++++----------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/mobile/src/profile/hooks/useSetUpProfile.ts b/mobile/src/profile/hooks/useSetUpProfile.ts index 9acb8838..bc04cd8a 100644 --- a/mobile/src/profile/hooks/useSetUpProfile.ts +++ b/mobile/src/profile/hooks/useSetUpProfile.ts @@ -6,6 +6,7 @@ import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { useDataContext } from "../../common/contexts/data_context"; import { useSetUp } from "../../common/contexts/set_up_context"; import { router } from "expo-router"; +import { useChangeInterests } from "./useChangeInterests"; export type SetUpProfileFormValues = { interests: number[]; @@ -13,38 +14,34 @@ export type SetUpProfileFormValues = { }; export const useSetUpProfile = () => { - const { control, handleSubmit, setValue } = useForm(); - const { setFirstTime } = useSetUp(); - const { interests: allCategories, requestStatus } = useGetInterests(); - // TODO: Si se agregan mas campos que requieran datos de la API, debemos procurar que todos los request status esten en success - const [interests, setInterests] = useState([]); + const { interests: allCategories, requestStatus: changeInterestsRequest } = useGetInterests(); + const { interests, toogleInterest, onSubmit: onSubmitInterests, setAllInterests } = useChangeInterests(); + const [requestStatus, setRequestStatus] = useState(ApiRequestStatus.LOADING); + // const { control, handleSubmit, setValue, getValues } = useForm(); + const { setFirstTime } = useSetUp(); + useEffect(() => { - if (requestStatus === ApiRequestStatus.SUCCESS && allCategories && allCategories.length > 0) { - setInterests([...allCategories]); + const requests = [changeInterestsRequest]; + if (requests.every((request) => request === ApiRequestStatus.SUCCESS)) { + setAllInterests(allCategories!); + setRequestStatus(ApiRequestStatus.SUCCESS); } - }, [requestStatus]); - - const toogleInterest = (id: number) => { - console.log("toogle"); - const newInterests = interests.map((interest) => { - if (interest.id === id) { - return { ...interest, isSelected: !interest.isSelected }; - } - return interest; - }); - setInterests(newInterests); - }; + }, [changeInterestsRequest]); + const onSubmit = async () => { - setValue("interests", interests.filter((interest) => interest.isSelected).map((interest) => interest.id)); - await handleSubmit((data) => { - //TODO: Implementar la logica de envio de datos - //TODO: Verificar si se enviará la fecha de nacimiento y los intereses en el mismo request o por separado - console.log(data); - })(); - await setFirstTime(); - router.replace("(tabs)"); +/* await handleSubmit((data) => { + + })(); */ + + try { + await onSubmitInterests(); + await setFirstTime(); + router.replace("/(tabs)"); + } catch (error) { + console.log(error); + } }; - return { control, onSubmit, toogleInterest, interests, requestStatus }; + return { onSubmit, toogleInterest, interests, requestStatus }; }; -- GitLab From d351007610b8a2f241d02f66960bfe9fe401f71a Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:17:48 -0600 Subject: [PATCH 21/22] =?UTF-8?q?Se=20cambiaron=20los=20datos=20de=20prueb?= =?UTF-8?q?a=20por=20los=20hooks=20que=20proporcionan=20la=20informaci?= =?UTF-8?q?=C3=B3n=20real?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screens/change_interests_screen.tsx | 102 +++--------------- 1 file changed, 17 insertions(+), 85 deletions(-) diff --git a/mobile/src/profile/screens/change_interests_screen.tsx b/mobile/src/profile/screens/change_interests_screen.tsx index c08f54de..0f647bac 100644 --- a/mobile/src/profile/screens/change_interests_screen.tsx +++ b/mobile/src/profile/screens/change_interests_screen.tsx @@ -3,98 +3,30 @@ import { LIGHT_THEME } from "../../common/constants/theme"; import { ScrollView } from "react-native-gesture-handler"; import { useState } from "react"; import { MultipleOptionPicker } from "../components/multiple_option_pickeer"; +import { useUpdateInterests } from "../hooks/useUpdateInterests"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; +import { InterestSlide } from "../components/interest_slide"; +import { SlideControl } from "../../common/components/slide_control"; export const ChangeInterestsScreen = () => { - const [options, setOptions] = useState( [ - { - id: 1, - name: "Arquitectura", - isSelected: false, - }, - { - id: 2, - name: "Ciencia", - isSelected: false, - }, - { - id: 3, - name: "Cultura", - isSelected: false, - }, - { - id: 4, - name: "Deportes", - isSelected: false, - }, - { - id: 5, - name: "Economía", - isSelected: false, - }, - { - id: 6, - name: "Educación", - isSelected: false, - }, - { - id: 7, - name: "Entretenimiento", - isSelected: false, - }, - { - id: 8, - name: "Gastronomía", - isSelected: false, - }, - { - id: 9, - name: "Historia", - isSelected: false, - }, - { - id: 10, - name: "Moda", - isSelected: false, - }, - { - id: 11, - name: "Música", - isSelected: false, - }, - { - id: 12, - name: "Política", - isSelected: false, - }, - { - id: 13, - name: "Salud", - isSelected: false, - }, - { - id: 14, - name: "Tecnología", - isSelected: false, - }, - ]); + const { toogleInterest: onToogleOption, interests: options, requestStatus, onSubmit } = useUpdateInterests(); + if (requestStatus === ApiRequestStatus.LOADING) { + return Loading...; + } - const onToogleOption = (optionId: number) => { - setOptions( - options.map((option) => - option.id === optionId - ? { ...option, isSelected: !option.isSelected } - : option - ) - ); - }; + if (requestStatus === ApiRequestStatus.ERROR) { + return Error; + } + + const onFinish = () => { + onSubmit(); + } return ( - - {`Selecciona las categorías que te interesan, puedes cambiarlos en la pestaña de cuenta > Cambiar intereses`} - - + + {}} onPrevious={() => {}} isFirst isLast /> ); }; -- GitLab From dd96bc9b5dc3761000ea93af933cba0b13868c09 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 16 Aug 2024 20:18:15 -0600 Subject: [PATCH 22/22] =?UTF-8?q?Actualizaci=C3=B3n=20de=20dependencias?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/package-lock.json | 9 +++++++++ mobile/package.json | 3 ++- mobile/src/profile/hooks/useSelectInterests.ts | 0 3 files changed, 11 insertions(+), 1 deletion(-) delete mode 100644 mobile/src/profile/hooks/useSelectInterests.ts diff --git a/mobile/package-lock.json b/mobile/package-lock.json index e1b43956..0145b231 100644 --- a/mobile/package-lock.json +++ b/mobile/package-lock.json @@ -21,6 +21,7 @@ "expo-checkbox": "~2.7.0", "expo-constants": "~15.4.5", "expo-image-picker": "~14.7.1", + "expo-linear-gradient": "~12.7.2", "expo-linking": "~6.2.2", "expo-localization": "~14.8.4", "expo-router": "~3.4.8", @@ -8869,6 +8870,14 @@ "expo": "*" } }, + "node_modules/expo-linear-gradient": { + "version": "12.7.2", + "resolved": "https://registry.npmjs.org/expo-linear-gradient/-/expo-linear-gradient-12.7.2.tgz", + "integrity": "sha512-Wwb2EF18ywgrlTodcXJ6Yt/UEcKitRMdXPNyP/IokmeKh4emoq9DxZJpZdkXm3HUTLlbRpi6/t32jrFVqXB9AQ==", + "peerDependencies": { + "expo": "*" + } + }, "node_modules/expo-linking": { "version": "6.2.2", "resolved": "https://registry.npmjs.org/expo-linking/-/expo-linking-6.2.2.tgz", diff --git a/mobile/package.json b/mobile/package.json index bb5ccad6..1afc8f73 100644 --- a/mobile/package.json +++ b/mobile/package.json @@ -43,7 +43,8 @@ "react-native-screens": "~3.29.0", "react-native-svg": "14.1.0", "@react-native-picker/picker": "2.6.1", - "@react-native-async-storage/async-storage": "1.21.0" + "@react-native-async-storage/async-storage": "1.21.0", + "expo-linear-gradient": "~12.7.2" }, "devDependencies": { "@babel/core": "^7.20.0", diff --git a/mobile/src/profile/hooks/useSelectInterests.ts b/mobile/src/profile/hooks/useSelectInterests.ts deleted file mode 100644 index e69de29b..00000000 -- GitLab