From b73e1bcad5386fbe1e0f4c7abae7d524d0045f77 Mon Sep 17 00:00:00 2001 From: ngomesodent <101274479+ngomesodent@users.noreply.github.com> Date: Thu, 4 Apr 2024 16:21:07 +0200 Subject: [PATCH] ui/bottom-navigation (#130) * feat(front): add safe area for mobile * fix(front): reduce safe area size * fix(front): remove padding bottom from safe area and resize bottom nav * style: updated color palette * refactor: moved Button colors inside color palette * feat: integrated tabs from Figma mockup * refactor: optimized code by propagating props and fixed color palette * refactor: deleted useless pages and moved SafeAreaProvider and IconContextProvider inside root layout instead of tabs root layout * fix: annoying scroll issue --------- Co-authored-by: MAXOUXAX <24844231+MAXOUXAX@users.noreply.github.com> --- expo/app/(tabs)/_layout.tsx | 99 +++++++++++++++++++++++-------------- expo/app/AddMusic.tsx | 9 ---- expo/app/_layout.tsx | 33 ++++++++++--- expo/app/modal.tsx | 13 ----- expo/components/Button.tsx | 7 +-- expo/constants/Colors.ts | 18 +++---- 6 files changed, 98 insertions(+), 81 deletions(-) delete mode 100644 expo/app/AddMusic.tsx delete mode 100644 expo/app/modal.tsx diff --git a/expo/app/(tabs)/_layout.tsx b/expo/app/(tabs)/_layout.tsx index c6432d0c..303900b3 100644 --- a/expo/app/(tabs)/_layout.tsx +++ b/expo/app/(tabs)/_layout.tsx @@ -1,12 +1,14 @@ import { Redirect, Tabs } from "expo-router"; import * as WebBrowser from "expo-web-browser"; -import House from "phosphor-react-native/src/icons/House"; +import HouseLine from "phosphor-react-native/src/icons/HouseLine"; import MusicNote from "phosphor-react-native/src/icons/MusicNote"; import User from "phosphor-react-native/src/icons/User"; import Users from "phosphor-react-native/src/icons/Users"; -import { useColorScheme } from "react-native"; +import { ActivityIndicator } from "react-native"; import { Text } from "../../components/Tamed"; +import { View } from "../../components/Themed"; +import Colors from "../../constants/Colors"; import { useSupabaseUserHook } from "../../lib/useSupabaseUser"; WebBrowser.maybeCompleteAuthSession(); @@ -19,10 +21,9 @@ function TabBarLabel(props: { return ( {props.children} @@ -30,29 +31,53 @@ function TabBarLabel(props: { ); } export default function TabLayout() { - WebBrowser.maybeCompleteAuthSession(); // required for web only - - const colorScheme = useColorScheme(); + // This is only required for web + // This is used to close the authentication popup on web + WebBrowser.maybeCompleteAuthSession(); const user = useSupabaseUserHook(); - if (user === undefined) return Loading..; + if (user === undefined) + return ( + + + + Chargement de l'application en cours... + + + ); if (!user) return ; return ( ( - - {children} - - ), + tabBarLabel: (props) => , tabBarIcon: ({ color, focused }) => ( - + ), }} /> @@ -77,13 +102,13 @@ export default function TabLayout() { options={{ title: "Salles", headerShown: false, - tabBarLabel: ({ color, focused, children }) => ( - - {children} - - ), + tabBarLabel: (props) => , tabBarIcon: ({ color, focused }) => ( - + ), }} /> @@ -91,13 +116,13 @@ export default function TabLayout() { name="Friends" options={{ title: "Amis", - tabBarLabel: ({ color, focused, children }) => ( - - {children} - - ), + tabBarLabel: (props) => , tabBarIcon: ({ color, focused }) => ( - + ), }} /> @@ -106,13 +131,13 @@ export default function TabLayout() { options={{ title: "Profil", headerShown: false, - tabBarLabel: ({ color, focused, children }) => ( - - {children} - - ), + tabBarLabel: (props) => , tabBarIcon: ({ color, focused }) => ( - + ), }} /> diff --git a/expo/app/AddMusic.tsx b/expo/app/AddMusic.tsx deleted file mode 100644 index b38d9cf7..00000000 --- a/expo/app/AddMusic.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { View, Text } from "react-native"; - -export default function AddMusic() { - return ( - - Ajoueter une musique - - ); -} diff --git a/expo/app/_layout.tsx b/expo/app/_layout.tsx index 80ec534e..4737980f 100644 --- a/expo/app/_layout.tsx +++ b/expo/app/_layout.tsx @@ -1,10 +1,13 @@ import FontAwesome from "@expo/vector-icons/FontAwesome"; import { useFonts } from "expo-font"; import { SplashScreen, Stack, router } from "expo-router"; +import { IconContext } from "phosphor-react-native/src/lib"; import { useEffect } from "react"; import { MenuProvider } from "react-native-popup-menu"; +import { SafeAreaProvider } from "react-native-safe-area-context"; import { Text, View } from "../components/Themed"; +import Colors from "../constants/Colors"; import { supabase } from "../lib/supabase"; export const unstable_settings = { @@ -78,14 +81,28 @@ function RootLayoutNav() { borderRadius: 40, }} > - - - - - - - - + + + + + + + + + + + ); diff --git a/expo/app/modal.tsx b/expo/app/modal.tsx deleted file mode 100644 index a405acb1..00000000 --- a/expo/app/modal.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { StatusBar } from "expo-status-bar"; -import { Platform, StyleSheet, Text, View } from "react-native"; - -export default function ModalScreen() { - return ( - - Modal - - {/* Use a light status bar on iOS to account for the black space above the modal */} - - - ); -} diff --git a/expo/components/Button.tsx b/expo/components/Button.tsx index 431c323f..ca196a24 100644 --- a/expo/components/Button.tsx +++ b/expo/components/Button.tsx @@ -11,15 +11,16 @@ import { } from "react-native"; import { Text } from "./Tamed"; +import Colors from "../constants/Colors"; const BUTTON_COLORS = ["primary", "success", "danger"] as const; type ButtonColor = (typeof BUTTON_COLORS)[number]; const COLOR_PALETTE: Record = { - primary: "#1A1A1A", - success: "#13863C", - danger: "#F33F33", + primary: Colors.light.text, + success: Colors.light.success, + danger: Colors.light.danger, }; export type ButtonProps = { diff --git a/expo/constants/Colors.ts b/expo/constants/Colors.ts index 32674d87..58e6f7e5 100644 --- a/expo/constants/Colors.ts +++ b/expo/constants/Colors.ts @@ -1,19 +1,15 @@ const tintColorLight = "#2f95dc"; -const tintColorDark = "#fff"; +const fakeBlack = "#1A1A1A"; export default { light: { - text: "#000", + success: "#13863C", + danger: "#F33F33", + text: fakeBlack, + black: fakeBlack, background: "#f2f2f2", tint: tintColorLight, - tabIconDefault: "#ccc", - tabIconSelected: tintColorLight, - }, - dark: { - text: "#fff", - background: "#000", - tint: tintColorDark, - tabIconDefault: "#ccc", - tabIconSelected: tintColorDark, + tabIconDefault: fakeBlack, + tabIconSelected: fakeBlack, }, };