Update dark mode
This commit is contained in:
parent
84aab76737
commit
4b2d3b8b32
6 changed files with 45 additions and 28 deletions
|
@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react';
|
|||
import { StyleSheet, ScrollView, SafeAreaView, View, StatusBar } from 'react-native';
|
||||
// @ts-ignore
|
||||
import CalendarPicker from 'react-native-calendar-picker';
|
||||
import Ionicons from '@expo/vector-icons/Ionicons';
|
||||
import { useIsFocused } from '@react-navigation/core';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { LogLevel, OneSignal } from 'react-native-onesignal';
|
||||
|
@ -15,12 +14,13 @@ import { useToken } from '@/lib/context/AppProvider';
|
|||
import { Request } from '@/lib/services/request';
|
||||
import List from '@/lib/components/List';
|
||||
import { Message } from '@/lib/services/message';
|
||||
import { ThemedIcon } from '@/lib/components/ThemedIcon';
|
||||
|
||||
export default function HomeScreen() {
|
||||
const colorScheme = useColorScheme() ?? 'light';
|
||||
const isFocused = useIsFocused();
|
||||
const session = useSelector((state: any) => state.data.session);
|
||||
const reloadCalendar = useSelector((state: any) => state.data.reloadCalendar);
|
||||
const session = useSelector( (state: any) => state.data.session );
|
||||
const reloadCalendar = useSelector( (state: any) => state.data.reloadCalendar );
|
||||
const { token, isLoading } = useToken();
|
||||
const [ name, setName ] = useState( ' ' ); // Default empty space to prevent layout shifting
|
||||
const [ dates, setDates ] = useState<any | null>( [] );
|
||||
|
@ -29,15 +29,15 @@ export default function HomeScreen() {
|
|||
|
||||
const loadOneSignal = () => {
|
||||
// Remove this method to stop OneSignal Debugging
|
||||
OneSignal.Debug.setLogLevel(LogLevel.Verbose);
|
||||
OneSignal.Debug.setLogLevel( LogLevel.Verbose );
|
||||
|
||||
// OneSignal Initialization
|
||||
OneSignal.initialize("6ef15aa7-9dc0-4d8b-b6b1-e2005bcd3dc6");
|
||||
OneSignal.initialize( "6ef15aa7-9dc0-4d8b-b6b1-e2005bcd3dc6" );
|
||||
|
||||
// Request permission
|
||||
OneSignal.Notifications.requestPermission(true).then(() => {
|
||||
OneSignal.Notifications.requestPermission( true ).then( () => {
|
||||
// Retrieve one signal user token
|
||||
OneSignal.User.pushSubscription.getIdAsync().then((notificationsToken) => {
|
||||
OneSignal.User.pushSubscription.getIdAsync().then( (notificationsToken) => {
|
||||
if (notificationsToken) {
|
||||
Request.post( 'sessions/update', { token: token, notifications_token: notificationsToken } ).then( (response) => {
|
||||
if (!response.success) {
|
||||
|
@ -45,22 +45,22 @@ export default function HomeScreen() {
|
|||
}
|
||||
} );
|
||||
}
|
||||
})
|
||||
})
|
||||
} )
|
||||
} )
|
||||
|
||||
// Disable loading again
|
||||
setOnesignalLoaded(true);
|
||||
setOnesignalLoaded( true );
|
||||
}
|
||||
|
||||
// Load OneSignal
|
||||
useEffect( () => {
|
||||
loadOneSignal();
|
||||
}, [onesignalLoaded] );
|
||||
}, [ onesignalLoaded ] );
|
||||
|
||||
// Load session
|
||||
useEffect( () => {
|
||||
setName(session.name);
|
||||
}, [session, isFocused]);
|
||||
setName( session.name );
|
||||
}, [ session, isFocused ] );
|
||||
|
||||
useEffect( () => {
|
||||
if (token) {
|
||||
|
@ -108,11 +108,13 @@ export default function HomeScreen() {
|
|||
enableDateChange={false}
|
||||
customDatesStyles={dates}
|
||||
todayTextStyle={styles.today}
|
||||
textStyle={{ color: Colors[ colorScheme ].text }}
|
||||
startFromMonday={true}
|
||||
previousComponent={
|
||||
<Ionicons size={28} name="chevron-back"/>
|
||||
<ThemedIcon size={28} name="chevron-back"/>
|
||||
}
|
||||
nextComponent={
|
||||
<Ionicons size={28} name="chevron-forward"/>
|
||||
<ThemedIcon size={28} name="chevron-forward"/>
|
||||
}
|
||||
weekdays={[ "Zo", "Ma", "Di", "Woe", "Do", "Vrij", "Zat" ]}
|
||||
months={[
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue