diff --git a/app/application/_layout.tsx b/app/application/_layout.tsx index 25796d79f918f301a891f21cf003e0fc98e4a622..67cad6f7c67dc21f76ca2380be30768952e483aa 100644 --- a/app/application/_layout.tsx +++ b/app/application/_layout.tsx @@ -8,7 +8,7 @@ const TabLayout: React.FC = () => { const { user } = useAuthentication() if (user == null) { - return <Redirect href="/authentication/login" /> + return <Redirect href="/authentication/about" /> } return ( diff --git a/app/application/users/settings.tsx b/app/application/users/settings.tsx index 1a4b9f926dd65be983b18eee0362705301e52409..414f11a21a4897ef9e682f5c519c49e49b18c2f7 100644 --- a/app/application/users/settings.tsx +++ b/app/application/users/settings.tsx @@ -1,7 +1,6 @@ -import { Text } from "react-native" import { Button } from "react-native-paper" -import { SafeAreaView } from "react-native-safe-area-context" +import { About } from "@/presentation/react-native/components/About" import { useAuthentication } from "@/presentation/react/contexts/Authentication" const SettingsPage: React.FC = () => { @@ -12,26 +11,19 @@ const SettingsPage: React.FC = () => { } return ( - <SafeAreaView - style={[ - { - flex: 1, - alignItems: "center", - justifyContent: "center", - }, - ]} - > - <Text>Settings</Text> - - <Button - mode="contained" - onPress={handleLogout} - loading={logout.state === "loading"} - disabled={logout.state === "loading"} - > - Logout - </Button> - </SafeAreaView> + <About + actionButton={ + <Button + mode="contained" + labelStyle={{ fontSize: 18 }} + onPress={handleLogout} + loading={logout.state === "loading"} + disabled={logout.state === "loading"} + > + Logout + </Button> + } + /> ) } diff --git a/app/authentication/_layout.tsx b/app/authentication/_layout.tsx index 4302423eda1a57204d548e27918c446b87844676..b8325bcccea51e2bcf29845e15ba891786cc47a7 100644 --- a/app/authentication/_layout.tsx +++ b/app/authentication/_layout.tsx @@ -17,6 +17,15 @@ const TabLayout: React.FC = () => { headerShown: false, }} > + <Tabs.Screen + name="about" + options={{ + title: "About", + tabBarIcon: ({ color }) => { + return <TabBarIcon name="info" color={color} /> + }, + }} + /> <Tabs.Screen name="login" options={{ diff --git a/app/authentication/about.tsx b/app/authentication/about.tsx new file mode 100644 index 0000000000000000000000000000000000000000..de3f25cb121db2098dd7260de786d329b9f1c0f0 --- /dev/null +++ b/app/authentication/about.tsx @@ -0,0 +1,26 @@ +import { Button } from "react-native-paper" +import { useRouter } from "expo-router" + +import { About } from "@/presentation/react-native/components/About" + +const AboutPage: React.FC = () => { + const router = useRouter() + + return ( + <About + actionButton={ + <Button + mode="contained" + labelStyle={{ fontSize: 18 }} + onPress={() => { + router.push("/authentication/login") + }} + > + Get Started 🚀 + </Button> + } + /> + ) +} + +export default AboutPage diff --git a/app/authentication/login.tsx b/app/authentication/login.tsx index d6fea8ca9193ce664ddc76d960e7cfc5b5344e8a..944c828a49a4ec8321b3de10f5daf70fc71a2974 100644 --- a/app/authentication/login.tsx +++ b/app/authentication/login.tsx @@ -67,6 +67,7 @@ const LoginPage: React.FC = () => { <Button mode="contained" + labelStyle={{ fontSize: 18 }} onPress={handleSubmit(onSubmit)} loading={login.state === "loading"} disabled={login.state === "loading"} diff --git a/app/authentication/register.tsx b/app/authentication/register.tsx index 74e8ceb05fb8ac8acce544d4cf0880aef421f4d2..6664b072f6a3560a5cc16bdc912ffc2e59315aa7 100644 --- a/app/authentication/register.tsx +++ b/app/authentication/register.tsx @@ -107,6 +107,7 @@ const RegisterPage: React.FC = () => { <Button mode="contained" + labelStyle={{ fontSize: 18 }} onPress={handleSubmit(onSubmit)} loading={register.state === "loading"} disabled={register.state === "loading"} diff --git a/app/index.tsx b/app/index.tsx index c8c246b6edae66ddb3d0367dfa673dd975a8aead..275cb7c915e54faf854fdc83272412a615447204 100644 --- a/app/index.tsx +++ b/app/index.tsx @@ -6,7 +6,7 @@ const HomePage: React.FC = () => { const { user } = useAuthentication() if (user == null) { - return <Redirect href="/authentication/login" /> + return <Redirect href="/authentication/about" /> } return <Redirect href="/application/habits/" /> diff --git a/presentation/assets/images/Universite-Strasbourg.png b/presentation/assets/images/Universite-Strasbourg.png deleted file mode 100644 index ff3bd48fb06081d82afb2f0e715652e2de907f27..0000000000000000000000000000000000000000 Binary files a/presentation/assets/images/Universite-Strasbourg.png and /dev/null differ diff --git a/presentation/react-native/components/About.tsx b/presentation/react-native/components/About.tsx new file mode 100644 index 0000000000000000000000000000000000000000..62f523c2f54d168d2ba5801696acd1cd34f9b5e5 --- /dev/null +++ b/presentation/react-native/components/About.tsx @@ -0,0 +1,81 @@ +import { View } from "react-native" +import { Text } from "react-native-paper" +import { SafeAreaView } from "react-native-safe-area-context" + +import { ExternalLink } from "@/presentation/react-native/ui/ExternalLink" +import { getVersion } from "@/utils/version" + +export interface AboutProps { + actionButton: React.ReactNode +} + +export const About: React.FC<AboutProps> = (props) => { + const { actionButton } = props + + const version = getVersion() + + return ( + <SafeAreaView + style={{ + flex: 1, + paddingHorizontal: 20, + }} + > + <View style={{ alignItems: "center", marginVertical: 20 }}> + <Text + style={{ + fontWeight: "bold", + fontSize: 28, + textAlign: "center", + }} + > + Habits Tracker + </Text> + + <Text + style={{ + marginTop: 6, + fontWeight: "bold", + fontSize: 18, + textAlign: "center", + }} + > + To perform at work and in everyday life. + </Text> + + <Text + style={{ + marginTop: 6, + fontWeight: "bold", + fontSize: 16, + textAlign: "center", + }} + > + v{version} + </Text> + </View> + + <Text variant="bodyLarge" style={{ textAlign: "center" }}> + <ExternalLink href="https://unistra.fr" style={{ color: "#006CFF" }}> + Université de Strasbourg + </ExternalLink> + </Text> + <Text variant="bodyLarge" style={{ textAlign: "center" }}> + BUT Informatique - IUT Robert Schuman + </Text> + <Text variant="bodyLarge" style={{ textAlign: "center" }}> + P61 Mobile Development + </Text> + + <View + style={{ + justifyContent: "center", + alignItems: "center", + marginVertical: 20, + }} + > + {actionButton} + </View> + </SafeAreaView> + ) +} diff --git a/utils/__tests__/version.test.ts b/utils/__tests__/version.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9e94b07dccf8779b8a2d98950c2b7b25ed0d7f5 --- /dev/null +++ b/utils/__tests__/version.test.ts @@ -0,0 +1,39 @@ +import { getVersion } from "../version" +import { version } from "@/package.json" + +describe("utils/version", () => { + const env = process.env + + beforeEach(() => { + jest.resetModules() + process.env = { ...env } + }) + + afterEach(() => { + process.env = env + jest.clearAllMocks() + }) + + it("should return '0.0.0-development' when NODE_ENV is 'development'", () => { + // Arrange - Given + process.env["NODE_ENV"] = "development" + + // Act - When + const result = getVersion() + + // Assert - Then + const expected = "0.0.0-development" + expect(result).toEqual(expected) + }) + + it("should return the version from package.json when NODE_ENV is not 'development'", () => { + // Arrange - Given + process.env["NODE_ENV"] = "production" + + // Act - When + const result = getVersion() + + // Assert - Then + expect(result).toEqual(version) + }) +}) diff --git a/utils/version.ts b/utils/version.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ddaefbd8f63ab0d357660c8990e82793b46e401 --- /dev/null +++ b/utils/version.ts @@ -0,0 +1,8 @@ +import { version } from "@/package.json" + +export const getVersion = (): string => { + if (process.env["NODE_ENV"] === "development") { + return "0.0.0-development" + } + return version +}