From 1a85e4aa2182523d54401acb67388616a34b2e28 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Tue, 19 Mar 2024 11:39:49 -0600 Subject: [PATCH 1/2] Creacion del contexto para obtener las fuentes de datos --- mobile/src/contexts/data_context.tsx | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 mobile/src/contexts/data_context.tsx diff --git a/mobile/src/contexts/data_context.tsx b/mobile/src/contexts/data_context.tsx new file mode 100644 index 00000000..e50f5262 --- /dev/null +++ b/mobile/src/contexts/data_context.tsx @@ -0,0 +1,37 @@ +import { createContext, PropsWithChildren, useContext } from "react"; +import { StateRepository } from "../domain/repositories/state_repository"; +import { StateRepositoryImpl } from "../infrastructure/repositories/state_repository"; +import { StateDataSourceImpl } from "../infrastructure/datasource/state_datasource"; + +type DataContextType = { + statesRepository: StateRepository | null; +}; + +type DataContextProviderProps = PropsWithChildren<{}>; + +const DataContext = createContext({ + statesRepository: null +}); + +export const DataContextProvider = ({ children }: DataContextProviderProps) => { + const statesDataSource = new StateDataSourceImpl(); + const statesRepository = new StateRepositoryImpl(statesDataSource); + + const value = { + statesRepository + }; + + 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 -- GitLab From 55161da13eac9f5fce7efae14d6029aa10f01e74 Mon Sep 17 00:00:00 2001 From: Lorenzo Trujillo Date: Fri, 29 Mar 2024 12:24:18 -0600 Subject: [PATCH 2/2] Primer commit mobile --- mobile/App.tsx | 9 +- mobile/app.json | 18 +- mobile/app/(modal)/[id].tsx | 16 + mobile/app/(tabs)/_layout.tsx | 61 + mobile/app/(tabs)/account.tsx | 7 + mobile/app/(tabs)/index.tsx | 7 + mobile/app/(tabs)/travel_history.tsx | 9 + mobile/app/_layout.tsx | 49 + mobile/app/login.tsx | 9 + mobile/app/sign_up.tsx | 64 + mobile/assets/avatar.png | Bin 0 -> 1281454 bytes mobile/assets/login-image.jpg | Bin 0 -> 201199 bytes mobile/assets/placeholder.jpeg | Bin 0 -> 10036 bytes mobile/babel.config.js | 2 +- mobile/eas.json | 21 + mobile/package-lock.json | 1430 ++++++++++++++--- mobile/package.json | 14 +- mobile/src/components/caroussel/caroussel.tsx | 77 + .../components/caroussel/caroussel_tile.tsx | 71 + .../circle_avatar/circle_avatar.tsx | 14 + .../full_page_loader/full_page_loader.tsx | 9 + .../src/components/login_form/login_form.tsx | 107 ++ .../components/or_division/or_division.tsx | 26 + .../components/sign_up_form/sign_up_form.tsx | 167 ++ .../src/components/text_input/text_input.tsx | 90 ++ mobile/src/constants/api_request_states.ts | 5 + mobile/src/constants/theme.ts | 31 + mobile/src/contexts/auth_context.tsx | 71 + .../domain/datasources/state_datasource.ts | 4 +- .../src/domain/entities/place_info_entity.ts | 6 + mobile/src/domain/entities/state_entity.ts | 9 +- mobile/src/domain/entities/town_entity.ts | 5 + .../src/domain/entities/user_info_entity.ts | 7 + .../domain/repositories/state_repository.ts | 4 +- mobile/src/hooks/useGetList.ts | 23 + mobile/src/hooks/useGetStates.ts | 14 + mobile/src/hooks/useGetTowns.ts | 15 + mobile/src/hooks/useLoggin.ts | 34 + .../datasource/state_datasource.ts | 67 +- .../repositories/state_repository.ts | 6 +- mobile/src/screens/account/account_page.tsx | 81 + mobile/src/screens/login/login_page.tsx | 65 + mobile/src/screens/page_styles.tsx | 10 + .../state_selection/state_selection_page.tsx | 21 + .../town_selection/town_selection_page.tsx | 26 + 45 files changed, 2514 insertions(+), 267 deletions(-) create mode 100644 mobile/app/(modal)/[id].tsx create mode 100644 mobile/app/(tabs)/_layout.tsx create mode 100644 mobile/app/(tabs)/account.tsx create mode 100644 mobile/app/(tabs)/index.tsx create mode 100644 mobile/app/(tabs)/travel_history.tsx create mode 100644 mobile/app/_layout.tsx create mode 100644 mobile/app/login.tsx create mode 100644 mobile/app/sign_up.tsx create mode 100644 mobile/assets/avatar.png create mode 100644 mobile/assets/login-image.jpg create mode 100644 mobile/assets/placeholder.jpeg create mode 100644 mobile/eas.json create mode 100644 mobile/src/components/caroussel/caroussel.tsx create mode 100644 mobile/src/components/caroussel/caroussel_tile.tsx create mode 100644 mobile/src/components/circle_avatar/circle_avatar.tsx create mode 100644 mobile/src/components/full_page_loader/full_page_loader.tsx create mode 100644 mobile/src/components/login_form/login_form.tsx create mode 100644 mobile/src/components/or_division/or_division.tsx create mode 100644 mobile/src/components/sign_up_form/sign_up_form.tsx create mode 100644 mobile/src/components/text_input/text_input.tsx create mode 100644 mobile/src/constants/api_request_states.ts create mode 100644 mobile/src/constants/theme.ts create mode 100644 mobile/src/contexts/auth_context.tsx create mode 100644 mobile/src/domain/entities/place_info_entity.ts create mode 100644 mobile/src/domain/entities/town_entity.ts create mode 100644 mobile/src/domain/entities/user_info_entity.ts create mode 100644 mobile/src/hooks/useGetList.ts create mode 100644 mobile/src/hooks/useGetStates.ts create mode 100644 mobile/src/hooks/useGetTowns.ts create mode 100644 mobile/src/hooks/useLoggin.ts create mode 100644 mobile/src/screens/account/account_page.tsx create mode 100644 mobile/src/screens/login/login_page.tsx create mode 100644 mobile/src/screens/page_styles.tsx create mode 100644 mobile/src/screens/state_selection/state_selection_page.tsx create mode 100644 mobile/src/screens/town_selection/town_selection_page.tsx diff --git a/mobile/App.tsx b/mobile/App.tsx index 0329d0c9..1f252495 100644 --- a/mobile/App.tsx +++ b/mobile/App.tsx @@ -1,12 +1,13 @@ 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'; export default function App() { return ( - - Open up App.tsx to start working on your app! - - + + + ); } diff --git a/mobile/app.json b/mobile/app.json index 2cabcf6a..69fc5a60 100644 --- a/mobile/app.json +++ b/mobile/app.json @@ -1,6 +1,7 @@ { "expo": { - "name": "mobile", + "name": "pueblos-magicos", + "scheme": "myapp", "slug": "mobile", "version": "1.0.0", "orientation": "portrait", @@ -21,10 +22,23 @@ "adaptiveIcon": { "foregroundImage": "./assets/adaptive-icon.png", "backgroundColor": "#ffffff" - } + }, + "package": "com.lorenzotrujillo.mobile" }, "web": { "favicon": "./assets/favicon.png" + }, + "plugins": [ + "expo-router", + "expo-secure-store" + ], + "extra": { + "router": { + "origin": false + }, + "eas": { + "projectId": "e886fd36-a509-4844-bc03-c722bb61a245" + } } } } diff --git a/mobile/app/(modal)/[id].tsx b/mobile/app/(modal)/[id].tsx new file mode 100644 index 00000000..10b634af --- /dev/null +++ b/mobile/app/(modal)/[id].tsx @@ -0,0 +1,16 @@ +import { View, Text } from "react-native"; +import { TownSelectionPage } from "../../src/screens/town_selection/town_selection_page"; +import { useLocalSearchParams } from "expo-router"; +import { FullPageLoader } from "../../src/components/full_page_loader/full_page_loader"; + +export default function Main () { + const { id } = useLocalSearchParams<{ id: string }>(); + if (!id) { + return ( + + ); + } + return ( + + ); +} \ No newline at end of file diff --git a/mobile/app/(tabs)/_layout.tsx b/mobile/app/(tabs)/_layout.tsx new file mode 100644 index 00000000..55ed70f3 --- /dev/null +++ b/mobile/app/(tabs)/_layout.tsx @@ -0,0 +1,61 @@ +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"; + +export default function Layout() { + const { user } = useAuth(); + console.log(user); + if (!user) { + return ; + } + + return ( + + { + if (focused) { + return ; + } + return ; + }, + }} + /> + { + if (focused) { + return ; + } + return ; + }, + }} + /> + { + if (focused) { + return ; + } + return ; + }, + }} + /> + + ); +} diff --git a/mobile/app/(tabs)/account.tsx b/mobile/app/(tabs)/account.tsx new file mode 100644 index 00000000..64a31b26 --- /dev/null +++ b/mobile/app/(tabs)/account.tsx @@ -0,0 +1,7 @@ +import { AccountPage } from "../../src/screens/account/account_page"; + +export default function AccountScreen() { + return ( + + ); +} \ No newline at end of file diff --git a/mobile/app/(tabs)/index.tsx b/mobile/app/(tabs)/index.tsx new file mode 100644 index 00000000..9c27cc41 --- /dev/null +++ b/mobile/app/(tabs)/index.tsx @@ -0,0 +1,7 @@ +import { DataContextProvider } from '../../src/contexts/data_context'; +import { StateSelectionPage } from '../../src/screens/state_selection/state_selection_page'; +export default function Main () { + return ( + + ); +}; \ No newline at end of file diff --git a/mobile/app/(tabs)/travel_history.tsx b/mobile/app/(tabs)/travel_history.tsx new file mode 100644 index 00000000..2416e829 --- /dev/null +++ b/mobile/app/(tabs)/travel_history.tsx @@ -0,0 +1,9 @@ +import { View } from "react-native"; + +export default function TravelHistoryScreen() { + return ( + + + + ); +} \ No newline at end of file diff --git a/mobile/app/_layout.tsx b/mobile/app/_layout.tsx new file mode 100644 index 00000000..0f888a42 --- /dev/null +++ b/mobile/app/_layout.tsx @@ -0,0 +1,49 @@ +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 { ActivityIndicator } from "react-native"; + +export default function Root() { + return + + + + ; +} + +const MainLayout = () => { + const { isLoading } = useAuth(); + + if (isLoading) { + return ; + } + + return ( + + + + + + + ); +}; diff --git a/mobile/app/login.tsx b/mobile/app/login.tsx new file mode 100644 index 00000000..d574b543 --- /dev/null +++ b/mobile/app/login.tsx @@ -0,0 +1,9 @@ +import { LoginPage } from "../src/screens/login/login_page"; + +const LoginScreen = () => { + return ( + + ); +}; + +export default LoginScreen; diff --git a/mobile/app/sign_up.tsx b/mobile/app/sign_up.tsx new file mode 100644 index 00000000..236776db --- /dev/null +++ b/mobile/app/sign_up.tsx @@ -0,0 +1,64 @@ +import { View, StyleSheet, Image, Text, Button } from "react-native"; +import { LIGTHT_THEME } from "../src/constants/theme"; +import { SignUpForm } from "../src/components/sign_up_form/sign_up_form"; +import { router } from "expo-router"; +const loginImage = require("../assets/login-image.jpg"); + +const SignUp = () => { + return ( + + + + + + +