Compare commits
No commits in common. "3fe6be4238349c58de04eefc827501752acca1a8" and "2e4fa2089564ddbf9447d0b5e5d937197b23e2d8" have entirely different histories.
3fe6be4238
...
2e4fa20895
8 changed files with 77 additions and 160 deletions
2
App.js
2
App.js
|
|
@ -73,7 +73,7 @@ export default class App extends React.Component<Props, State> {
|
|||
// Navigate to nested navigator and pass data to the index screen
|
||||
this.navigatorRef.current.navigate('home', {
|
||||
screen: 'index',
|
||||
params: {nextScreen: route, data: data}
|
||||
params: {nextScreen: route, data: data, shouldOpen: true}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import {ERROR_TYPE} from "../../managers/ConnectionManager";
|
|||
|
||||
type Props = {
|
||||
navigation: Object,
|
||||
route: Object,
|
||||
errorCode: number,
|
||||
onRefresh: Function,
|
||||
}
|
||||
|
|
@ -86,11 +85,7 @@ class ErrorView extends React.PureComponent<Props, State> {
|
|||
</Button>;
|
||||
}
|
||||
|
||||
goToLogin = () => this.props.navigation.navigate("login",
|
||||
{
|
||||
screen: 'index',
|
||||
params: {nextScreen: this.props.route.name}
|
||||
});
|
||||
goToLogin = () => this.props.navigation.navigate("login");
|
||||
|
||||
getLoginButton() {
|
||||
return <Button
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ type Props = {
|
|||
stickyHeader: boolean,
|
||||
createDataset: Function,
|
||||
updateData: number,
|
||||
itemHeight: number | null,
|
||||
itemHeight: number,
|
||||
}
|
||||
|
||||
type State = {
|
||||
|
|
@ -43,7 +43,7 @@ export default class WebSectionList extends React.PureComponent<Props, State> {
|
|||
renderSectionHeader: null,
|
||||
stickyHeader: false,
|
||||
updateData: 0,
|
||||
itemHeight: null,
|
||||
itemHeight: undefined,
|
||||
};
|
||||
|
||||
refreshInterval: IntervalID;
|
||||
|
|
@ -198,7 +198,7 @@ export default class WebSectionList extends React.PureComponent<Props, State> {
|
|||
errorCode={ERROR_TYPE.CONNECTION_ERROR}
|
||||
onRefresh={this.onRefresh}/>
|
||||
}
|
||||
getItemLayout={this.props.itemHeight !== null ? this.itemLayout : undefined}
|
||||
getItemLayout={this.props.itemHeight !== undefined ? this.itemLayout : undefined}
|
||||
/>
|
||||
<Snackbar
|
||||
visible={this.state.snackbarVisible}
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ function HomeStackComponent(initialRoute: string | null, defaultData: Object) {
|
|||
initialParams={data}
|
||||
/>
|
||||
<HomeStack.Screen
|
||||
name="home-planning-information"
|
||||
name="planning-information"
|
||||
component={PlanningDisplayScreen}
|
||||
options={{
|
||||
title: i18n.t('screens.planningDisplayScreen'),
|
||||
|
|
@ -177,7 +177,7 @@ function HomeStackComponent(initialRoute: string | null, defaultData: Object) {
|
|||
}}
|
||||
/>
|
||||
<HomeStack.Screen
|
||||
name="home-club-information"
|
||||
name="club-information"
|
||||
component={ClubDisplayScreen}
|
||||
options={({navigation}) => {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,9 @@ import ConnectionManager from "../../managers/ConnectionManager";
|
|||
import {openBrowser} from "../../utils/WebBrowser";
|
||||
import i18n from 'i18n-js';
|
||||
import ErrorDialog from "../../components/Dialog/ErrorDialog";
|
||||
import {CommonActions} from "@react-navigation/native";
|
||||
|
||||
type Props = {
|
||||
navigation: Object,
|
||||
route: Object,
|
||||
}
|
||||
|
||||
type State = {
|
||||
|
|
@ -46,9 +44,8 @@ class LoginScreen extends React.Component<Props, State> {
|
|||
|
||||
onEmailChange: Function;
|
||||
onPasswordChange: Function;
|
||||
passwordInputRef: Object;
|
||||
|
||||
nextScreen: string;
|
||||
passwordInputRef: Object;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
|
@ -56,18 +53,8 @@ class LoginScreen extends React.Component<Props, State> {
|
|||
this.onPasswordChange = this.onInputChange.bind(this, false);
|
||||
|
||||
this.colors = props.theme.colors;
|
||||
|
||||
this.props.navigation.addListener('focus', this.onScreenFocus);
|
||||
}
|
||||
|
||||
onScreenFocus = () => {
|
||||
if (this.props.route.params !== undefined && this.props.route.params.nextScreen !== undefined) {
|
||||
this.nextScreen = this.props.route.params.nextScreen;
|
||||
this.props.navigation.dispatch(CommonActions.setParams({nextScreen: 'profile'}));
|
||||
} else
|
||||
this.nextScreen = 'profile';
|
||||
};
|
||||
|
||||
showErrorDialog = (error: number) =>
|
||||
this.setState({
|
||||
dialogVisible: true,
|
||||
|
|
@ -76,33 +63,23 @@ class LoginScreen extends React.Component<Props, State> {
|
|||
|
||||
hideErrorDialog = () => this.setState({dialogVisible: false});
|
||||
|
||||
handleSuccess = () => this.props.navigation.navigate(this.nextScreen);
|
||||
handleSuccess = () => this.props.navigation.navigate('profile');
|
||||
|
||||
onResetPasswordClick = () => openBrowser(RESET_PASSWORD_LINK, this.colors.primary);
|
||||
|
||||
validateEmail = () => this.setState({isEmailValidated: true});
|
||||
|
||||
isEmailValid() {
|
||||
return emailRegex.test(this.state.email);
|
||||
}
|
||||
isEmailValid() {return emailRegex.test(this.state.email);}
|
||||
|
||||
shouldShowEmailError() {
|
||||
return this.state.isEmailValidated && !this.isEmailValid();
|
||||
}
|
||||
shouldShowEmailError() {return this.state.isEmailValidated && !this.isEmailValid();}
|
||||
|
||||
validatePassword = () => this.setState({isPasswordValidated: true});
|
||||
|
||||
isPasswordValid() {
|
||||
return this.state.password !== '';
|
||||
}
|
||||
isPasswordValid() {return this.state.password !== '';}
|
||||
|
||||
shouldShowPasswordError() {
|
||||
return this.state.isPasswordValidated && !this.isPasswordValid();
|
||||
}
|
||||
shouldShowPasswordError() {return this.state.isPasswordValidated && !this.isPasswordValid();}
|
||||
|
||||
shouldEnableLogin() {
|
||||
return this.isEmailValid() && this.isPasswordValid() && !this.state.loading;
|
||||
}
|
||||
shouldEnableLogin() {return this.isEmailValid() && this.isPasswordValid() && !this.state.loading;}
|
||||
|
||||
onInputChange(isEmail: boolean, value: string) {
|
||||
if (isEmail) {
|
||||
|
|
|
|||
|
|
@ -41,8 +41,9 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
componentDidMount() {
|
||||
const rightButton = this.getHeaderButtons.bind(this);
|
||||
this.props.navigation.setOptions({
|
||||
headerRight: this.getHeaderButton,
|
||||
headerRight: rightButton,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -50,7 +51,9 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
|
||||
hideDisconnectDialog = () => this.setState({dialogVisible: false});
|
||||
|
||||
getHeaderButton = () => <HeaderButton icon={'logout'} onPress={this.showDisconnectDialog}/>;
|
||||
getHeaderButtons() {
|
||||
return <HeaderButton icon={'logout'} onPress={this.showDisconnectDialog}/>;
|
||||
}
|
||||
|
||||
getScreen = (data: Object) => {
|
||||
this.data = data[0];
|
||||
|
|
@ -81,67 +84,6 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks if the given field is available
|
||||
*
|
||||
* @param field The field to check
|
||||
* @return {boolean}
|
||||
*/
|
||||
isFieldAvailable(field: ?string) {
|
||||
return field !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the given field value.
|
||||
* If the field does not have a value, returns a placeholder text
|
||||
*
|
||||
* @param field The field to get the value from
|
||||
* @return {*}
|
||||
*/
|
||||
getFieldValue(field: ?string) {
|
||||
return this.isFieldAvailable(field)
|
||||
? field
|
||||
: i18n.t("profileScreen.noData");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the color depending on the value.
|
||||
*
|
||||
* @param field The field to get the color for
|
||||
* @return {*}
|
||||
*/
|
||||
getFieldColor(field: ?string) {
|
||||
return this.isFieldAvailable(field)
|
||||
? this.colors.text
|
||||
: this.colors.textDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list item showing personal information
|
||||
*
|
||||
* @param field The field to display
|
||||
* @param icon The icon to use
|
||||
* @return {*}
|
||||
*/
|
||||
getPersonalListItem(field: ?string, icon: string) {
|
||||
return (
|
||||
<List.Item
|
||||
title={this.getFieldValue(field)}
|
||||
left={props => <List.Icon
|
||||
{...props}
|
||||
icon={icon}
|
||||
color={this.getFieldColor(field)}
|
||||
/>}
|
||||
titleStyle={{color: this.getFieldColor(field)}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a card containing user personal information
|
||||
*
|
||||
* @return {*}
|
||||
*/
|
||||
getPersonalCard() {
|
||||
return (
|
||||
<Card style={styles.card}>
|
||||
|
|
@ -179,11 +121,6 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a cars containing clubs the user is part of
|
||||
*
|
||||
* @return {*}
|
||||
*/
|
||||
getClubCard() {
|
||||
return (
|
||||
<Card style={styles.card}>
|
||||
|
|
@ -205,11 +142,6 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a card showing if the user has payed his membership
|
||||
*
|
||||
* @return {*}
|
||||
*/
|
||||
getMembershipCar() {
|
||||
return (
|
||||
<Card style={styles.card}>
|
||||
|
|
@ -232,38 +164,10 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item showing if the user has payed his membership
|
||||
*
|
||||
* @return {*}
|
||||
*/
|
||||
getMembershipItem(state: boolean) {
|
||||
return (
|
||||
<List.Item
|
||||
title={state ? i18n.t("profileScreen.membershipPayed") : i18n.t("profileScreen.membershipNotPayed")}
|
||||
left={props => <List.Icon
|
||||
{...props}
|
||||
color={state ? this.colors.success : this.colors.danger}
|
||||
icon={state ? 'check' : 'close'}
|
||||
/>}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens the club details screen for the club of given ID
|
||||
* @param id The club's id to open
|
||||
*/
|
||||
openClubDetailsScreen(id: number) {
|
||||
this.props.navigation.navigate("club-information", {clubId: id});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list item for the club list
|
||||
*
|
||||
* @param item The club to render
|
||||
* @return {*}
|
||||
*/
|
||||
clubListItem = ({item}: Object) => {
|
||||
const onPress = () => this.openClubDetailsScreen(0); // TODO get club id
|
||||
const isManager = false; // TODO detect if manager
|
||||
|
|
@ -283,12 +187,6 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
|
||||
clubKeyExtractor = (item: Object) => item.name;
|
||||
|
||||
/**
|
||||
* Renders the list of clubs the user is part of
|
||||
*
|
||||
* @param list The club list
|
||||
* @return {*}
|
||||
*/
|
||||
getClubList(list: Array<string>) {
|
||||
let dataset = [];
|
||||
for (let i = 0; i < list.length; i++) {
|
||||
|
|
@ -304,6 +202,49 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
);
|
||||
}
|
||||
|
||||
getMembershipItem(state: boolean) {
|
||||
return (
|
||||
<List.Item
|
||||
title={state ? i18n.t("profileScreen.membershipPayed") : i18n.t("profileScreen.membershipNotPayed")}
|
||||
left={props => <List.Icon
|
||||
{...props}
|
||||
color={state ? this.colors.success : this.colors.danger}
|
||||
icon={state ? 'check' : 'close'}
|
||||
/>}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
isFieldAvailable(field: ?string) {
|
||||
return field !== null;
|
||||
}
|
||||
|
||||
getFieldValue(field: ?string) {
|
||||
return this.isFieldAvailable(field)
|
||||
? field
|
||||
: i18n.t("profileScreen.noData");
|
||||
}
|
||||
|
||||
getFieldColor(field: ?string) {
|
||||
return this.isFieldAvailable(field)
|
||||
? this.colors.text
|
||||
: this.colors.textDisabled;
|
||||
}
|
||||
|
||||
getPersonalListItem(field: ?string, icon: string) {
|
||||
return (
|
||||
<List.Item
|
||||
title={this.getFieldValue(field)}
|
||||
left={props => <List.Icon
|
||||
{...props}
|
||||
icon={icon}
|
||||
color={this.getFieldColor(field)}
|
||||
/>}
|
||||
titleStyle={{color: this.getFieldColor(field)}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<AuthenticatedScreen
|
||||
|
|
|
|||
|
|
@ -39,12 +39,17 @@ type Props = {
|
|||
*/
|
||||
class HomeScreen extends React.Component<Props> {
|
||||
|
||||
getRenderItem: Function;
|
||||
createDataset: Function;
|
||||
|
||||
colors: Object;
|
||||
|
||||
isLoggedIn: boolean | null;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.getRenderItem = this.getRenderItem.bind(this);
|
||||
this.createDataset = this.createDataset.bind(this);
|
||||
this.colors = props.theme.colors;
|
||||
|
||||
this.isLoggedIn = null;
|
||||
|
|
@ -80,10 +85,10 @@ class HomeScreen extends React.Component<Props> {
|
|||
|
||||
handleNavigationParams = () => {
|
||||
if (this.props.route.params !== undefined) {
|
||||
if (this.props.route.params.nextScreen !== undefined && this.props.route.params.nextScreen !== null) {
|
||||
if (this.props.route.params.shouldOpen !== undefined && this.props.route.params.shouldOpen) {
|
||||
this.props.navigation.navigate(this.props.route.params.nextScreen, this.props.route.params.data);
|
||||
// reset params to prevent infinite loop
|
||||
this.props.navigation.dispatch(CommonActions.setParams({ nextScreen: null }));
|
||||
this.props.navigation.dispatch(CommonActions.setParams({ shouldOpen: false }));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -117,7 +122,7 @@ class HomeScreen extends React.Component<Props> {
|
|||
* @param fetchedData
|
||||
* @return {*}
|
||||
*/
|
||||
createDataset = (fetchedData: Object) => {
|
||||
createDataset(fetchedData: Object) {
|
||||
// fetchedData = DATA;
|
||||
let newsData = [];
|
||||
let dashboardData = [];
|
||||
|
|
@ -196,7 +201,7 @@ class HomeScreen extends React.Component<Props> {
|
|||
return this.getDashboardEventItem(content);
|
||||
else if (item['id'] === 'top')
|
||||
return this.getDashboardTopItem(content);
|
||||
else
|
||||
else if (item['id'] === 'actions')
|
||||
return this.getActionsDashboardItem();
|
||||
}
|
||||
|
||||
|
|
@ -457,11 +462,10 @@ class HomeScreen extends React.Component<Props> {
|
|||
* @param section The current section
|
||||
* @return {*}
|
||||
*/
|
||||
getRenderItem = ({item, section}: Object) => {
|
||||
return (section['id'] === SECTIONS_ID[0]
|
||||
? this.getDashboardItem(item)
|
||||
: this.getFeedItem(item));
|
||||
};
|
||||
getRenderItem({item, section}: Object) {
|
||||
return (section['id'] === SECTIONS_ID[0] ?
|
||||
this.getDashboardItem(item) : this.getFeedItem(item));
|
||||
}
|
||||
|
||||
openScanner = () => this.props.navigation.navigate("scanner");
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ export default class URLHandler {
|
|||
static CLUB_INFO_URL_PATH = "club";
|
||||
static EVENT_INFO_URL_PATH = "event";
|
||||
|
||||
static CLUB_INFO_ROUTE = "home-club-information";
|
||||
static EVENT_INFO_ROUTE = "home-planning-information";
|
||||
static CLUB_INFO_ROUTE = "club-information";
|
||||
static EVENT_INFO_ROUTE = "planning-information";
|
||||
|
||||
onInitialURLParsed: Function;
|
||||
onDetectURL: Function;
|
||||
|
|
|
|||
Loading…
Reference in a new issue