Front: Typecheck Navigators and hooks
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { Appearance } from "react-native";
|
||||
import { useSelector } from "react-redux";
|
||||
import { RootState } from "../state/Store";
|
||||
import { useSelector } from "../state/Store";
|
||||
|
||||
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();
|
||||
|
||||
if (colorScheme == 'system') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface LocalSettings {
|
||||
export default interface LocalSettings {
|
||||
deviceId: number,
|
||||
micVolume: number,
|
||||
colorScheme: 'light' | 'dark' | 'system',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createSlice, PayloadAction } from "@reduxjs/toolkit";
|
||||
import LocalSettings from "../models/LocalSettings";
|
||||
|
||||
export const settingsSlice = createSlice({
|
||||
name: 'settings',
|
||||
|
||||
@@ -100,6 +100,8 @@
|
||||
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
||||
},
|
||||
"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,
|
||||
} from "../../i18n/i18n";
|
||||
import { RootState, useSelector } from "../../state/Store";
|
||||
import { useSelector } from "../../state/Store";
|
||||
import { updateSettings } from "../../state/SettingsSlice";
|
||||
import ElementList from "../../components/GtkUI/ElementList";
|
||||
|
||||
const PreferencesView = () => {
|
||||
const dispatch = useDispatch();
|
||||
const language: AvailableLanguages = useSelector(
|
||||
(state: RootState) => state.language.value
|
||||
);
|
||||
const settings = useSelector(
|
||||
(state: RootState) => state.settings.local
|
||||
);
|
||||
const language = useSelector((state) => state.language.value);
|
||||
const settings = useSelector((state) => state.settings.local);
|
||||
return (
|
||||
<Center style={{ flex: 1 }}>
|
||||
<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 { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||
import { unsetAccessToken } from '../../state/UserSlice';
|
||||
@@ -16,9 +16,6 @@ import GuestToUserView from './GuestToUserView';
|
||||
import { useQuery } from 'react-query';
|
||||
import API from '../../API';
|
||||
|
||||
|
||||
const SettingsStack = createNativeStackNavigator();
|
||||
|
||||
const handleChangeEmail = async (newEmail: string): Promise<string> => {
|
||||
try {
|
||||
let response = await API.updateUserEmail(newEmail);
|
||||
@@ -37,43 +34,7 @@ const handleChangePassword = async (oldPassword: string, newPassword: string): P
|
||||
}
|
||||
}
|
||||
|
||||
const MainView = ({ navigation }) => {
|
||||
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 }) => {
|
||||
export const ChangePasswordView = () => {
|
||||
return (
|
||||
<Center style={{ flex: 1}}>
|
||||
<Heading paddingBottom={'2%'}>{translate('changePassword')}</Heading>
|
||||
@@ -82,7 +43,7 @@ export const ChangePasswordView = ({ navigation }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const ChangeEmailView = ({ navigation }) => {
|
||||
export const ChangeEmailView = () => {
|
||||
return (
|
||||
<Center style={{ flex: 1}}>
|
||||
<Heading paddingBottom={'2%'}>{translate('changeEmail')}</Heading>
|
||||
@@ -91,7 +52,7 @@ export const ChangeEmailView = ({ navigation }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const GoogleAccountView = ({ navigation }) => {
|
||||
export const GoogleAccountView = () => {
|
||||
return (
|
||||
<Center style={{ flex: 1}}>
|
||||
<Text>GoogleAccount</Text>
|
||||
@@ -99,7 +60,7 @@ export const GoogleAccountView = ({ navigation }) => {
|
||||
)
|
||||
}
|
||||
|
||||
export const PianoSettingsView = ({ navigation }) => {
|
||||
export const PianoSettingsView = () => {
|
||||
return (
|
||||
<Center style={{ flex: 1}}>
|
||||
<Text>Global settings for the virtual piano</Text>
|
||||
@@ -113,10 +74,6 @@ const SetttingsNavigator = () => {
|
||||
const userQuery = useQuery(['user'], () => API.getUserInfo());
|
||||
const user = useMemo(() => userQuery.data, [userQuery]);
|
||||
|
||||
if (userQuery.isError) {
|
||||
user.isGuest = false;
|
||||
}
|
||||
|
||||
if (userQuery.isLoading) {
|
||||
return (
|
||||
<Center style={{ flex: 1}}>
|
||||
|
||||
Reference in New Issue
Block a user