From bb44e6e9669172324afecc5facea28aad99aee5f Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Mon, 13 May 2024 19:31:06 -0600 Subject: [PATCH 1/5] =?UTF-8?q?Reestructura=20de=20la=20arquitectura=20de?= =?UTF-8?q?=20la=20aplicaci=C3=B3n=20mobile?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/App.tsx | 2 +- mobile/app/(tabs)/_layout.tsx | 4 +- mobile/app/(tabs)/account.tsx | 2 +- mobile/app/(tabs)/index.tsx | 2 +- mobile/app/_layout.tsx | 12 ++-- mobile/app/sign_up.tsx | 2 +- .../town/[townId]/activity/_layout.tsx | 2 +- mobile/app/state/[stateId]/town/_layout.tsx | 2 +- mobile/app/state/_layout.tsx | 2 +- mobile/app/travel_history/_layout.tsx | 2 +- .../screens}/account_page.tsx | 6 +- mobile/src/auth/components/login_form.tsx | 2 +- mobile/src/auth/components/sign_up_form.tsx | 2 +- .../src/{ => auth}/contexts/auth_context.tsx | 0 .../domain/datasources/auth_datasource.ts | 0 .../domain/entities/login_info_entity.ts | 0 .../domain/entities/register_info.ts | 0 .../domain/entities/user_info_entity.ts | 0 .../domain/repositories/auth_repository.ts | 0 mobile/src/auth/hooks/useLoggin.ts | 4 +- mobile/src/auth/hooks/useSignUp.ts | 4 +- .../dev/datasources}/auth_datasource.ts | 0 .../prod/datasources}/auth_datasource.ts | 8 +-- .../prod/models}/login_user_model.ts | 0 .../prod/models}/register_user_model.ts | 0 .../prod}/repositories/auth_repository.ts | 8 +-- .../infrastructure/prod/utils}/user_util.ts | 2 +- mobile/src/auth/pages/login_page.tsx | 4 +- mobile/src/common/components/audio_player.tsx | 4 +- .../components}/circle_avatar.tsx | 0 .../common/components/custom_tile_button.tsx | 3 +- .../components}/floating_back_button.tsx | 0 .../common/components/form/or_division.tsx | 2 +- .../src/common/components/form/text_input.tsx | 2 +- mobile/src/common/constants/api.ts | 1 + .../constants/api_request_states.ts | 0 mobile/src/{ => common}/constants/theme.ts | 0 .../{ => common}/contexts/audio_context.tsx | 0 .../activity_bottom_sheet.tsx | 2 +- .../activity_tile/activity_tile.tsx | 2 +- mobile/src/constants/api.ts | 1 - mobile/src/contexts/data_context.tsx | 62 ------------------- mobile/src/hooks/useGet.ts | 2 +- mobile/src/hooks/useGetActivities.ts | 2 +- mobile/src/hooks/useGetActivityInfo.ts | 2 +- mobile/src/hooks/useGetActivityPoint.ts | 2 +- mobile/src/hooks/useGetStates.ts | 2 +- mobile/src/hooks/useGetTowns.ts | 2 +- mobile/src/hooks/useGetTravelDetails.ts | 2 +- mobile/src/hooks/useGetTravelHistory.ts | 10 ++- .../components}/language_icon.tsx | 2 +- .../activity_description_page.tsx | 6 +- .../screens/activity_point/activity_point.tsx | 19 +++--- .../edit_profile/edit_profile_page.tsx | 6 +- mobile/src/screens/page_styles.tsx | 2 +- .../state_selection/state_selection_page.tsx | 2 +- .../town_activities/town_activities_page.tsx | 30 +++------ .../town_selection/town_selection_page.tsx | 2 +- .../travel_details/travel_details_page.tsx | 2 +- .../travel_history/travel_history_page.tsx | 46 ++++++++++---- 60 files changed, 121 insertions(+), 171 deletions(-) rename mobile/src/{screens/account => account/screens}/account_page.tsx (90%) rename mobile/src/{ => auth}/contexts/auth_context.tsx (100%) rename mobile/src/{ => auth}/domain/datasources/auth_datasource.ts (100%) rename mobile/src/{ => auth}/domain/entities/login_info_entity.ts (100%) rename mobile/src/{ => auth}/domain/entities/register_info.ts (100%) rename mobile/src/{ => auth}/domain/entities/user_info_entity.ts (100%) rename mobile/src/{ => auth}/domain/repositories/auth_repository.ts (100%) rename mobile/src/{infrastructure/datasource/dev => auth/infrastructure/dev/datasources}/auth_datasource.ts (100%) rename mobile/src/{infrastructure/datasource/prod => auth/infrastructure/prod/datasources}/auth_datasource.ts (87%) rename mobile/src/{infrastructure/models/prod => auth/infrastructure/prod/models}/login_user_model.ts (100%) rename mobile/src/{infrastructure/models/prod => auth/infrastructure/prod/models}/register_user_model.ts (100%) rename mobile/src/{infrastructure => auth/infrastructure/prod}/repositories/auth_repository.ts (53%) rename mobile/src/{infrastructure/utils/prod => auth/infrastructure/prod/utils}/user_util.ts (82%) rename mobile/src/{components/circle_avatar => common/components}/circle_avatar.tsx (100%) rename mobile/src/{components/floating_back_button => common/components}/floating_back_button.tsx (100%) create mode 100644 mobile/src/common/constants/api.ts rename mobile/src/{ => common}/constants/api_request_states.ts (100%) rename mobile/src/{ => common}/constants/theme.ts (100%) rename mobile/src/{ => common}/contexts/audio_context.tsx (100%) delete mode 100644 mobile/src/constants/api.ts delete mode 100644 mobile/src/contexts/data_context.tsx rename mobile/src/{components/language_icon => lang/components}/language_icon.tsx (91%) diff --git a/mobile/App.tsx b/mobile/App.tsx index 1f252495..d41dfd91 100644 --- a/mobile/App.tsx +++ b/mobile/App.tsx @@ -1,7 +1,7 @@ import { StatusBar } from 'expo-status-bar'; import { StyleSheet, Text, View } from 'react-native'; import { StateSelectionPage } from './src/screens/state_selection/state_selection_page'; -import { DataContextProvider } from './src/contexts/data_context'; +import { DataContextProvider } from './src/common/contexts/data_context'; export default function App() { return ( diff --git a/mobile/app/(tabs)/_layout.tsx b/mobile/app/(tabs)/_layout.tsx index 8a503eb8..1081d4af 100644 --- a/mobile/app/(tabs)/_layout.tsx +++ b/mobile/app/(tabs)/_layout.tsx @@ -1,8 +1,8 @@ import { Redirect, Tabs } from "expo-router"; import { Ionicons } from "@expo/vector-icons"; import { FontAwesome5 } from "@expo/vector-icons"; -import { LIGTHT_THEME } from "../../src/constants/theme"; -import { useAuth } from "../../src/contexts/auth_context"; +import { LIGTHT_THEME } from "../../src/common/constants/theme"; +import { useAuth } from "../../src/auth/contexts/auth_context"; export default function Layout() { const { user } = useAuth(); diff --git a/mobile/app/(tabs)/account.tsx b/mobile/app/(tabs)/account.tsx index 64a31b26..96163b6c 100644 --- a/mobile/app/(tabs)/account.tsx +++ b/mobile/app/(tabs)/account.tsx @@ -1,4 +1,4 @@ -import { AccountPage } from "../../src/screens/account/account_page"; +import { AccountPage } from "../../src/account/screens/account_page"; export default function AccountScreen() { return ( diff --git a/mobile/app/(tabs)/index.tsx b/mobile/app/(tabs)/index.tsx index 9c27cc41..e29e42d6 100644 --- a/mobile/app/(tabs)/index.tsx +++ b/mobile/app/(tabs)/index.tsx @@ -1,4 +1,4 @@ -import { DataContextProvider } from '../../src/contexts/data_context'; +import { DataContextProvider } from '../../src/common/contexts/data_context'; import { StateSelectionPage } from '../../src/screens/state_selection/state_selection_page'; export default function Main () { return ( diff --git a/mobile/app/_layout.tsx b/mobile/app/_layout.tsx index aaff8dba..0024ab5e 100644 --- a/mobile/app/_layout.tsx +++ b/mobile/app/_layout.tsx @@ -1,10 +1,10 @@ import { Stack, Tabs } from "expo-router"; -import { DataContextProvider } from "../src/contexts/data_context"; -import { LIGTHT_THEME } from "../src/constants/theme"; -import { AuthContextProvider, useAuth } from "../src/contexts/auth_context"; +import { DataContextProvider } from "../src/common/contexts/data_context"; +import { LIGTHT_THEME } from "../src/common/constants/theme"; +import { AuthContextProvider, useAuth } from "../src/auth/contexts/auth_context"; import { ActivityIndicator } from "react-native"; import { GestureHandlerRootView } from "react-native-gesture-handler"; -import { AudioContextProvider } from "../src/contexts/audio_context"; +import { AudioContextProvider } from "../src/common/contexts/audio_context"; export default function Root() { return ( @@ -82,6 +82,10 @@ const MainLayout = () => { headerShown: false, statusBarColor: LIGTHT_THEME.color.primary, }}/> + ); }; diff --git a/mobile/app/sign_up.tsx b/mobile/app/sign_up.tsx index 26e0aa2b..0d279953 100644 --- a/mobile/app/sign_up.tsx +++ b/mobile/app/sign_up.tsx @@ -1,5 +1,5 @@ import { View, StyleSheet, Image, Text, Button } from "react-native"; -import { LIGTHT_THEME } from "../src/constants/theme"; +import { LIGTHT_THEME } from "../src/common/constants/theme"; import { SignUpForm } from "../src/auth/components/sign_up_form"; import { router } from "expo-router"; const loginImage = require("../assets/login-image.jpg"); diff --git a/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx b/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx index e7b5dee5..38d73fd4 100644 --- a/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx +++ b/mobile/app/state/[stateId]/town/[townId]/activity/_layout.tsx @@ -1,5 +1,5 @@ import { Stack } from "expo-router"; -import { LIGTHT_THEME } from "../../../../../../src/constants/theme"; +import { LIGTHT_THEME } from "../../../../../../src/common/constants/theme"; export default function ActivitySelectionScreen() { return ( diff --git a/mobile/app/state/[stateId]/town/_layout.tsx b/mobile/app/state/[stateId]/town/_layout.tsx index b7875621..fe283a44 100644 --- a/mobile/app/state/[stateId]/town/_layout.tsx +++ b/mobile/app/state/[stateId]/town/_layout.tsx @@ -1,5 +1,5 @@ import { Stack } from "expo-router"; -import { LIGTHT_THEME } from "../../../../src/constants/theme"; +import { LIGTHT_THEME } from "../../../../src/common/constants/theme"; export default function Layout() { return ( diff --git a/mobile/app/state/_layout.tsx b/mobile/app/state/_layout.tsx index 4394434c..281241a1 100644 --- a/mobile/app/state/_layout.tsx +++ b/mobile/app/state/_layout.tsx @@ -1,5 +1,5 @@ import { Stack } from "expo-router"; -import { LIGTHT_THEME } from "../../src/constants/theme"; +import { LIGTHT_THEME } from "../../src/common/constants/theme"; export default function Layout() { return ( diff --git a/mobile/app/travel_history/_layout.tsx b/mobile/app/travel_history/_layout.tsx index 0290a744..11108a21 100644 --- a/mobile/app/travel_history/_layout.tsx +++ b/mobile/app/travel_history/_layout.tsx @@ -1,5 +1,5 @@ import { Stack } from "expo-router"; -import { LIGTHT_THEME } from "../../src/constants/theme"; +import { LIGTHT_THEME } from "../../src/common/constants/theme"; import { Button } from "react-native"; import { ShareButton } from "../../src/travel_history/components/share_button"; diff --git a/mobile/src/screens/account/account_page.tsx b/mobile/src/account/screens/account_page.tsx similarity index 90% rename from mobile/src/screens/account/account_page.tsx rename to mobile/src/account/screens/account_page.tsx index 205d8ae9..229cd721 100644 --- a/mobile/src/screens/account/account_page.tsx +++ b/mobile/src/account/screens/account_page.tsx @@ -6,8 +6,8 @@ import { Touchable, TouchableOpacity, } from "react-native"; -import { useAuth } from "../../contexts/auth_context"; -import { CircleAvatar } from "../../components/circle_avatar/circle_avatar"; +import { useAuth } from "../../auth/contexts/auth_context"; +import { CircleAvatar } from "../../common/components/circle_avatar"; import { MaterialIcons, MaterialCommunityIcons, @@ -15,7 +15,7 @@ import { } from "@expo/vector-icons"; import { CustomTileButton } from "../../common/components/custom_tile_button"; import { router } from "expo-router"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; //TODO: Add source to CircleAvatar const source = require("../../../assets/avatar.png"); diff --git a/mobile/src/auth/components/login_form.tsx b/mobile/src/auth/components/login_form.tsx index 0e0b55ba..4e73840b 100644 --- a/mobile/src/auth/components/login_form.tsx +++ b/mobile/src/auth/components/login_form.tsx @@ -1,7 +1,7 @@ import { Control, Controller, FieldValues } from "react-hook-form"; import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from "react-native"; import { CustomTextInput } from "../../common/components/form/text_input"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; import { LoginFormValues } from "../hooks/useLoggin"; import { OrDivision } from "../../common/components/form/or_division"; import { LANG } from "../../lang/translations"; diff --git a/mobile/src/auth/components/sign_up_form.tsx b/mobile/src/auth/components/sign_up_form.tsx index 9b91b8e3..8ec93be2 100644 --- a/mobile/src/auth/components/sign_up_form.tsx +++ b/mobile/src/auth/components/sign_up_form.tsx @@ -7,7 +7,7 @@ import { View, } from "react-native"; import { CustomTextInput } from "../../common/components/form/text_input"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; import { useLoggin } from "../hooks/useLoggin"; import { OrDivision } from "../../common/components/form/or_division"; import { useSignUp } from "../hooks/useSignUp"; diff --git a/mobile/src/contexts/auth_context.tsx b/mobile/src/auth/contexts/auth_context.tsx similarity index 100% rename from mobile/src/contexts/auth_context.tsx rename to mobile/src/auth/contexts/auth_context.tsx diff --git a/mobile/src/domain/datasources/auth_datasource.ts b/mobile/src/auth/domain/datasources/auth_datasource.ts similarity index 100% rename from mobile/src/domain/datasources/auth_datasource.ts rename to mobile/src/auth/domain/datasources/auth_datasource.ts diff --git a/mobile/src/domain/entities/login_info_entity.ts b/mobile/src/auth/domain/entities/login_info_entity.ts similarity index 100% rename from mobile/src/domain/entities/login_info_entity.ts rename to mobile/src/auth/domain/entities/login_info_entity.ts diff --git a/mobile/src/domain/entities/register_info.ts b/mobile/src/auth/domain/entities/register_info.ts similarity index 100% rename from mobile/src/domain/entities/register_info.ts rename to mobile/src/auth/domain/entities/register_info.ts diff --git a/mobile/src/domain/entities/user_info_entity.ts b/mobile/src/auth/domain/entities/user_info_entity.ts similarity index 100% rename from mobile/src/domain/entities/user_info_entity.ts rename to mobile/src/auth/domain/entities/user_info_entity.ts diff --git a/mobile/src/domain/repositories/auth_repository.ts b/mobile/src/auth/domain/repositories/auth_repository.ts similarity index 100% rename from mobile/src/domain/repositories/auth_repository.ts rename to mobile/src/auth/domain/repositories/auth_repository.ts diff --git a/mobile/src/auth/hooks/useLoggin.ts b/mobile/src/auth/hooks/useLoggin.ts index 802aefdd..5b9d5f3f 100644 --- a/mobile/src/auth/hooks/useLoggin.ts +++ b/mobile/src/auth/hooks/useLoggin.ts @@ -1,7 +1,7 @@ import { set, useForm } from "react-hook-form" -import { useAuth } from "../../contexts/auth_context"; +import { useAuth } from "../contexts/auth_context"; import { Navigator, Redirect, router } from "expo-router"; -import { useDataContext } from "../../contexts/data_context"; +import { useDataContext } from "../../common/contexts/data_context"; export type LoginFormValues = { email: string; diff --git a/mobile/src/auth/hooks/useSignUp.ts b/mobile/src/auth/hooks/useSignUp.ts index 41dbc8a1..cb4ad86d 100644 --- a/mobile/src/auth/hooks/useSignUp.ts +++ b/mobile/src/auth/hooks/useSignUp.ts @@ -1,6 +1,6 @@ import { useForm } from "react-hook-form" -import { useDataContext } from "../../contexts/data_context"; -import { useAuth } from "../../contexts/auth_context"; +import { useDataContext } from "../../common/contexts/data_context"; +import { useAuth } from "../contexts/auth_context"; import { router } from "expo-router"; interface SignUpForm { diff --git a/mobile/src/infrastructure/datasource/dev/auth_datasource.ts b/mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts similarity index 100% rename from mobile/src/infrastructure/datasource/dev/auth_datasource.ts rename to mobile/src/auth/infrastructure/dev/datasources/auth_datasource.ts diff --git a/mobile/src/infrastructure/datasource/prod/auth_datasource.ts b/mobile/src/auth/infrastructure/prod/datasources/auth_datasource.ts similarity index 87% rename from mobile/src/infrastructure/datasource/prod/auth_datasource.ts rename to mobile/src/auth/infrastructure/prod/datasources/auth_datasource.ts index 37714d19..ed25eca4 100644 --- a/mobile/src/infrastructure/datasource/prod/auth_datasource.ts +++ b/mobile/src/auth/infrastructure/prod/datasources/auth_datasource.ts @@ -2,11 +2,11 @@ import axios from "axios"; import { AuthDataSource } from "../../../domain/datasources/auth_datasource"; import { LoginInfoEntity } from "../../../domain/entities/login_info_entity"; import { RegisterInfoEntity } from "../../../domain/entities/register_info"; -import { userRegisterEntityToUserRegisterModel } from "../../utils/prod/user_util"; -import { API_URL } from "../../../constants/api"; -import { LoginUserModel } from "../../models/prod/login_user_model"; +import { userRegisterEntityToUserRegisterModel } from "../utils/user_util"; +import { API_URL } from "../../../../common/constants/api"; +import { LoginUserModel } from "../models/login_user_model"; import { UserInfoEntity } from "../../../domain/entities/user_info_entity"; -import { RegisterResponseModel } from "../../models/prod/register_user_model"; +import { RegisterResponseModel } from "../models/register_user_model"; export class AuthDatasourceProd implements AuthDataSource { login: (email: string, password: string) => Promise = async (email, password) => { diff --git a/mobile/src/infrastructure/models/prod/login_user_model.ts b/mobile/src/auth/infrastructure/prod/models/login_user_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/login_user_model.ts rename to mobile/src/auth/infrastructure/prod/models/login_user_model.ts diff --git a/mobile/src/infrastructure/models/prod/register_user_model.ts b/mobile/src/auth/infrastructure/prod/models/register_user_model.ts similarity index 100% rename from mobile/src/infrastructure/models/prod/register_user_model.ts rename to mobile/src/auth/infrastructure/prod/models/register_user_model.ts diff --git a/mobile/src/infrastructure/repositories/auth_repository.ts b/mobile/src/auth/infrastructure/prod/repositories/auth_repository.ts similarity index 53% rename from mobile/src/infrastructure/repositories/auth_repository.ts rename to mobile/src/auth/infrastructure/prod/repositories/auth_repository.ts index 21ec1df1..abf18b31 100644 --- a/mobile/src/infrastructure/repositories/auth_repository.ts +++ b/mobile/src/auth/infrastructure/prod/repositories/auth_repository.ts @@ -1,7 +1,7 @@ -import { AuthDataSource } from '../../domain/datasources/auth_datasource'; -import { RegisterInfoEntity } from '../../domain/entities/register_info'; -import { UserInfoEntity } from '../../domain/entities/user_info_entity'; -import { AuthRepository } from '../../domain/repositories/auth_repository'; +import { AuthDataSource } from '../../../domain/datasources/auth_datasource'; +import { RegisterInfoEntity } from '../../../domain/entities/register_info'; +import { UserInfoEntity } from '../../../domain/entities/user_info_entity'; +import { AuthRepository } from '../../../domain/repositories/auth_repository'; export class AuthRepositoryImpl implements AuthRepository { constructor(private authDataSource: AuthDataSource) { } diff --git a/mobile/src/infrastructure/utils/prod/user_util.ts b/mobile/src/auth/infrastructure/prod/utils/user_util.ts similarity index 82% rename from mobile/src/infrastructure/utils/prod/user_util.ts rename to mobile/src/auth/infrastructure/prod/utils/user_util.ts index 5ba2220c..f2132714 100644 --- a/mobile/src/infrastructure/utils/prod/user_util.ts +++ b/mobile/src/auth/infrastructure/prod/utils/user_util.ts @@ -1,5 +1,5 @@ import { RegisterInfoEntity } from "../../../domain/entities/register_info"; -import { RegisterUserModel } from "../../models/prod/register_user_model"; +import { RegisterUserModel } from "../models/register_user_model"; export const userRegisterEntityToUserRegisterModel: (user: RegisterInfoEntity) => RegisterUserModel = (user) => { return { diff --git a/mobile/src/auth/pages/login_page.tsx b/mobile/src/auth/pages/login_page.tsx index 4a3750d4..4a2140b2 100644 --- a/mobile/src/auth/pages/login_page.tsx +++ b/mobile/src/auth/pages/login_page.tsx @@ -1,10 +1,10 @@ import { View, Image, StyleSheet, Button } from "react-native"; import { LoginForm } from "../components/login_form"; import { useLoggin } from "../hooks/useLoggin"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; import { router } from "expo-router"; import { LANG } from "../../lang/translations"; -import { LanguageIcon } from "../../components/language_icon/language_icon"; +import { LanguageIcon } from "../../lang/components/language_icon"; const loginImage = require("../../../assets/login-image.jpg"); export const LoginPage = () => { diff --git a/mobile/src/common/components/audio_player.tsx b/mobile/src/common/components/audio_player.tsx index ad8fe1a7..8d68de93 100644 --- a/mobile/src/common/components/audio_player.tsx +++ b/mobile/src/common/components/audio_player.tsx @@ -2,8 +2,8 @@ import { TouchableOpacity, View, StyleSheet, Text } from "react-native"; import { FontAwesome, Feather } from "@expo/vector-icons"; import Slider from "@react-native-community/slider"; import { millisecondsToHourFormat } from "../../utils/time"; -import { LIGTHT_THEME } from "../../constants/theme"; -import { useAudio } from "../../contexts/audio_context"; +import { LIGTHT_THEME } from "../constants/theme"; +import { useAudio } from "../contexts/audio_context"; import { useEffect } from "react"; const audio = require("./../../../assets/audio_prueba.mp3"); diff --git a/mobile/src/components/circle_avatar/circle_avatar.tsx b/mobile/src/common/components/circle_avatar.tsx similarity index 100% rename from mobile/src/components/circle_avatar/circle_avatar.tsx rename to mobile/src/common/components/circle_avatar.tsx diff --git a/mobile/src/common/components/custom_tile_button.tsx b/mobile/src/common/components/custom_tile_button.tsx index 93719b02..501f935b 100644 --- a/mobile/src/common/components/custom_tile_button.tsx +++ b/mobile/src/common/components/custom_tile_button.tsx @@ -1,7 +1,7 @@ import { ReactNode } from "react"; import { TouchableOpacity, View, Text, StyleSheet } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../constants/theme"; interface CustomTileButtonProps { leadingIcon?: ReactNode; @@ -50,6 +50,7 @@ const styles = StyleSheet.create({ alignItems: "flex-start", justifyContent: "space-between", paddingVertical: 10, + minWidth: "50%", maxWidth: "85%", }, diff --git a/mobile/src/components/floating_back_button/floating_back_button.tsx b/mobile/src/common/components/floating_back_button.tsx similarity index 100% rename from mobile/src/components/floating_back_button/floating_back_button.tsx rename to mobile/src/common/components/floating_back_button.tsx diff --git a/mobile/src/common/components/form/or_division.tsx b/mobile/src/common/components/form/or_division.tsx index 4fd16baa..439db1d9 100644 --- a/mobile/src/common/components/form/or_division.tsx +++ b/mobile/src/common/components/form/or_division.tsx @@ -1,5 +1,5 @@ import { View, Text, StyleSheet } from "react-native"; -import { LIGTHT_THEME } from "../../../constants/theme"; +import { LIGTHT_THEME } from "../../constants/theme"; import { LANG } from "../../../lang/translations"; export const OrDivision = () => { diff --git a/mobile/src/common/components/form/text_input.tsx b/mobile/src/common/components/form/text_input.tsx index 55e7e733..4a7ad5a9 100644 --- a/mobile/src/common/components/form/text_input.tsx +++ b/mobile/src/common/components/form/text_input.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef } from "react"; import { TextInput, Text, StyleSheet, View, Animated, TouchableOpacity } from "react-native"; -import { LIGTHT_THEME } from "../../../constants/theme"; +import { LIGTHT_THEME } from "../../constants/theme"; interface TextInputProps { isPassword?: boolean; diff --git a/mobile/src/common/constants/api.ts b/mobile/src/common/constants/api.ts new file mode 100644 index 00000000..1ea7e0ee --- /dev/null +++ b/mobile/src/common/constants/api.ts @@ -0,0 +1 @@ +export const API_URL = 'http://172.18.48.1:3005'; \ No newline at end of file diff --git a/mobile/src/constants/api_request_states.ts b/mobile/src/common/constants/api_request_states.ts similarity index 100% rename from mobile/src/constants/api_request_states.ts rename to mobile/src/common/constants/api_request_states.ts diff --git a/mobile/src/constants/theme.ts b/mobile/src/common/constants/theme.ts similarity index 100% rename from mobile/src/constants/theme.ts rename to mobile/src/common/constants/theme.ts diff --git a/mobile/src/contexts/audio_context.tsx b/mobile/src/common/contexts/audio_context.tsx similarity index 100% rename from mobile/src/contexts/audio_context.tsx rename to mobile/src/common/contexts/audio_context.tsx 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 440756af..acca09e4 100644 --- a/mobile/src/components/activity_bottom_sheet/activity_bottom_sheet.tsx +++ b/mobile/src/components/activity_bottom_sheet/activity_bottom_sheet.tsx @@ -12,7 +12,7 @@ import { TouchableOpacity, } from "react-native"; import { ActivityInfoEntity } from "../../domain/entities/activity_info_entity"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; import { router } from "expo-router"; interface ActivityBottomSheetProps { diff --git a/mobile/src/components/activity_tile/activity_tile.tsx b/mobile/src/components/activity_tile/activity_tile.tsx index 7474be9c..e55cf76b 100644 --- a/mobile/src/components/activity_tile/activity_tile.tsx +++ b/mobile/src/components/activity_tile/activity_tile.tsx @@ -1,6 +1,6 @@ import { View, Text, StyleSheet, Image, TouchableOpacity } from "react-native"; import { ActivityInfoEntity } from "../../domain/entities/activity_info_entity"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; interface ActivityTileProps { activity: ActivityInfoEntity; diff --git a/mobile/src/constants/api.ts b/mobile/src/constants/api.ts deleted file mode 100644 index 8b1c50f9..00000000 --- a/mobile/src/constants/api.ts +++ /dev/null @@ -1 +0,0 @@ -export const API_URL = 'http://192.168.1.83:3005'; \ No newline at end of file diff --git a/mobile/src/contexts/data_context.tsx b/mobile/src/contexts/data_context.tsx deleted file mode 100644 index bc97c510..00000000 --- a/mobile/src/contexts/data_context.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import { createContext, PropsWithChildren, useContext } from "react"; -import { StateRepository } from "../domain/repositories/state_repository"; -import { StateRepositoryImpl } from "../infrastructure/repositories/state_repository"; -import { StateDataSourceDev } from "../infrastructure/datasource/dev/state_datasource"; -import { AuthRepository } from "../domain/repositories/auth_repository"; -import { AuthDataSourceDev } from "../infrastructure/datasource/dev/auth_datasource"; -import { AuthRepositoryImpl } from "../infrastructure/repositories/auth_repository"; -import { AuthDatasourceProd } from "../infrastructure/datasource/prod/auth_datasource"; -import { ActivityRepository } from "../domain/repositories/activity_repository"; -import { ActivityDatasourceDev } from "../infrastructure/datasource/dev/activity_datasource"; -import { ActivityRepositoryDev } from '../infrastructure/repositories/activity_repository'; -import { TravelDatasourceDev } from "../infrastructure/datasource/dev/travel_datasource"; -import { TravelRepositoryImpl } from "../infrastructure/repositories/travel_repository"; -import { TravelRepository } from "../domain/repositories/travel_repository"; - -type DataContextType = { - statesRepository: StateRepository | null; - authRepository: AuthRepository | null; - activityRepository: ActivityRepository | null; - travelRepository: TravelRepository | null; -}; - -type DataContextProviderProps = PropsWithChildren<{}>; - -const DataContext = createContext({ - statesRepository: null, - authRepository: null, - activityRepository: null, - travelRepository: null -}); - -export const DataContextProvider = ({ children }: DataContextProviderProps) => { - const statesDataSource = new StateDataSourceDev(); - const statesRepository = new StateRepositoryImpl(statesDataSource); - const authDataSource = new AuthDataSourceDev(); - const authRepository = new AuthRepositoryImpl(authDataSource); - const activityDataSource = new ActivityDatasourceDev(); - const activityRepository = new ActivityRepositoryDev(activityDataSource); - const travelDatasource = new TravelDatasourceDev(); - const travelRepository = new TravelRepositoryImpl(travelDatasource); - - const value = { - statesRepository, - authRepository, - activityRepository, - travelRepository - }; - - return ( - - {children} - - ); -}; - -export const useDataContext = () => { - const context = useContext(DataContext); - if (!context) { - throw new Error("useDataContext must be used within a DataContextProvider"); - } - return context; -} \ No newline at end of file diff --git a/mobile/src/hooks/useGet.ts b/mobile/src/hooks/useGet.ts index 89f089d1..c2a39765 100644 --- a/mobile/src/hooks/useGet.ts +++ b/mobile/src/hooks/useGet.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import { ApiRequestStatus } from "../constants/api_request_states"; +import { ApiRequestStatus } from "../common/constants/api_request_states"; export const useGet = (callback: () => Promise) => { const [data, setData] = useState(null); diff --git a/mobile/src/hooks/useGetActivities.ts b/mobile/src/hooks/useGetActivities.ts index a71737b3..f6e39305 100644 --- a/mobile/src/hooks/useGetActivities.ts +++ b/mobile/src/hooks/useGetActivities.ts @@ -1,4 +1,4 @@ -import { useDataContext } from "../contexts/data_context"; +import { useDataContext } from "../common/contexts/data_context"; import { ActivityInfoEntity } from "../domain/entities/activity_info_entity"; import { useGet } from "./useGet" diff --git a/mobile/src/hooks/useGetActivityInfo.ts b/mobile/src/hooks/useGetActivityInfo.ts index 8f3f747e..2120efa7 100644 --- a/mobile/src/hooks/useGetActivityInfo.ts +++ b/mobile/src/hooks/useGetActivityInfo.ts @@ -1,4 +1,4 @@ -import { useDataContext } from "../contexts/data_context"; +import { useDataContext } from "../common/contexts/data_context"; import { ActivityInfoEntity } from "../domain/entities/activity_info_entity"; import { useGet } from "./useGet"; diff --git a/mobile/src/hooks/useGetActivityPoint.ts b/mobile/src/hooks/useGetActivityPoint.ts index 151b5f45..10a57b61 100644 --- a/mobile/src/hooks/useGetActivityPoint.ts +++ b/mobile/src/hooks/useGetActivityPoint.ts @@ -1,4 +1,4 @@ -import { useDataContext } from "../contexts/data_context" +import { useDataContext } from "../common/contexts/data_context" import { ActivityPlaceEntity } from "../domain/entities/activity_place_entity"; import { useGet } from "./useGet"; diff --git a/mobile/src/hooks/useGetStates.ts b/mobile/src/hooks/useGetStates.ts index 788aeefc..e098e988 100644 --- a/mobile/src/hooks/useGetStates.ts +++ b/mobile/src/hooks/useGetStates.ts @@ -1,4 +1,4 @@ -import { useDataContext } from "../contexts/data_context"; +import { useDataContext } from "../common/contexts/data_context"; import { StateEntity } from '../domain/entities/state_entity'; import { useGet } from "./useGet" diff --git a/mobile/src/hooks/useGetTowns.ts b/mobile/src/hooks/useGetTowns.ts index 19b233bb..de59d039 100644 --- a/mobile/src/hooks/useGetTowns.ts +++ b/mobile/src/hooks/useGetTowns.ts @@ -1,4 +1,4 @@ -import { useDataContext } from "../contexts/data_context"; +import { useDataContext } from "../common/contexts/data_context"; import { StateEntity } from '../domain/entities/state_entity'; import { TownEntity } from "../domain/entities/town_entity"; import { useGet } from "./useGet" diff --git a/mobile/src/hooks/useGetTravelDetails.ts b/mobile/src/hooks/useGetTravelDetails.ts index cffb20c8..ed3d2cbf 100644 --- a/mobile/src/hooks/useGetTravelDetails.ts +++ b/mobile/src/hooks/useGetTravelDetails.ts @@ -1,4 +1,4 @@ -import { useDataContext } from "../contexts/data_context"; +import { useDataContext } from "../common/contexts/data_context"; import { TravelDetails } from "../domain/entities/travel_details"; import { useGet } from "./useGet"; diff --git a/mobile/src/hooks/useGetTravelHistory.ts b/mobile/src/hooks/useGetTravelHistory.ts index 1d73ddf1..83f43c4b 100644 --- a/mobile/src/hooks/useGetTravelHistory.ts +++ b/mobile/src/hooks/useGetTravelHistory.ts @@ -1,7 +1,11 @@ import { useEffect, useState } from "react"; -import { useDataContext } from "../contexts/data_context" +import { useDataContext } from "../common/contexts/data_context" import { Travel, TravelHistory } from "../domain/entities/travel_history"; import { useGet } from "./useGet"; +export enum TravelHistorySection { + ACTIVE = "Active Travels", + PAST = "Past Travels", +} interface SectionItem { title: string; @@ -19,8 +23,8 @@ export const useGetTravelHistory = () => { const pastTravels = [...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels, ...data.pastTravels,]; const activeTravels = data.activeTravel ? [data.activeTravel] : []; const preparedData = [ - { title: "Active Travels", data: activeTravels }, - { title: "Past Travels", data: pastTravels }, + { title: TravelHistorySection.ACTIVE, data: activeTravels }, + { title: TravelHistorySection.PAST, data: pastTravels }, ]; setPreparedData(preparedData); } diff --git a/mobile/src/components/language_icon/language_icon.tsx b/mobile/src/lang/components/language_icon.tsx similarity index 91% rename from mobile/src/components/language_icon/language_icon.tsx rename to mobile/src/lang/components/language_icon.tsx index 657cb320..c418be68 100644 --- a/mobile/src/components/language_icon/language_icon.tsx +++ b/mobile/src/lang/components/language_icon.tsx @@ -1,6 +1,6 @@ import { Entypo } from '@expo/vector-icons'; import { TouchableOpacity } from 'react-native-gesture-handler'; -import { LANG } from '../../lang/translations'; +import { LANG } from '../translations'; export const LanguageIcon = () => { const changeLanguage = () => { diff --git a/mobile/src/screens/activity_description/activity_description_page.tsx b/mobile/src/screens/activity_description/activity_description_page.tsx index 27d92a83..24dcc11b 100644 --- a/mobile/src/screens/activity_description/activity_description_page.tsx +++ b/mobile/src/screens/activity_description/activity_description_page.tsx @@ -9,17 +9,17 @@ import { Dimensions, } from "react-native"; import { FullPageLoader } from "../../common/components/full_page_loader"; -import { ApiRequestStatus } from "../../constants/api_request_states"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { useGetActivityInfo } from "../../hooks/useGetActivityInfo"; import { router } from "expo-router"; import { Ionicons } from "@expo/vector-icons"; import { useCallback, useEffect, useRef, useState } from "react"; import { ActivityBottomSheet } from "../../components/activity_bottom_sheet/activity_bottom_sheet"; import * as ScreenOrientation from "expo-screen-orientation"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; import { useScreenOrientation } from "../../hooks/useScreenOrientation"; import { useRotationEnabled } from "../../hooks/useRotationEnabled"; -import { FloatingBackButton } from "../../components/floating_back_button/floating_back_button"; +import { FloatingBackButton } from "../../common/components/floating_back_button"; interface ActivityDescriptionPageProps { activityId: number; } diff --git a/mobile/src/screens/activity_point/activity_point.tsx b/mobile/src/screens/activity_point/activity_point.tsx index feeeac1f..d0f72548 100644 --- a/mobile/src/screens/activity_point/activity_point.tsx +++ b/mobile/src/screens/activity_point/activity_point.tsx @@ -1,15 +1,14 @@ -import { Image, Text, View, StyleSheet, Button, BackHandler } from "react-native"; +import { Image, Text, View, StyleSheet, BackHandler } from "react-native"; import { FullPageLoader } from "../../common/components/full_page_loader"; -import { ApiRequestStatus } from "../../constants/api_request_states"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { useGetActivityPoint } from "../../hooks/useGetActivityPoint"; import { ScrollView } from "react-native-gesture-handler"; import { AudioPlayer } from "../../common/components/audio_player"; -import { FloatingBackButton } from "../../components/floating_back_button/floating_back_button"; import { TouchableOpacity } from "@gorhom/bottom-sheet"; -import { LIGTHT_THEME } from "../../constants/theme"; -import { router, useFocusEffect } from "expo-router"; -import { useAudio } from "../../contexts/audio_context"; -import { useEffect } from "react"; +import { LIGTHT_THEME } from "../../common/constants/theme"; +import { router } from "expo-router"; +import { useAudio } from "../../common/contexts/audio_context"; +import { memo, useEffect } from "react"; interface ActivityPointScreenProps { stateId: number; @@ -18,7 +17,7 @@ interface ActivityPointScreenProps { id: number; } -export const ActivityPointScreen = ({ +export const ActivityPointScreen = memo(({ stateId, townId, activityId, @@ -33,8 +32,6 @@ export const ActivityPointScreen = ({ const { onUnmount } = useAudio(); - console.log('render') - useEffect(() => { const backAction = () => { onUnmount(); @@ -80,7 +77,7 @@ export const ActivityPointScreen = ({ /> ); -}; +}); const styles = StyleSheet.create({ container: { diff --git a/mobile/src/screens/edit_profile/edit_profile_page.tsx b/mobile/src/screens/edit_profile/edit_profile_page.tsx index abf6867e..4cd987f0 100644 --- a/mobile/src/screens/edit_profile/edit_profile_page.tsx +++ b/mobile/src/screens/edit_profile/edit_profile_page.tsx @@ -1,13 +1,13 @@ import { View, Text, StyleSheet } from "react-native"; import { useEditProfile } from "../../hooks/useEditProfile"; import { Controller } from "react-hook-form"; -import { useAuth } from "../../contexts/auth_context"; +import { useAuth } from "../../auth/contexts/auth_context"; import { CustomTextInput } from "../../common/components/form/text_input"; import Checkbox from "expo-checkbox"; import { useState } from "react"; import { TouchableOpacity } from "@gorhom/bottom-sheet"; -import { LIGTHT_THEME } from "../../constants/theme"; -import { CircleAvatar } from "../../components/circle_avatar/circle_avatar"; +import { LIGTHT_THEME } from "../../common/constants/theme"; +import { CircleAvatar } from "../../common/components/circle_avatar"; import { MaterialIcons } from "@expo/vector-icons"; import { ScrollView } from "react-native-gesture-handler"; //TODO: delete this line and import the correct CircleAvatar component diff --git a/mobile/src/screens/page_styles.tsx b/mobile/src/screens/page_styles.tsx index badaa113..a89fd2f4 100644 --- a/mobile/src/screens/page_styles.tsx +++ b/mobile/src/screens/page_styles.tsx @@ -1,5 +1,5 @@ import { StyleSheet } from "react-native" -import { LIGTHT_THEME } from "../constants/theme"; +import { LIGTHT_THEME } from "../common/constants/theme"; export const pageStyles = StyleSheet.create({ page_container: { diff --git a/mobile/src/screens/state_selection/state_selection_page.tsx b/mobile/src/screens/state_selection/state_selection_page.tsx index ad625c45..bdc42c14 100644 --- a/mobile/src/screens/state_selection/state_selection_page.tsx +++ b/mobile/src/screens/state_selection/state_selection_page.tsx @@ -1,7 +1,7 @@ import { View, ActivityIndicator, Text } from "react-native"; import { pageStyles } from "../page_styles"; import { useGetStates } from "../../hooks/useGetStates"; -import { ApiRequestStatus } from "../../constants/api_request_states"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { Caroussel } from "../../common/components/caroussel/caroussel"; import { router } from "expo-router"; import { useAnimatedSelectedIndex } from "../../hooks/useAnimatedSelectedIndex"; diff --git a/mobile/src/screens/town_activities/town_activities_page.tsx b/mobile/src/screens/town_activities/town_activities_page.tsx index b057e12a..5596a31c 100644 --- a/mobile/src/screens/town_activities/town_activities_page.tsx +++ b/mobile/src/screens/town_activities/town_activities_page.tsx @@ -8,11 +8,12 @@ import { TouchableOpacity, } from "react-native"; import { FullPageLoader } from "../../common/components/full_page_loader"; -import { ApiRequestStatus } from "../../constants/api_request_states"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { useGetActivities } from "../../hooks/useGetActivities"; import { ActivityTile } from "../../components/activity_tile/activity_tile"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; import { router } from "expo-router"; +import { FloatingEndActionButton } from "../../common/components/floating_end_action_button"; interface TownActivitiesPageProps { townId: number; @@ -34,6 +35,10 @@ export const TownActivitiesPage = ({ townId, stateId }: TownActivitiesPageProps) router.push(`/state/${stateId}/town/${townId}/activity/${activityId}/`); } + const handleGenerateRoute = () => { + router.push(`/routes/generate_route?townId=${townId}`); + } + return ( } keyExtractor={(item) => item.id.toString()} /> - - Generate Route - + ); }; @@ -64,18 +64,4 @@ const styles = StyleSheet.create({ flex: 1, width: "100%", }, - generate_route_button: { - position: "absolute", - justifyContent: "center", - alignItems: "center", - backgroundColor: LIGTHT_THEME.color.primary, - borderRadius: 25, - bottom: 10, - width: 200, - height: 50, - elevation: 5, - }, - generate_router_button_text: { - color: LIGTHT_THEME.color.white, - }, }); diff --git a/mobile/src/screens/town_selection/town_selection_page.tsx b/mobile/src/screens/town_selection/town_selection_page.tsx index b8ce396b..84e4d48b 100644 --- a/mobile/src/screens/town_selection/town_selection_page.tsx +++ b/mobile/src/screens/town_selection/town_selection_page.tsx @@ -1,7 +1,7 @@ import { View, Text, ActivityIndicator, StyleSheet } from "react-native"; import { pageStyles } from "../page_styles"; import { useGetStates } from "../../hooks/useGetStates"; -import { ApiRequestStatus } from "../../constants/api_request_states"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { Caroussel } from "../../common/components/caroussel/caroussel"; import { useGetTowns } from "../../hooks/useGetTowns"; import { router } from "expo-router"; diff --git a/mobile/src/screens/travel_details/travel_details_page.tsx b/mobile/src/screens/travel_details/travel_details_page.tsx index 9c42d247..f09afa1b 100644 --- a/mobile/src/screens/travel_details/travel_details_page.tsx +++ b/mobile/src/screens/travel_details/travel_details_page.tsx @@ -6,7 +6,7 @@ import { Dimensions, } from "react-native"; import { useGetTravelDetails } from "../../hooks/useGetTravelDetails"; -import { ApiRequestStatus } from "../../constants/api_request_states"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { TravelActivityList } from "../../travel_history/components/activity_list"; diff --git a/mobile/src/screens/travel_history/travel_history_page.tsx b/mobile/src/screens/travel_history/travel_history_page.tsx index be9c3ee7..7a52c709 100644 --- a/mobile/src/screens/travel_history/travel_history_page.tsx +++ b/mobile/src/screens/travel_history/travel_history_page.tsx @@ -1,9 +1,12 @@ import { View, Text, FlatList, StyleSheet, SectionList } from "react-native"; -import { useGetTravelHistory } from "../../hooks/useGetTravelHistory"; -import { ApiRequestStatus } from "../../constants/api_request_states"; +import { + TravelHistorySection, + useGetTravelHistory, +} from "../../hooks/useGetTravelHistory"; +import { ApiRequestStatus } from "../../common/constants/api_request_states"; import { FullPageLoader } from "../../common/components/full_page_loader"; import { CustomTileButton } from "../../common/components/custom_tile_button"; -import { LIGTHT_THEME } from "../../constants/theme"; +import { LIGTHT_THEME } from "../../common/constants/theme"; import { router } from "expo-router"; export const TravelHistoryPage = () => { @@ -21,22 +24,39 @@ export const TravelHistoryPage = () => { ); } - const onPress = (id: number) => { + const onPressPastTravel = (id: number) => { router.push(`/travel_history/details/${id}`); }; + const onPressActiveTravel = (id: number) => { + router.push(`/travel_history/active/${id}`); + }; + return ( item.id.toString() + index} - renderItem={({ item }) => ( - onPress(item.id)} - /> - )} + renderItem={({ item, section }) => { + switch (section.title) { + case TravelHistorySection.ACTIVE: + return ( + onPressActiveTravel(item.id)} + /> + ); + default: + return ( + onPressPastTravel(item.id)} + /> + ); + } + }} renderSectionHeader={({ section: { title } }) => ( {title} @@ -45,10 +65,10 @@ export const TravelHistoryPage = () => { style={styles.pastTravelsContainer} ListFooterComponent={} ItemSeparatorComponent={() => } - renderSectionFooter={({section}) => { + renderSectionFooter={({ section }) => { if (section.data.length === 0) { return ( - + No travels ); -- GitLab From 3483f1bcf9ba847872c3b93aec4815387f924ce3 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 17 May 2024 12:03:10 -0600 Subject: [PATCH 2/5] =?UTF-8?q?Refactorizaci=C3=B3n=20del=20text=20input?= =?UTF-8?q?=20para=20hacerlo=20m=C3=A1s=20reutilizable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/common/components/form/text_input.tsx | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/mobile/src/common/components/form/text_input.tsx b/mobile/src/common/components/form/text_input.tsx index 4a7ad5a9..cd72f6da 100644 --- a/mobile/src/common/components/form/text_input.tsx +++ b/mobile/src/common/components/form/text_input.tsx @@ -1,20 +1,18 @@ import { useEffect, useRef } from "react"; -import { TextInput, Text, StyleSheet, View, Animated, TouchableOpacity } from "react-native"; +import { TextInput, Text, StyleSheet, View, Animated, TouchableOpacity, TextInputProps } from "react-native"; import { LIGTHT_THEME } from "../../constants/theme"; -interface TextInputProps { +interface CustomTextInputProps { isPassword?: boolean; label: string; - onChangeText: (text: string) => void; value: string; onBlur?: () => void; errors?: string; - type?: any; editable?: boolean; + textInputProps?: TextInputProps; } -export const CustomTextInput = (props: TextInputProps) => { - const { isPassword, label, type, onBlur, errors, value, editable,...rest } = props; +export const CustomTextInput = ({ textInputProps, label, value, errors, onBlur, editable, isPassword }: CustomTextInputProps) => { const labelFocusAnimation = useRef(new Animated.Value(value.length > 0 ? 1 : 0)).current; const inputRef = useRef(null); @@ -27,7 +25,7 @@ export const CustomTextInput = (props: TextInputProps) => { }; const handleBlur = () => { - if (!props.value || props.value === "") { + if (!value || value === "") { Animated.timing(labelFocusAnimation, { toValue: 0, duration: 200, @@ -52,11 +50,10 @@ export const CustomTextInput = (props: TextInputProps) => { {label} Date: Fri, 17 May 2024 12:03:55 -0600 Subject: [PATCH 3/5] =?UTF-8?q?Creaci=C3=B3n=20de=20una=20funci=C3=B3n=20p?= =?UTF-8?q?ara=20simular=20delay=20en=20una=20petici=C3=B3n.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/utils/dev/delay_time.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 mobile/src/utils/dev/delay_time.ts diff --git a/mobile/src/utils/dev/delay_time.ts b/mobile/src/utils/dev/delay_time.ts new file mode 100644 index 00000000..dfb58af3 --- /dev/null +++ b/mobile/src/utils/dev/delay_time.ts @@ -0,0 +1,3 @@ +export const delay = async (delay: number) => { + return new Promise( resolve => setTimeout(resolve, delay) ); +} \ No newline at end of file -- GitLab From d4d03c647a6872db4d5312e556b8d34b6185e889 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 17 May 2024 12:05:51 -0600 Subject: [PATCH 4/5] =?UTF-8?q?Creaci=C3=B3n=20de=20la=20nueva=20fuente=20?= =?UTF-8?q?de=20datos=20para=20rutas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/src/domain/datasources/route_datasource.ts | 6 ++++++ mobile/src/domain/entities/activity_info_entity.ts | 13 +++++++++++++ mobile/src/domain/entities/travel_details.ts | 4 ++-- mobile/src/domain/entities/travel_history.ts | 6 +++--- mobile/src/domain/repositories/route_repository.ts | 6 ++++++ 5 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 mobile/src/domain/datasources/route_datasource.ts create mode 100644 mobile/src/domain/repositories/route_repository.ts diff --git a/mobile/src/domain/datasources/route_datasource.ts b/mobile/src/domain/datasources/route_datasource.ts new file mode 100644 index 00000000..78a312b9 --- /dev/null +++ b/mobile/src/domain/datasources/route_datasource.ts @@ -0,0 +1,6 @@ +import { ActivityRouteEntity } from "../entities/activity_info_entity"; + +export interface RouteDataSource { + generateRoute: (townId: number) => Promise; + getRoute: (routeId: number) => Promise; +} \ No newline at end of file diff --git a/mobile/src/domain/entities/activity_info_entity.ts b/mobile/src/domain/entities/activity_info_entity.ts index 26e1468b..2631049a 100644 --- a/mobile/src/domain/entities/activity_info_entity.ts +++ b/mobile/src/domain/entities/activity_info_entity.ts @@ -5,4 +5,17 @@ export interface ActivityInfoEntity extends PlaceInfoEntity { townId: number; location: string; tags?: string[]; +} + +export interface ActivityRouteEntity extends PlaceInfoEntity { + townId: number; + location: string; + coordinates: { + latitude: number; + longitude: number; + }; + tags?: string[]; + startTime: Date; + endTime: Date; + done: boolean; } \ No newline at end of file diff --git a/mobile/src/domain/entities/travel_details.ts b/mobile/src/domain/entities/travel_details.ts index 8dcbf8a2..fd4bdcb6 100644 --- a/mobile/src/domain/entities/travel_details.ts +++ b/mobile/src/domain/entities/travel_details.ts @@ -1,8 +1,8 @@ import { PlaceInfoEntity } from "./place_info_entity"; -import { Travel } from "./travel_history"; +import { Route } from "./travel_history"; export interface TravelDetails { - travel: Travel; + travel: Route; activityList: TravelHistoryActivity[]; } diff --git a/mobile/src/domain/entities/travel_history.ts b/mobile/src/domain/entities/travel_history.ts index 7a03fb75..c22a0572 100644 --- a/mobile/src/domain/entities/travel_history.ts +++ b/mobile/src/domain/entities/travel_history.ts @@ -1,9 +1,9 @@ export interface TravelHistory { - pastTravels: Travel[]; - activeTravel?: Travel; + pastTravels: Route[]; + activeTravel?: Route; } -export interface Travel { +export interface Route { id: number; destination: string; imageUri?: string; diff --git a/mobile/src/domain/repositories/route_repository.ts b/mobile/src/domain/repositories/route_repository.ts new file mode 100644 index 00000000..f2667ab3 --- /dev/null +++ b/mobile/src/domain/repositories/route_repository.ts @@ -0,0 +1,6 @@ +import { ActivityRouteEntity } from "../entities/activity_info_entity"; + +export interface RouteRepository { + generateRoute: (townId: number) => Promise; + getRoute: (routeId: number) => Promise; +} \ No newline at end of file -- GitLab From 6148992dee1ea1e0b7c6c50f65e4e5ad537f7ce8 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Thu, 23 May 2024 12:28:28 -0600 Subject: [PATCH 5/5] =?UTF-8?q?Selecci=C3=B3n=20de=20puntos=20en=20el=20ma?= =?UTF-8?q?pa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mobile/app/routes/generate_route.tsx | 11 + mobile/app/sign_up.tsx | 54 +- mobile/app/travel_history/active/[id].tsx | 12 + mobile/package-lock.json | 2803 ++++++++++++----- mobile/package.json | 4 +- mobile/src/auth/components/login_form.tsx | 12 +- mobile/src/auth/components/sign_up_form.tsx | 47 +- mobile/src/auth/hooks/useLoggin.ts | 12 +- mobile/src/auth/hooks/useSignUp.ts | 22 +- .../dev/datasources/auth_datasource.ts | 2 + mobile/src/auth/pages/login_page.tsx | 10 +- mobile/src/auth/pages/sign_up_page.tsx | 71 + .../components/floating_end_action_button.tsx | 38 + .../components/form/date_text_input.tsx | 5 +- .../common/constants/api_request_states.ts | 3 +- mobile/src/common/contexts/data_context.tsx | 70 + mobile/src/hooks/useGenerateRoute.ts | 13 + mobile/src/hooks/useGet.ts | 30 +- mobile/src/hooks/useGetTravelHistory.ts | 4 +- .../datasource/dev/route_datasource.ts | 63 + .../datasource/dev/travel_datasource.ts | 9 +- .../datasource/prod/state_datasource.ts | 20 + .../repositories/route_repository.ts | 12 + .../components/maps/custom_map_marker.tsx | 81 + .../src/route/components/maps/svg_marker.tsx | 26 + .../route/components/route_activity_tile.tsx | 103 + .../src/route/hooks/useGetRouteActivities.ts | 12 + mobile/src/route/screens/maps.tsx | 69 + mobile/src/route/screens/route_preview.tsx | 75 + .../town_activities/town_activities_page.tsx | 5 + 30 files changed, 2774 insertions(+), 924 deletions(-) create mode 100644 mobile/app/routes/generate_route.tsx create mode 100644 mobile/app/travel_history/active/[id].tsx create mode 100644 mobile/src/auth/pages/sign_up_page.tsx create mode 100644 mobile/src/common/components/floating_end_action_button.tsx create mode 100644 mobile/src/common/contexts/data_context.tsx create mode 100644 mobile/src/hooks/useGenerateRoute.ts create mode 100644 mobile/src/infrastructure/datasource/dev/route_datasource.ts create mode 100644 mobile/src/infrastructure/datasource/prod/state_datasource.ts create mode 100644 mobile/src/infrastructure/repositories/route_repository.ts create mode 100644 mobile/src/route/components/maps/custom_map_marker.tsx create mode 100644 mobile/src/route/components/maps/svg_marker.tsx create mode 100644 mobile/src/route/components/route_activity_tile.tsx create mode 100644 mobile/src/route/hooks/useGetRouteActivities.ts create mode 100644 mobile/src/route/screens/maps.tsx create mode 100644 mobile/src/route/screens/route_preview.tsx diff --git a/mobile/app/routes/generate_route.tsx b/mobile/app/routes/generate_route.tsx new file mode 100644 index 00000000..468a48eb --- /dev/null +++ b/mobile/app/routes/generate_route.tsx @@ -0,0 +1,11 @@ +import { useLocalSearchParams } from "expo-router"; +import { Text } from "react-native"; +import { RoutePreviewPage } from "../../src/route/screens/route_preview"; + +export default function GenerateRoute() { + const { townId } = useLocalSearchParams<{ townId: string }>(); + if (!townId) { + return Invalid town id; + } + return ; +} \ No newline at end of file diff --git a/mobile/app/sign_up.tsx b/mobile/app/sign_up.tsx index 0d279953..c6f7ba00 100644 --- a/mobile/app/sign_up.tsx +++ b/mobile/app/sign_up.tsx @@ -2,63 +2,13 @@ import { View, StyleSheet, Image, Text, Button } from "react-native"; import { LIGTHT_THEME } from "../src/common/constants/theme"; import { SignUpForm } from "../src/auth/components/sign_up_form"; import { router } from "expo-router"; +import { SignUpPage } from "../src/auth/pages/sign_up_page"; const loginImage = require("../assets/login-image.jpg"); const SignUp = () => { return ( - - - - - - -