master
Netcup Gituser 2023-12-02 13:48:22 +01:00
parent dbb5950426
commit 34185d8a7e
6 changed files with 62 additions and 44 deletions

View File

@ -1,6 +1,4 @@
import React, {useEffect, Fragment} from 'react'; import React, {useEffect, Fragment} from 'react';
import {View, Text} from 'react-native';
import {NavigationContainer} from '@react-navigation/native'; import {NavigationContainer} from '@react-navigation/native';
import {Provider, useSelector} from 'react-redux'; import {Provider, useSelector} from 'react-redux';
@ -78,6 +76,7 @@ const MainComponent = () => {
const currentAppStatus = useSelector( const currentAppStatus = useSelector(
(state: RootState) => state.nonSaveVariables.appStatus, (state: RootState) => state.nonSaveVariables.appStatus,
); );
return ( return (
<Fragment> <Fragment>
<StartHelper /> <StartHelper />

View File

@ -5,7 +5,7 @@ interface MyIconInputProps {
text: string; text: string;
iconName: string; iconName: string;
keyboardType?: KeyboardTypeOptions; keyboardType?: KeyboardTypeOptions;
secureTextEntry?: boolean | undefined; secureTextEntry?: boolean;
value?: string; value?: string;
onChangeText?: (text: string) => void; onChangeText?: (text: string) => void;
disableContainer?: boolean; disableContainer?: boolean;
@ -29,13 +29,12 @@ export function MyIconInput({text, iconName, keyboardType, secureTextEntry, valu
backgroundColor: '#212137', backgroundColor: '#212137',
height: 40, height: 40,
borderRadius: 10, borderRadius: 10,
paddingLeft: 10, paddingLeft: 10
}} }}
keyboardType={keyboardType} keyboardType={keyboardType}
secureTextEntry={secureTextEntry} secureTextEntry={secureTextEntry}
value={value} value={value}
onChangeText={onChangeText} onChangeText={onChangeText}
/> />
</View> </View>
</View> </View>

View File

@ -17,25 +17,15 @@ export function MyScreenContainer({
flex: 1, flex: 1,
paddingLeft: 20, paddingLeft: 20,
paddingRight: 20, paddingRight: 20,
} };
const ScreenView = () => (
<View
style={[
style,
!scrollView && containerStyle,
]}>
{children}
</View>
);
if (scrollView) { if (scrollView) {
return ( return (
<ScrollView style={containerStyle}> <ScrollView style={containerStyle}>
<ScreenView /> <View style={[style, !scrollView && containerStyle]}>{children}</View>
</ScrollView> </ScrollView>
); );
} }
return <ScreenView />; return <View style={[style, !scrollView && containerStyle]}>{children}</View>;
} }

View File

@ -20,7 +20,7 @@ import AppleLogo from '@assets/apple-logo.png';
import Logo from '@assets/logo.png'; import Logo from '@assets/logo.png';
import {MyDividerWithText} from '@components/MyDivider'; import {MyDividerWithText} from '@components/MyDivider';
import {MyButton, MyImageButton} from '@components/MyButton'; import {MyButton, MyIconButton, MyImageButton} from '@components/MyButton';
import {MyClickableText} from '@components/MyClickableText'; import {MyClickableText} from '@components/MyClickableText';
import {OpenURL} from '@helper/linking'; import {OpenURL} from '@helper/linking';
import {Constants} from '@utils/utils'; import {Constants} from '@utils/utils';

View File

