mirror of
https://github.com/urosran/cally.git
synced 2025-11-26 08:24:55 +00:00
changes to tablet detection and more
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import { Drawer } from "expo-router/drawer";
|
import { Drawer } from "expo-router/drawer";
|
||||||
import { useSignOut } from "@/hooks/firebase/useSignOut";
|
import { useSignOut } from "@/hooks/firebase/useSignOut";
|
||||||
import {
|
import {
|
||||||
@ -32,6 +32,9 @@ import {
|
|||||||
userSettingsView,
|
userSettingsView,
|
||||||
} from "@/components/pages/calendar/atoms";
|
} from "@/components/pages/calendar/atoms";
|
||||||
import FeedbackNavIcon from "@/assets/svgs/FeedbackNavIcon";
|
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() {
|
export default function TabLayout() {
|
||||||
const { mutateAsync: signOut } = useSignOut();
|
const { mutateAsync: signOut } = useSignOut();
|
||||||
@ -44,11 +47,11 @@ export default function TabLayout() {
|
|||||||
<Drawer
|
<Drawer
|
||||||
initialRouteName={"index"}
|
initialRouteName={"index"}
|
||||||
detachInactiveScreens
|
detachInactiveScreens
|
||||||
screenOptions={{
|
screenOptions={({ navigation }) => ({
|
||||||
headerShown: true,
|
headerShown: true,
|
||||||
headerRight: () =>
|
headerRight: () =>
|
||||||
Constants.isTablet ? (
|
Device.deviceType === DeviceType.TABLET ? (
|
||||||
<ViewSwitch />
|
<ViewSwitch navigation={navigation} />
|
||||||
) : (
|
) : (
|
||||||
<></>
|
<></>
|
||||||
),
|
),
|
||||||
@ -57,7 +60,7 @@ export default function TabLayout() {
|
|||||||
backgroundColor: "#f9f8f7",
|
backgroundColor: "#f9f8f7",
|
||||||
height: "100%",
|
height: "100%",
|
||||||
},
|
},
|
||||||
}}
|
})}
|
||||||
drawerContent={(props) => {
|
drawerContent={(props) => {
|
||||||
return (
|
return (
|
||||||
<DrawerContentScrollView {...props} style={{}}>
|
<DrawerContentScrollView {...props} style={{}}>
|
||||||
|
|||||||
@ -2,7 +2,17 @@ import React from "react";
|
|||||||
import CalendarPage from "@/components/pages/calendar/CalendarPage";
|
import CalendarPage from "@/components/pages/calendar/CalendarPage";
|
||||||
import { Constants } from "react-native-ui-lib";
|
import { Constants } from "react-native-ui-lib";
|
||||||
import TabletCalendarPage from "@/components/pages/(tablet_pages)/calendar/TabletCalendarPage";
|
import TabletCalendarPage from "@/components/pages/(tablet_pages)/calendar/TabletCalendarPage";
|
||||||
|
import { DeviceType } from "expo-device";
|
||||||
|
import * as Device from "expo-device";
|
||||||
|
|
||||||
export default function Screen() {
|
export default function Screen() {
|
||||||
return <>{Constants.isTablet ? <TabletCalendarPage /> : <CalendarPage />}</>;
|
return (
|
||||||
|
<>
|
||||||
|
{Device.deviceType === DeviceType.TABLET ? (
|
||||||
|
<TabletCalendarPage />
|
||||||
|
) : (
|
||||||
|
<CalendarPage />
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,11 +10,16 @@ import { ToDosContextProvider, useToDosContext } from "@/contexts/ToDosContext";
|
|||||||
import { AntDesign } from "@expo/vector-icons";
|
import { AntDesign } from "@expo/vector-icons";
|
||||||
import { ScrollView } from "react-native-gesture-handler";
|
import { ScrollView } from "react-native-gesture-handler";
|
||||||
import { Button, ButtonSize, View, Text, Constants } from "react-native-ui-lib";
|
import { Button, ButtonSize, View, Text, Constants } from "react-native-ui-lib";
|
||||||
|
import * as Device from "expo-device";
|
||||||
|
|
||||||
export default function Screen() {
|
export default function Screen() {
|
||||||
return (
|
return (
|
||||||
<ToDosContextProvider>
|
<ToDosContextProvider>
|
||||||
{Constants.isTablet ? <TabletChoresPage /> : <ToDosPage />}
|
{Device.deviceType === Device.DeviceType.TABLET ? (
|
||||||
|
<TabletChoresPage />
|
||||||
|
) : (
|
||||||
|
<ToDosPage />
|
||||||
|
)}
|
||||||
</ToDosContextProvider>
|
</ToDosContextProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,19 @@
|
|||||||
import { Text, TouchableOpacity, View } from "react-native-ui-lib";
|
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 { StyleSheet } from "react-native";
|
||||||
|
import { NavigationProp } from "@react-navigation/native";
|
||||||
|
import view from "react-native-ui-lib/src/components/view";
|
||||||
|
|
||||||
const ViewSwitch = () => {
|
interface ViewSwitchProps {
|
||||||
const [view, setView] = useState<boolean>(false);
|
navigation: NavigationProp<any>; // Adjust according to your navigation structure
|
||||||
|
}
|
||||||
|
|
||||||
|
const ViewSwitch: React.FC<ViewSwitchProps> = ({ navigation }) => {
|
||||||
|
const [pageIndex, setPageIndex] = useState<number>(navigation.getState().index);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setPageIndex(navigation.getState().index);
|
||||||
|
}, [navigation.getState().index])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
@ -26,7 +36,7 @@ const ViewSwitch = () => {
|
|||||||
>
|
>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setView(true);
|
navigation.navigate("calendar");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
@ -34,9 +44,9 @@ const ViewSwitch = () => {
|
|||||||
centerH
|
centerH
|
||||||
height={54}
|
height={54}
|
||||||
paddingH-15
|
paddingH-15
|
||||||
style={view ? styles.switchBtnActive : styles.switchBtn}
|
style={ pageIndex == 1 || pageIndex == 0 ? styles.switchBtnActive : styles.switchBtn}
|
||||||
>
|
>
|
||||||
<Text color={view ? "white" : "black"} style={styles.switchTxt}>
|
<Text color={pageIndex == 1 || pageIndex == 0 ? "white" : "black"} style={styles.switchTxt}>
|
||||||
Calendar
|
Calendar
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
@ -44,7 +54,7 @@ const ViewSwitch = () => {
|
|||||||
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
setView(false);
|
navigation.navigate("todos");
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<View
|
<View
|
||||||
@ -52,9 +62,9 @@ const ViewSwitch = () => {
|
|||||||
centerH
|
centerH
|
||||||
height={54}
|
height={54}
|
||||||
paddingH-15
|
paddingH-15
|
||||||
style={!view ? styles.switchBtnActive : styles.switchBtn}
|
style={pageIndex == 6 ? styles.switchBtnActive : styles.switchBtn}
|
||||||
>
|
>
|
||||||
<Text color={!view ? "white" : "black"} style={styles.switchTxt}>
|
<Text color={pageIndex == 6 ? "white" : "black"} style={styles.switchTxt}>
|
||||||
Chores
|
Chores
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@ -1,56 +1,29 @@
|
|||||||
import { View, Text } from "react-native-ui-lib";
|
import { View, Text } from "react-native-ui-lib";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import * as ScreenOrientation from "expo-screen-orientation";
|
import * as ScreenOrientation from "expo-screen-orientation";
|
||||||
import { Dimensions, StyleSheet } from "react-native";
|
|
||||||
import { InnerCalendar } from "../../calendar/InnerCalendar";
|
import { InnerCalendar } from "../../calendar/InnerCalendar";
|
||||||
|
import TabletContainer from "../tablet_components/TabletContainer";
|
||||||
const { width, height } = Dimensions.get("window");
|
|
||||||
|
|
||||||
const TabletCalendarPage = () => {
|
const TabletCalendarPage = () => {
|
||||||
// Function to lock the screen orientation to landscape
|
|
||||||
const lockScreenOrientation = async () => {
|
const lockScreenOrientation = async () => {
|
||||||
await ScreenOrientation.lockAsync(
|
await ScreenOrientation.lockAsync(
|
||||||
ScreenOrientation.OrientationLock.LANDSCAPE_LEFT
|
ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
lockScreenOrientation(); // Lock orientation when the component mounts
|
lockScreenOrientation();
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
// Optional: Unlock to default when the component unmounts
|
|
||||||
ScreenOrientation.unlockAsync();
|
ScreenOrientation.unlockAsync();
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<TabletContainer>
|
||||||
<View row>
|
<InnerCalendar />
|
||||||
<View style={styles.calendarContainer}>
|
</TabletContainer>
|
||||||
<InnerCalendar />
|
|
||||||
</View>
|
|
||||||
<View style={styles.profilesContainer}></View>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
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;
|
export default TabletCalendarPage;
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import * as ScreenOrientation from 'expo-screen-orientation';
|
|||||||
const TabletChoresPage = () => {
|
const TabletChoresPage = () => {
|
||||||
// Function to lock the screen orientation to landscape
|
// Function to lock the screen orientation to landscape
|
||||||
const lockScreenOrientation = async () => {
|
const lockScreenOrientation = async () => {
|
||||||
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_LEFT);
|
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE_RIGHT);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@ -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<TabletContainerProps> = ({
|
||||||
|
children,
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<View row>
|
||||||
|
<View style={styles.calendarContainer}>{children}</View>
|
||||||
|
<View style={styles.profilesContainer}>
|
||||||
|
<UsersList />
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
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;
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
import { View, Text } from "react-native-ui-lib";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const UsersList = () => {
|
||||||
|
return (
|
||||||
|
<View centerH gap-20>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
aspectRatio: 1,
|
||||||
|
width: 113,
|
||||||
|
backgroundColor: "red",
|
||||||
|
borderRadius: 100,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
aspectRatio: 1,
|
||||||
|
width: 113,
|
||||||
|
backgroundColor: "red",
|
||||||
|
borderRadius: 100,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UsersList;
|
||||||
Reference in New Issue
Block a user