diff --git a/app/(auth)/_layout.tsx b/app/(auth)/_layout.tsx index 13d04c3..d91d8d6 100644 --- a/app/(auth)/_layout.tsx +++ b/app/(auth)/_layout.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useEffect } from "react"; import { Drawer } from "expo-router/drawer"; import { useSignOut } from "@/hooks/firebase/useSignOut"; import { @@ -32,6 +32,9 @@ import { userSettingsView, } from "@/components/pages/calendar/atoms"; import FeedbackNavIcon from "@/assets/svgs/FeedbackNavIcon"; +import Constants from "expo-constants"; +import * as Device from "expo-device"; +import { DeviceType } from "expo-device"; export default function TabLayout() { const { mutateAsync: signOut } = useSignOut(); @@ -44,11 +47,11 @@ export default function TabLayout() { ({ headerShown: true, headerRight: () => - Constants.isTablet ? ( - + Device.deviceType === DeviceType.TABLET ? ( + ) : ( <> ), @@ -57,7 +60,7 @@ export default function TabLayout() { backgroundColor: "#f9f8f7", height: "100%", }, - }} + })} drawerContent={(props) => { return ( diff --git a/app/(auth)/calendar/index.tsx b/app/(auth)/calendar/index.tsx index 8d47936..444563f 100644 --- a/app/(auth)/calendar/index.tsx +++ b/app/(auth)/calendar/index.tsx @@ -2,7 +2,17 @@ import React from "react"; import CalendarPage from "@/components/pages/calendar/CalendarPage"; import { Constants } from "react-native-ui-lib"; import TabletCalendarPage from "@/components/pages/(tablet_pages)/calendar/TabletCalendarPage"; +import { DeviceType } from "expo-device"; +import * as Device from "expo-device"; export default function Screen() { - return <>{Constants.isTablet ? : }; + return ( + <> + {Device.deviceType === DeviceType.TABLET ? ( + + ) : ( + + )} + + ); } diff --git a/app/(auth)/todos/index.tsx b/app/(auth)/todos/index.tsx index 518f346..33103a5 100644 --- a/app/(auth)/todos/index.tsx +++ b/app/(auth)/todos/index.tsx @@ -10,11 +10,16 @@ import { ToDosContextProvider, useToDosContext } from "@/contexts/ToDosContext"; import { AntDesign } from "@expo/vector-icons"; import { ScrollView } from "react-native-gesture-handler"; import { Button, ButtonSize, View, Text, Constants } from "react-native-ui-lib"; +import * as Device from "expo-device"; export default function Screen() { return ( - {Constants.isTablet ? : } + {Device.deviceType === Device.DeviceType.TABLET ? ( + + ) : ( + + )} ); } diff --git a/components/pages/(tablet_pages)/ViewSwitch.tsx b/components/pages/(tablet_pages)/ViewSwitch.tsx index d051681..0f1455e 100644 --- a/components/pages/(tablet_pages)/ViewSwitch.tsx +++ b/components/pages/(tablet_pages)/ViewSwitch.tsx @@ -1,10 +1,20 @@ import { Text, TouchableOpacity, View } from "react-native-ui-lib"; -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { StyleSheet } from "react-native"; +import { NavigationProp } from "@react-navigation/native"; +import view from "react-native-ui-lib/src/components/view"; -const ViewSwitch = () => { - const [view, setView] = useState(false); +interface ViewSwitchProps { + navigation: NavigationProp; // Adjust according to your navigation structure +} +const ViewSwitch: React.FC = ({ navigation }) => { + const [pageIndex, setPageIndex] = useState(navigation.getState().index); + + useEffect(() => { + setPageIndex(navigation.getState().index); + }, [navigation.getState().index]) + return ( { > { - setView(true); + navigation.navigate("calendar"); }} > { centerH height={54} paddingH-15 - style={view ? styles.switchBtnActive : styles.switchBtn} + style={ pageIndex == 1 || pageIndex == 0 ? styles.switchBtnActive : styles.switchBtn} > - + Calendar @@ -44,7 +54,7 @@ const ViewSwitch = () => { { - setView(false); + navigation.navigate("todos"); }} > { centerH height={54} paddingH-15 - style={!view ? styles.switchBtnActive : styles.switchBtn} + style={pageIndex == 6 ? styles.switchBtnActive : styles.switchBtn} > - + Chores diff --git a/components/pages/(tablet_pages)/calendar/TabletCalendarPage.tsx b/components/pages/(tablet_pages)/calendar/TabletCalendarPage.tsx index 3e709e0..8465b9b 100644 --- a/components/pages/(tablet_pages)/calendar/TabletCalendarPage.tsx +++ b/components/pages/(tablet_pages)/calendar/TabletCalendarPage.tsx @@ -1,56 +1,29 @@ import { View, Text } from "react-native-ui-lib"; import React, { useEffect } from "react"; import * as ScreenOrientation from "expo-screen-orientation"; -import { Dimensions, StyleSheet } from "react-native"; import { InnerCalendar } from "../../calendar/InnerCalendar"; - -const { width, height } = Dimensions.get("window"); +import TabletContainer from "../tablet_components/TabletContainer"; const TabletCalendarPage = () => { - // Function to lock the screen orientation to landscape const lockScreenOrientation = async () => { await ScreenOrientation.lockAsync( - ScreenOrientation.OrientationLock.LANDSCAPE_LEFT + ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT ); }; useEffect(() => { - lockScreenOrientation(); // Lock orientation when the component mounts + lockScreenOrientation(); return () => { - // Optional: Unlock to default when the component unmounts ScreenOrientation.unlockAsync(); }; }, []); return ( - - - - - - - - + + + ); }; -const styles = StyleSheet.create({ - container: { - backgroundColor: "white", - width: "100%", - flex: 1, - }, - calendarContainer: { - backgroundColor: "white", - height: height, - width: width * 0.85, - }, - profilesContainer: { - width: width * 0.15, - backgroundColor: "green", - height: height, - }, -}); - export default TabletCalendarPage; diff --git a/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx b/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx index 3bf40d8..c05b5d4 100644 --- a/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx +++ b/components/pages/(tablet_pages)/chores/TabletChoresPage.tsx @@ -5,7 +5,7 @@ import * as ScreenOrientation from 'expo-screen-orientation'; const TabletChoresPage = () => { // Function to lock the screen orientation to landscape const lockScreenOrientation = async () => { - await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_LEFT); + await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT); }; useEffect(() => { diff --git a/components/pages/(tablet_pages)/tablet_components/TabletContainer.tsx b/components/pages/(tablet_pages)/tablet_components/TabletContainer.tsx new file mode 100644 index 0000000..168f6ff --- /dev/null +++ b/components/pages/(tablet_pages)/tablet_components/TabletContainer.tsx @@ -0,0 +1,46 @@ +import { View, Text, ViewProps } from "react-native-ui-lib"; +import React, { ReactNode } from "react"; +import { Dimensions, StyleSheet } from "react-native"; +import UsersList from "./UsersList"; + +interface TabletContainerProps extends ViewProps { + children: ReactNode; +} + +const { width, height } = Dimensions.get("window"); + +const TabletContainer: React.FC = ({ + children, + ...props +}) => { + return ( + + + {children} + + + + + + ); +}; + +const styles = StyleSheet.create({ + container: { + backgroundColor: "white", + width: "100%", + flex: 1, + }, + calendarContainer: { + backgroundColor: "white", + height: height, + width: width * 0.85, + }, + profilesContainer: { + width: width * 0.15, + backgroundColor: "green", + height: height, + }, +}); + +export default TabletContainer; diff --git a/components/pages/(tablet_pages)/tablet_components/UsersList.tsx b/components/pages/(tablet_pages)/tablet_components/UsersList.tsx new file mode 100644 index 0000000..6104a1e --- /dev/null +++ b/components/pages/(tablet_pages)/tablet_components/UsersList.tsx @@ -0,0 +1,27 @@ +import { View, Text } from "react-native-ui-lib"; +import React from "react"; + +const UsersList = () => { + return ( + + + + + ); +}; + +export default UsersList;