@ -74,7 +74,7 @@ export default function ProfileTab() {
name="UpdateUsername" name="UpdateUsername"
options={{ options={{
animation: 'slide_from_right', animation: 'slide_from_right',
title: 'Update Account Name', title: 'Update Username',
headerShown: true, headerShown: true,
headerStyle: {backgroundColor: '#212137'}, headerStyle: {backgroundColor: '#212137'},
headerTitleAlign: 'center', headerTitleAlign: 'center',

View File

@ -1,5 +1,5 @@
import {MyScreenContainer} from '@components/MyScreenContainer'; import {MyScreenContainer} from '@components/MyScreenContainer';
import {Image, ScrollView, TouchableOpacity} from 'react-native'; import {Image, ScrollView, TextInput, TouchableOpacity} from 'react-native';
import {Text, View} from 'react-native'; import {Text, View} from 'react-native';
import Avatar from '@assets/profile.png'; import Avatar from '@assets/profile.png';
@ -10,7 +10,10 @@ import {useNavigation} from '@react-navigation/native';
import {ProfileScreenNavigationProp} from '@navigation/tabs/main/ProfileTab'; import {ProfileScreenNavigationProp} from '@navigation/tabs/main/ProfileTab';
import {MyIconInput} from '@components/MyInput'; import {MyIconInput} from '@components/MyInput';
import {useEffect, useState} from 'react'; import {useEffect, useState} from 'react';
import {RootScreenNavigationProp} from '@navigation/navigation'; import {
RootScreenNavigationProp,
RootStackNavigatorParamList,
} from '@navigation/navigation';
function UserAvatar() { function UserAvatar() {
return ( return (
@ -80,6 +83,8 @@ function Statistic({value, title}: StatisticProps) {
export function ProfileSettings() { export function ProfileSettings() {
const navigation = useNavigation<ProfileScreenNavigationProp>(); const navigation = useNavigation<ProfileScreenNavigationProp>();
const rootNavigation = useNavigation<RootScreenNavigationProp>();
return ( return (
<ScrollView> <ScrollView>
<MyScreenContainer <MyScreenContainer
@ -133,7 +138,13 @@ export function ProfileSettings() {
onPress={() => navigation.navigate('About')} onPress={() => navigation.navigate('About')}
/> />
<SettingsItem icon="logout" title="Logout" /> <SettingsItem
icon="logout"
title="Logout"
onPress={() =>
rootNavigation.navigate('Registration', {screen: 'LoginPreview'})
}
/>
</SettingsItemContainer> </SettingsItemContainer>
</MyScreenContainer> </MyScreenContainer>
</ScrollView> </ScrollView>
@ -208,16 +219,17 @@ export function UpdateUsername() {
const [newUsername, setNewUsername] = useState(username); const [newUsername, setNewUsername] = useState(username);
useEffect(() => { useEffect(() => {
const changed = username === newUsername; const changed = username !== newUsername;
navigation.setOptions({ navigation.setOptions({
headerRight: () => ( headerRight: () =>
<TouchableOpacity changed ? (
onPress={() => navigation.goBack()} <TouchableOpacity onPress={() => navigation.goBack()}>
disabled={changed}> <MyIcon name="done" size={24} color={!changed ? '#fff' : '#ccc'} />
<MyIcon name="done" size={24} color={!changed ? '#fff' : '#ccc'} /> </TouchableOpacity>
</TouchableOpacity> ) : (
), <></>
),
}); });
}, [navigation, newUsername]); }, [navigation, newUsername]);
@ -227,7 +239,9 @@ export function UpdateUsername() {
iconName="person" iconName="person"
text="USERNAME" text="USERNAME"
value={newUsername} value={newUsername}
onChangeText={text => setNewUsername(text)} onChangeText={text => {
setNewUsername(text);
}}
/> />
<Text style={{marginTop: 12}}>You can use a-z, 0-9 and underscores.</Text> <Text style={{marginTop: 12}}>You can use a-z, 0-9 and underscores.</Text>
<Text>Minimum length is 5 characters.</Text> <Text>Minimum length is 5 characters.</Text>
@ -238,18 +252,31 @@ export function UpdateUsername() {
export function UpdatePassword() { export function UpdatePassword() {
const navigation = useNavigation<RootScreenNavigationProp>(); const navigation = useNavigation<RootScreenNavigationProp>();
const [currentPassword, setCurrentPassword] = useState('');
const [newPassword, setNewPassword] = useState('');
const [repeatNewPassword, setRepeatNewPassword] = useState('');
useEffect(() => { useEffect(() => {
const passwordChanged =
currentPassword.length > 0 &&
newPassword.length > 0 &&
repeatNewPassword.length > 0 &&
newPassword === repeatNewPassword;
navigation.setOptions({ navigation.setOptions({
headerRight: () => ( headerRight: () =>
<TouchableOpacity passwordChanged ? (
onPress={() => <TouchableOpacity
navigation.navigate('Registration', {screen: 'LoginPreview'}) onPress={() =>
}> navigation.navigate('Registration', {screen: 'LoginPreview'})
<MyIcon name="done" size={24} color="#fff" /> }>
</TouchableOpacity> <MyIcon name="done" size={24} color="#fff" />
), </TouchableOpacity>
) : (
<></>
),
}); });
}, [navigation]); }, [navigation, currentPassword, newPassword, repeatNewPassword]);
return ( return (
<MyScreenContainer style={{paddingTop: 20}} scrollView> <MyScreenContainer style={{paddingTop: 20}} scrollView>
@ -263,21 +290,24 @@ export function UpdatePassword() {
iconName="lock" iconName="lock"
text="CURRENT PASSWORD" text="CURRENT PASSWORD"
secureTextEntry={true} secureTextEntry={true}
value="123456" value={currentPassword}
onChangeText={text => setCurrentPassword(text)}
disableContainer disableContainer
/> />
<MyIconInput <MyIconInput
iconName="lock" iconName="lock"
text="NEW PASSWORD" text="NEW PASSWORD"
secureTextEntry={true} secureTextEntry={true}
value="123456" value={newPassword}
onChangeText={text => setNewPassword(text)}
disableContainer disableContainer
/> />
<MyIconInput <MyIconInput
iconName="lock" iconName="lock"
text="REPEAT NEW PASSWORD" text="REPEAT NEW PASSWORD"
secureTextEntry={true} secureTextEntry={true}
value="123456" value={repeatNewPassword}
onChangeText={text => setRepeatNewPassword(text)}
disableContainer disableContainer
/> />
</View> </View>