Enabled collapsing header in login screen

This commit is contained in:
Arnaud Vergnet 2020-04-22 11:18:43 +02:00
parent c9b8a6e2ca
commit 0c71a78b22
2 changed files with 18 additions and 19 deletions

View file

@ -126,13 +126,7 @@ function ServicesStackComponent() {
{/* AMICALE */} {/* AMICALE */}
<ServicesStack.Screen {createScreenCollapsibleStack("login", ServicesStack, LoginScreen, i18n.t('screens.login'))}
name="login"
component={LoginScreen}
options={{
title: i18n.t('screens.login'),
}}
/>
{createScreenCollapsibleStack("profile", ServicesStack, ProfileScreen, i18n.t('screens.profile'))} {createScreenCollapsibleStack("profile", ServicesStack, ProfileScreen, i18n.t('screens.profile'))}
{createScreenCollapsibleStack("club-list", ServicesStack, ClubListScreen, i18n.t('clubs.clubList'))} {createScreenCollapsibleStack("club-list", ServicesStack, ClubListScreen, i18n.t('clubs.clubList'))}
<ServicesStack.Screen <ServicesStack.Screen
@ -274,14 +268,7 @@ function HomeStackComponent(initialRoute: string | null, defaultData: { [key: st
}} }}
/> />
{createScreenCollapsibleStack("self-menu", HomeStack, SelfMenuScreen, i18n.t('screens.menuSelf'), true, {...modalTransition})} {createScreenCollapsibleStack("self-menu", HomeStack, SelfMenuScreen, i18n.t('screens.menuSelf'), true, {...modalTransition})}
{createScreenCollapsibleStack("login", HomeStack, LoginScreen, i18n.t('screens.login'))}
<HomeStack.Screen
name="login"
component={LoginScreen}
options={{
title: i18n.t('screens.login'),
}}
/>
</HomeStack.Navigator> </HomeStack.Navigator>
); );
} }

View file

@ -1,16 +1,20 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {KeyboardAvoidingView, ScrollView, StyleSheet, View} from "react-native"; import {Animated, KeyboardAvoidingView, StyleSheet, View} from "react-native";
import {Avatar, Button, Card, HelperText, Paragraph, TextInput, withTheme} from 'react-native-paper'; import {Avatar, Button, Card, HelperText, Paragraph, TextInput, withTheme} from 'react-native-paper';
import ConnectionManager from "../../managers/ConnectionManager"; import ConnectionManager from "../../managers/ConnectionManager";
import i18n from 'i18n-js'; import i18n from 'i18n-js';
import ErrorDialog from "../../components/Dialogs/ErrorDialog"; import ErrorDialog from "../../components/Dialogs/ErrorDialog";
import {CommonActions} from "@react-navigation/native"; import {CommonActions} from "@react-navigation/native";
import {withCollapsible} from "../../utils/withCollapsible";
import {Collapsible} from "react-navigation-collapsible";
import CustomTabBar from "../../components/Tabbar/CustomTabBar";
type Props = { type Props = {
navigation: Object, navigation: Object,
route: Object, route: Object,
collapsibleStack: Collapsible,
} }
type State = { type State = {
@ -248,6 +252,7 @@ class LoginScreen extends React.Component<Props, State> {
} }
render() { render() {
const {containerPaddingTop, scrollIndicatorInsetTop, onScroll} = this.props.collapsibleStack;
return ( return (
<KeyboardAvoidingView <KeyboardAvoidingView
behavior={"height"} behavior={"height"}
@ -256,7 +261,14 @@ class LoginScreen extends React.Component<Props, State> {
enabled enabled
keyboardVerticalOffset={100} keyboardVerticalOffset={100}
> >
<ScrollView> <Animated.ScrollView
onScroll={onScroll}
contentContainerStyle={{
paddingTop: containerPaddingTop,
paddingBottom: CustomTabBar.TAB_BAR_HEIGHT + 20
}}
scrollIndicatorInsets={{top: scrollIndicatorInsetTop}}
>
<View> <View>
{this.getMainCard()} {this.getMainCard()}
{this.getSecondaryCard()} {this.getSecondaryCard()}
@ -266,7 +278,7 @@ class LoginScreen extends React.Component<Props, State> {
onDismiss={this.hideErrorDialog} onDismiss={this.hideErrorDialog}
errorCode={this.state.dialogError} errorCode={this.state.dialogError}
/> />
</ScrollView> </Animated.ScrollView>
</KeyboardAvoidingView> </KeyboardAvoidingView>
); );
} }
@ -292,4 +304,4 @@ const styles = StyleSheet.create({
} }
}); });
export default withTheme(LoginScreen); export default withCollapsible(withTheme(LoginScreen));