Front: Typecheck Navigators and hooks
This commit is contained in:
@@ -1,9 +1,8 @@
|
|||||||
import { Appearance } from "react-native";
|
import { Appearance } from "react-native";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "../state/Store";
|
||||||
import { RootState } from "../state/Store";
|
|
||||||
|
|
||||||
const useColorScheme = (): 'light' | 'dark' => {
|
const useColorScheme = (): 'light' | 'dark' => {
|
||||||
const colorScheme = useSelector((state: RootState) => state.settings.local.colorScheme);
|
const colorScheme = useSelector((state) => state.settings.local.colorScheme);
|
||||||
const systemColorScheme = Appearance.getColorScheme();
|
const systemColorScheme = Appearance.getColorScheme();
|
||||||
|
|
||||||
if (colorScheme == 'system') {
|
if (colorScheme == 'system') {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
interface LocalSettings {
|
export default interface LocalSettings {
|
||||||
deviceId: number,
|
deviceId: number,
|
||||||
micVolume: number,
|
micVolume: number,
|
||||||
colorScheme: 'light' | 'dark' | 'system',
|
colorScheme: 'light' | 'dark' | 'system',
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||||
|
import LocalSettings from "../models/LocalSettings";
|
||||||
|
|
||||||
export const settingsSlice = createSlice({
|
export const settingsSlice = createSlice({
|
||||||
name: 'settings',
|
name: 'settings',
|
||||||
|
|||||||
+3
-1
@@ -100,6 +100,8 @@
|
|||||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules", "babel.config.js", "metro.config.js", "jest.config.js"
|
"node_modules", "babel.config.js", "metro.config.js",
|
||||||
|
"jest.config.js", "app.config.ts",
|
||||||
|
"*/*.test.tsx"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,18 +11,14 @@ import {
|
|||||||
translate,
|
translate,
|
||||||
Translate,
|
Translate,
|
||||||
} from "../../i18n/i18n";
|
} from "../../i18n/i18n";
|
||||||
import { RootState, useSelector } from "../../state/Store";
|
import { useSelector } from "../../state/Store";
|
||||||
import { updateSettings } from "../../state/SettingsSlice";
|
import { updateSettings } from "../../state/SettingsSlice";
|
||||||
import ElementList from "../../components/GtkUI/ElementList";
|
import ElementList from "../../components/GtkUI/ElementList";
|
||||||
|
|
||||||
const PreferencesView = () => {
|
const PreferencesView = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const language: AvailableLanguages = useSelector(
|
const language = useSelector((state) => state.language.value);
|
||||||
(state: RootState) => state.language.value
|
const settings = useSelector((state) => state.settings.local);
|
||||||
);
|
|
||||||
const settings = useSelector(
|
|
||||||
(state: RootState) => state.settings.local
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<Center style={{ flex: 1 }}>
|
<Center style={{ flex: 1 }}>
|
||||||
<Heading style={{ textAlign: "center" }}>
|
<Heading style={{ textAlign: "center" }}>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { Center, Button, Text, Heading, Box } from "native-base";
|
import { Center, Button, Text, Heading, Box } from "native-base";
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import { unsetAccessToken } from '../../state/UserSlice';
|
import { unsetAccessToken } from '../../state/UserSlice';
|
||||||
@@ -16,9 +16,6 @@ import GuestToUserView from './GuestToUserView';
|
|||||||
import { useQuery } from 'react-query';
|
import { useQuery } from 'react-query';
|
||||||
import API from '../../API';
|
import API from '../../API';
|
||||||
|
|
||||||
|
|
||||||
const SettingsStack = createNativeStackNavigator();
|
|
||||||
|
|
||||||
const handleChangeEmail = async (newEmail: string): Promise<string> => {
|
const handleChangeEmail = async (newEmail: string): Promise<string> => {
|
||||||
try {
|
try {
|
||||||
let response = await API.updateUserEmail(newEmail);
|
let response = await API.updateUserEmail(newEmail);
|
||||||
@@ -37,43 +34,7 @@ const handleChangePassword = async (oldPassword: string, newPassword: string): P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const MainView = ({ navigation }) => {
|
export const ChangePasswordView = () => {
|
||||||
const dispatch = useDispatch();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Center style={{ flex: 1}}>
|
|
||||||
<Button variant='ghost' onPress={() => navigation.navigate('Preferences')}>
|
|
||||||
<Translate translationKey='prefBtn'/>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button variant='ghost' onPress={() => navigation.navigate('Notifications')}>
|
|
||||||
<Translate translationKey='notifBtn'/>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button variant='ghost' onPress={() => navigation.navigate('Privacy')}>
|
|
||||||
<Translate translationKey='privBtn'/>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button variant='ghost' onPress={() => navigation.navigate('ChangePassword')}>
|
|
||||||
<Translate translationKey='changepasswdBtn'/>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button variant='ghost' onPress={() => navigation.navigate('ChangeEmail')}>
|
|
||||||
<Translate translationKey='changeemailBtn'/>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button variant='ghost' onPress={() => navigation.navigate('GoogleAccount')}>
|
|
||||||
<Translate translationKey='googleacctBtn'/>
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
<Button variant='ghost' onPress={() => dispatch(unsetAccessToken())} >
|
|
||||||
<Translate translationKey='signOutBtn'/>
|
|
||||||
</Button>
|
|
||||||
</Center>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ChangePasswordView = ({ navigation }) => {
|
|
||||||
return (
|
return (
|
||||||
<Center style={{ flex: 1}}>
|
<Center style={{ flex: 1}}>
|
||||||
<Heading paddingBottom={'2%'}>{translate('changePassword')}</Heading>
|
<Heading paddingBottom={'2%'}>{translate('changePassword')}</Heading>
|
||||||
@@ -82,7 +43,7 @@ export const ChangePasswordView = ({ navigation }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ChangeEmailView = ({ navigation }) => {
|
export const ChangeEmailView = () => {
|
||||||
return (
|
return (
|
||||||
<Center style={{ flex: 1}}>
|
<Center style={{ flex: 1}}>
|
||||||
<Heading paddingBottom={'2%'}>{translate('changeEmail')}</Heading>
|
<Heading paddingBottom={'2%'}>{translate('changeEmail')}</Heading>
|
||||||
@@ -91,7 +52,7 @@ export const ChangeEmailView = ({ navigation }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GoogleAccountView = ({ navigation }) => {
|
export const GoogleAccountView = () => {
|
||||||
return (
|
return (
|
||||||
<Center style={{ flex: 1}}>
|
<Center style={{ flex: 1}}>
|
||||||
<Text>GoogleAccount</Text>
|
<Text>GoogleAccount</Text>
|
||||||
@@ -99,7 +60,7 @@ export const GoogleAccountView = ({ navigation }) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const PianoSettingsView = ({ navigation }) => {
|
export const PianoSettingsView = () => {
|
||||||
return (
|
return (
|
||||||
<Center style={{ flex: 1}}>
|
<Center style={{ flex: 1}}>
|
||||||
<Text>Global settings for the virtual piano</Text>
|
<Text>Global settings for the virtual piano</Text>
|
||||||
@@ -113,10 +74,6 @@ const SetttingsNavigator = () => {
|
|||||||
const userQuery = useQuery(['user'], () => API.getUserInfo());
|
const userQuery = useQuery(['user'], () => API.getUserInfo());
|
||||||
const user = useMemo(() => userQuery.data, [userQuery]);
|
const user = useMemo(() => userQuery.data, [userQuery]);
|
||||||
|
|
||||||
if (userQuery.isError) {
|
|
||||||
user.isGuest = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (userQuery.isLoading) {
|
if (userQuery.isLoading) {
|
||||||
return (
|
return (
|
||||||
<Center style={{ flex: 1}}>
|
<Center style={{ flex: 1}}>
|
||||||
|
|||||||
Reference in New Issue
Block a user