From ba5d2697c5c6a6aceaac17ac3e80f20e6135260c Mon Sep 17 00:00:00 2001 From: Djalim Simaila Date: Wed, 3 Apr 2024 14:31:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20style(App.tsx,=20SignIn.tsx,=20S?= =?UTF-8?q?ignUp.tsx,=20ClipElementLocal.tsx,=20ClipElementRemote.tsx,=20C?= =?UTF-8?q?lipList.tsx,=20ClipView.tsx,=20ClipViewLocal.tsx,=20ClipViewRem?= =?UTF-8?q?ote.tsx,=20Auth.tsx,=20Clips.tsx,=20Intro.tsx,=20Settings.tsx):?= =?UTF-8?q?=20Improve=20UI/UX=20by=20adding=20responsive=20design=20and=20?= =?UTF-8?q?theme=20support=20=F0=9F=94=A7=20refactor(App.tsx,=20SignIn.tsx?= =?UTF-8?q?,=20SignUp.tsx,=20ClipElementLocal.tsx,=20ClipElementRemote.tsx?= =?UTF-8?q?,=20ClipList.tsx,=20ClipView.tsx,=20ClipViewLocal.tsx,=20ClipVi?= =?UTF-8?q?ewRemote.tsx,=20Auth.tsx,=20Clips.tsx,=20Intro.tsx,=20Settings.?= =?UTF-8?q?tsx):=20Refactor=20code=20for=20better=20readability=20and=20ma?= =?UTF-8?q?intainability=20=F0=9F=94=A5=20remove(ClipElementLocal.tsx,=20C?= =?UTF-8?q?lipElementRemote.tsx,=20ClipList.tsx):=20Remove=20unused=20impo?= =?UTF-8?q?rts=20and=20props=20=E2=9C=A8=20feat(App.tsx,=20SignIn.tsx,=20S?= =?UTF-8?q?ignUp.tsx,=20ClipElementLocal.tsx,=20ClipElementRemote.tsx,=20C?= =?UTF-8?q?lipList.tsx,=20ClipView.tsx,=20ClipViewLocal.tsx,=20ClipViewRem?= =?UTF-8?q?ote.tsx,=20Auth.tsx,=20Clips.tsx,=20Intro.tsx,=20Settings.tsx,?= =?UTF-8?q?=20themes.ts,=20utils.ts):=20Add=20new=20features=20such=20as?= =?UTF-8?q?=20theme=20support,=20responsive=20design,=20and=20utility=20fu?= =?UTF-8?q?nctions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.tsx | 21 ++- src/components/auth/SignIn.tsx | 27 ++- src/components/auth/SignUp.tsx | 36 ++-- src/components/clip/ClipElementLocal.tsx | 3 +- src/components/clip/ClipElementRemote.tsx | 15 +- src/components/clip/ClipList.tsx | 3 +- src/components/clip/ClipView.tsx | 51 ++++++ src/components/clip/ClipViewLocal.tsx | 17 +- src/components/clip/ClipViewRemote.tsx | 39 +++-- src/pages/Auth.tsx | 13 ++ src/pages/Clips.tsx | 194 ++++++++++++++-------- src/pages/Intro.tsx | 18 +- src/pages/Settings.tsx | 26 +++ src/themes.ts | 28 ++++ src/utils.ts | 11 ++ 15 files changed, 364 insertions(+), 138 deletions(-) create mode 100644 src/components/clip/ClipView.tsx create mode 100644 src/themes.ts create mode 100644 src/utils.ts diff --git a/App.tsx b/App.tsx index 2355343..a6c4a21 100644 --- a/App.tsx +++ b/App.tsx @@ -1,7 +1,7 @@ import 'react-native-gesture-handler'; // ^ le bouge pas ca casse tout ^ import { useState } from "react"; -import { NavigationContainer } from '@react-navigation/native'; +import { NavigationContainer, DefaultTheme } from '@react-navigation/native'; import { createNativeStackNavigator } from '@react-navigation/native-stack'; import { Provider } from 'react-redux'; import { store } from './src/redux/store'; @@ -11,25 +11,33 @@ import AuthPage from './src/pages/Auth'; import ClipPage from './src/pages/Clips'; import IntroPage from './src/pages/Intro'; import { StatusBar } from 'expo-status-bar'; +import { Material3Dracula, ReactNavigationDracula } from './src/themes'; +import { PixelRatio, useWindowDimensions } from 'react-native'; +import { SafeAreaProvider } from 'react-native-safe-area-context'; const Stack = createNativeStackNavigator(); + + function App(){ const [token,setToken] = useState(""); const [username,setUsername] = useState(""); - + + const {height,width} = useWindowDimensions(); + console.log(width); + console.log(PixelRatio.get()) + store.subscribe(()=>{ - console.log("state Changed .w."); let newToken = store.getState().user.token; setToken(newToken); - console.log(store.getState()); }) return ( - + - + + { token !== "" ? ( @@ -45,6 +53,7 @@ function App(){ } + diff --git a/src/components/auth/SignIn.tsx b/src/components/auth/SignIn.tsx index 21f5c2f..1d39919 100644 --- a/src/components/auth/SignIn.tsx +++ b/src/components/auth/SignIn.tsx @@ -1,10 +1,12 @@ import axios from 'axios'; import React from 'react'; -import { View, Text } from 'react-native'; +import { View, Text, Platform, useWindowDimensions } from 'react-native'; import { useToast } from "react-native-toast-notifications"; import { Button, TextInput } from 'react-native-paper'; import { login } from '../../redux/reducers'; import { useDispatch } from 'react-redux'; +import { ReactNavigationDracula as t } from '../../themes'; +import { ps } from '../../utils'; export default function SignIn(){ const [username, setUsername] = React.useState(""); @@ -12,7 +14,8 @@ export default function SignIn(){ const [token,setToken] = React.useState(""); const toast = useToast(); const dispatch = useDispatch(); - + const {height, width} = useWindowDimensions(); + async function signInFunction(dispatch) { axios.post("https://notifysync.simailadjalim.fr/user",{ @@ -32,16 +35,22 @@ export default function SignIn(){ }); } - return + alignItems:"center", + backgroundColor: width > 600 ? t.colors.card : t.colors.background, + }]}> - + Connexion } diff --git a/src/components/clip/ClipElementRemote.tsx b/src/components/clip/ClipElementRemote.tsx index f7bf90e..990cefb 100644 --- a/src/components/clip/ClipElementRemote.tsx +++ b/src/components/clip/ClipElementRemote.tsx @@ -1,11 +1,10 @@ import { View } from 'react-native'; import IconVector from 'react-native-vector-icons/FontAwesome5'; -import { Store } from 'redux'; import * as Clipboard from 'expo-clipboard'; import { useToast } from "react-native-toast-notifications"; -import { Avatar, Card, Text } from 'react-native-paper'; +import { Card, Text, Button } from 'react-native-paper'; -export default function ClipElementRemote({content,timestamp,deviceName,store}:{content:string;timestamp:number,deviceName:string;store: Store}){ +export default function ClipElementRemote({content,timestamp,deviceName}:{content:string;timestamp:number,deviceName:string}){ const toast = useToast(); function onCopy() { @@ -18,19 +17,17 @@ export default function ClipElementRemote({content,timestamp,deviceName,store}:{ const date= new Date(timestamp*1000); return( - + + - {content.length >28 ?content.slice(0,24)+"...":content } {date.getHours() + ":" + date.getMinutes() + ", "+ date.toDateString()} {deviceName} - - onCopy()} /> - ); } diff --git a/src/components/clip/ClipList.tsx b/src/components/clip/ClipList.tsx index e949a32..0af4df6 100644 --- a/src/components/clip/ClipList.tsx +++ b/src/components/clip/ClipList.tsx @@ -9,7 +9,7 @@ export default class ClipList extends React.Component { } createClipElementLocal(content: string): JSX.Element { - return ; + return ; } createClipElementRemote( @@ -19,7 +19,6 @@ export default class ClipList extends React.Component { ): JSX.Element { return ( + + + { + layout == "compact"? ( + + + {() => ( + + )} + + + {()=> ( + + )} + + + ):( + + + + + ) + } + + + ) +} diff --git a/src/components/clip/ClipViewLocal.tsx b/src/components/clip/ClipViewLocal.tsx index 5f96732..21a3eaf 100644 --- a/src/components/clip/ClipViewLocal.tsx +++ b/src/components/clip/ClipViewLocal.tsx @@ -1,18 +1,18 @@ import React from 'react'; -import {ScrollView, Text} from 'react-native'; +import {ScrollView, View, Text, useWindowDimensions} from 'react-native'; import { Button } from 'react-native-paper'; import ClipList from './ClipList'; import { useDispatch } from 'react-redux'; import { localAddToList } from '../../redux/reducers'; import { useToast } from 'react-native-toast-notifications'; import * as Clipboard from 'expo-clipboard'; - - +import { ps } from '../../utils'; export default function ClipViewLocal({}){ const [clips, setClips] = React.useState([]); const dispatch = useDispatch(); const toast = useToast(); + const {height,width} = useWindowDimensions(); let title = 'Local Clipboard'; @@ -37,8 +37,13 @@ export default function ClipViewLocal({}){ } return ( - - + + ); } diff --git a/src/components/clip/ClipViewRemote.tsx b/src/components/clip/ClipViewRemote.tsx index 21f24c2..809b9d0 100644 --- a/src/components/clip/ClipViewRemote.tsx +++ b/src/components/clip/ClipViewRemote.tsx @@ -1,24 +1,26 @@ import React from 'react'; import axios from 'axios'; -import { ScrollView, Text } from 'react-native'; +import { ScrollView,View, Text, useWindowDimensions } from 'react-native'; import ClipList from './ClipList'; import { store } from '../../redux/store'; import { useToast } from 'react-native-toast-notifications'; import { Button } from 'react-native-paper'; +import { ps } from '../../utils'; - -export default function ClipViewRemote({type} :{type:string} ){ +export default function ClipViewRemote(){ const [clips,setClips] = React.useState([]); const toast = useToast(); + const {height,width} = useWindowDimensions(); + function getClips() { axios.get("http://notifysync.simailadjalim.fr/clipboard?token="+store.getState().user.token) - .then((response,status) => { - console.log(response); - setClips(Object.values(response["data"]['clipboard'])); - toast.show("fetched latest clips from remote"); - }) - .catch(response =>{ + .then((response,status) => { + console.log(response); + setClips(Object.values(response["data"]['clipboard'])); + toast.show("fetched latest clips from remote"); + }) + .catch(response =>{ console.log(response); toast.show("failed to fetch latest clips"); }); @@ -29,13 +31,18 @@ export default function ClipViewRemote({type} :{type:string} ){ } let title = "Remote Clipboard"; - return <> - - - + return 600 ? ps(10) : 0 + }}> + + + - ; + ; } diff --git a/src/pages/Auth.tsx b/src/pages/Auth.tsx index 524996f..a5625b7 100644 --- a/src/pages/Auth.tsx +++ b/src/pages/Auth.tsx @@ -1,10 +1,22 @@ +import { Platform, View, useWindowDimensions } from "react-native"; import SignIn from "../components/auth/SignIn"; import SignUp from "../components/auth/SignUp"; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; +import { ps } from "../utils"; export default function AuthPage(){ + const {height, width} = useWindowDimensions(); + const Tab = createMaterialTopTabNavigator(); + if (width > 700){ + return ( + + + + + );} + else{ return( ); + } } diff --git a/src/pages/Clips.tsx b/src/pages/Clips.tsx index 4e4c036..3a89ace 100644 --- a/src/pages/Clips.tsx +++ b/src/pages/Clips.tsx @@ -1,14 +1,15 @@ import React from "react"; -import ClipViewLocal from "../components/clip/ClipViewLocal"; -import ClipViewRemote from "../components/clip/ClipViewRemote"; import { Drawer as DrawerLayout } from 'react-native-drawer-layout'; -import { Button, Drawer } from 'react-native-paper'; -import { store } from "../redux/store"; -import { Platform, View,StyleSheet } from "react-native"; +import { Button, Drawer, Searchbar } from 'react-native-paper'; +import { Platform, View,StyleSheet, useWindowDimensions, ScrollView } from "react-native"; import { createMaterialTopTabNavigator } from '@react-navigation/material-top-tabs'; import { Appbar, Modal, Text, Portal } from 'react-native-paper'; import { useDispatch } from 'react-redux'; import { disconnect } from "../redux/reducers"; +import { ps } from "../utils"; +import { ReactNavigationDracula as t } from "../themes"; +import ClipView from "../components/clip/ClipView"; +import Settings from "./Settings"; const styles = StyleSheet.create({ modal: { @@ -24,90 +25,137 @@ const styles = StyleSheet.create({ export default function ClipPage(){ const [open, setOpen] = React.useState(false); const [visible, setVisible] = React.useState(false); - const Tab = createMaterialTopTabNavigator(); const [active, setActive] = React.useState('clips'); const dispatch = useDispatch() - const showModal = () => setVisible(true); const hideModal = () => setVisible(false); const containerStyle = {backgroundColor: 'white', padding: 20}; - function signout(){ - setVisible(true); - //dispatch(disconnect()); + const {height, width} = useWindowDimensions(); + + let layout = "" + + if (width < 600) layout = "compact"; + else if (width < 1200 ) layout = "medium"; + else layout = "expanded"; + + + let style = {}; + if (layout == "medium"){ + style = StyleSheet.create({ + drawer: { + backgroundColor: t.colors.background, + width : 100 + } + }) + } else { + style = StyleSheet.create({ + drawer : { + backgroundColor: t.colors.background + } + }) } - return (<> + let page; + if (active == "clips") page = ; + if (active == "notif") page = ; + if (active == "settings") page = ; + + return ( - - Do you really want to sign out? - - - - + Do you really want to sign out? + + + + setOpen(true)} onClose={() => setOpen(false)} + drawerStyle={style.drawer} renderDrawerContent={() => { - return <> - - setActive('clips')} - /> - setActive('second')} - /> - - - signout()} - /> - - + if (layout != "medium"){ + return <> + + { + setActive('clips'); + setOpen(false) + }} + /> + { + setActive('settings'); + setOpen(false) + }} + /> + + + setVisible(true)} + label="Sign out" + /> + + + }else{ + return + + { + setActive('clips'); + setOpen(false) + }} + /> + { + setActive('settings'); + setOpen(false) + }} + /> + + + setVisible(true)} + /> + + + } }} > - - {setOpen(true)}} /> - - - - - {props => ( - - )} - - - {props => ( - - )} - - + {page} - + ); } diff --git a/src/pages/Intro.tsx b/src/pages/Intro.tsx index fa405ab..ce94751 100644 --- a/src/pages/Intro.tsx +++ b/src/pages/Intro.tsx @@ -1,11 +1,23 @@ import { View, Text } from "react-native"; import { Button } from 'react-native-paper'; +import { ps } from "../utils"; +import { ReactNavigationDracula as t } from "../themes"; export default function IntroPage({navigation}){ return( - - - Holla Benvenido in l'application du turfu + + + Salut, bienvenue dans ClipSync :) connecte toi pour commencer