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
|
// Navigate to nested navigator and pass data to the index screen
|
||||||
this.navigatorRef.current.navigate('home', {
|
this.navigatorRef.current.navigate('home', {
|
||||||
screen: 'index',
|
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 = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
route: Object,
|
|
||||||
errorCode: number,
|
errorCode: number,
|
||||||
onRefresh: Function,
|
onRefresh: Function,
|
||||||
}
|
}
|
||||||
|
|
@ -86,11 +85,7 @@ class ErrorView extends React.PureComponent<Props, State> {
|
||||||
</Button>;
|
</Button>;
|
||||||
}
|
}
|
||||||
|
|
||||||
goToLogin = () => this.props.navigation.navigate("login",
|
goToLogin = () => this.props.navigation.navigate("login");
|
||||||
{
|
|
||||||
screen: 'index',
|
|
||||||
params: {nextScreen: this.props.route.name}
|
|
||||||
});
|
|
||||||
|
|
||||||
getLoginButton() {
|
getLoginButton() {
|
||||||
return <Button
|
return <Button
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ type Props = {
|
||||||
stickyHeader: boolean,
|
stickyHeader: boolean,
|
||||||
createDataset: Function,
|
createDataset: Function,
|
||||||
updateData: number,
|
updateData: number,
|
||||||
itemHeight: number | null,
|
itemHeight: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
|
@ -43,7 +43,7 @@ export default class WebSectionList extends React.PureComponent<Props, State> {
|
||||||
renderSectionHeader: null,
|
renderSectionHeader: null,
|
||||||
stickyHeader: false,
|
stickyHeader: false,
|
||||||
updateData: 0,
|
updateData: 0,
|
||||||
itemHeight: null,
|
itemHeight: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
refreshInterval: IntervalID;
|
refreshInterval: IntervalID;
|
||||||
|
|
@ -198,7 +198,7 @@ export default class WebSectionList extends React.PureComponent<Props, State> {
|
||||||
errorCode={ERROR_TYPE.CONNECTION_ERROR}
|
errorCode={ERROR_TYPE.CONNECTION_ERROR}
|
||||||
onRefresh={this.onRefresh}/>
|
onRefresh={this.onRefresh}/>
|
||||||
}
|
}
|
||||||
getItemLayout={this.props.itemHeight !== null ? this.itemLayout : undefined}
|
getItemLayout={this.props.itemHeight !== undefined ? this.itemLayout : undefined}
|
||||||
/>
|
/>
|
||||||
<Snackbar
|
<Snackbar
|
||||||
visible={this.state.snackbarVisible}
|
visible={this.state.snackbarVisible}
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ function HomeStackComponent(initialRoute: string | null, defaultData: Object) {
|
||||||
initialParams={data}
|
initialParams={data}
|
||||||
/>
|
/>
|
||||||
<HomeStack.Screen
|
<HomeStack.Screen
|
||||||
name="home-planning-information"
|
name="planning-information"
|
||||||
component={PlanningDisplayScreen}
|
component={PlanningDisplayScreen}
|
||||||
options={{
|
options={{
|
||||||
title: i18n.t('screens.planningDisplayScreen'),
|
title: i18n.t('screens.planningDisplayScreen'),
|
||||||
|
|
@ -177,7 +177,7 @@ function HomeStackComponent(initialRoute: string | null, defaultData: Object) {
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<HomeStack.Screen
|
<HomeStack.Screen
|
||||||
name="home-club-information"
|
name="club-information"
|
||||||
component={ClubDisplayScreen}
|
component={ClubDisplayScreen}
|
||||||
options={({navigation}) => {
|
options={({navigation}) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,9 @@ import ConnectionManager from "../../managers/ConnectionManager";
|
||||||
import {openBrowser} from "../../utils/WebBrowser";
|
import {openBrowser} from "../../utils/WebBrowser";
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import ErrorDialog from "../../components/Dialog/ErrorDialog";
|
import ErrorDialog from "../../components/Dialog/ErrorDialog";
|
||||||
import {CommonActions} from "@react-navigation/native";
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
route: Object,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
|
@ -46,9 +44,8 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
onEmailChange: Function;
|
onEmailChange: Function;
|
||||||
onPasswordChange: Function;
|
onPasswordChange: Function;
|
||||||
passwordInputRef: Object;
|
|
||||||
|
|
||||||
nextScreen: string;
|
passwordInputRef: Object;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
@ -56,18 +53,8 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
this.onPasswordChange = this.onInputChange.bind(this, false);
|
this.onPasswordChange = this.onInputChange.bind(this, false);
|
||||||
|
|
||||||
this.colors = props.theme.colors;
|
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) =>
|
showErrorDialog = (error: number) =>
|
||||||
this.setState({
|
this.setState({
|
||||||
dialogVisible: true,
|
dialogVisible: true,
|
||||||
|
|
@ -76,33 +63,23 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
hideErrorDialog = () => this.setState({dialogVisible: false});
|
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);
|
onResetPasswordClick = () => openBrowser(RESET_PASSWORD_LINK, this.colors.primary);
|
||||||
|
|
||||||
validateEmail = () => this.setState({isEmailValidated: true});
|
validateEmail = () => this.setState({isEmailValidated: true});
|
||||||
|
|
||||||
isEmailValid() {
|
isEmailValid() {return emailRegex.test(this.state.email);}
|
||||||
return emailRegex.test(this.state.email);
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldShowEmailError() {
|
shouldShowEmailError() {return this.state.isEmailValidated && !this.isEmailValid();}
|
||||||
return this.state.isEmailValidated && !this.isEmailValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
validatePassword = () => this.setState({isPasswordValidated: true});
|
validatePassword = () => this.setState({isPasswordValidated: true});
|
||||||
|
|
||||||
isPasswordValid() {
|
isPasswordValid() {return this.state.password !== '';}
|
||||||
return this.state.password !== '';
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldShowPasswordError() {
|
shouldShowPasswordError() {return this.state.isPasswordValidated && !this.isPasswordValid();}
|
||||||
return this.state.isPasswordValidated && !this.isPasswordValid();
|
|
||||||
}
|
|
||||||
|
|
||||||
shouldEnableLogin() {
|
shouldEnableLogin() {return this.isEmailValid() && this.isPasswordValid() && !this.state.loading;}
|
||||||
return this.isEmailValid() && this.isPasswordValid() && !this.state.loading;
|
|
||||||
}
|
|
||||||
|
|
||||||
onInputChange(isEmail: boolean, value: string) {
|
onInputChange(isEmail: boolean, value: string) {
|
||||||
if (isEmail) {
|
if (isEmail) {
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,9 @@ class ProfileScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
const rightButton = this.getHeaderButtons.bind(this);
|
||||||
this.props.navigation.setOptions({
|
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});
|
hideDisconnectDialog = () => this.setState({dialogVisible: false});
|
||||||
|
|
||||||
getHeaderButton = () => <HeaderButton icon={'logout'} onPress={this.showDisconnectDialog}/>;
|
getHeaderButtons() {
|
||||||
|
return <HeaderButton icon={'logout'} onPress={this.showDisconnectDialog}/>;
|
||||||
|
}
|
||||||
|
|
||||||
getScreen = (data: Object) => {
|
getScreen = (data: Object) => {
|
||||||
this.data = data[0];
|
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() {
|
getPersonalCard() {
|
||||||
return (
|
return (
|
||||||
<Card style={styles.card}>
|
<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() {
|
getClubCard() {
|
||||||
return (
|
return (
|
||||||
<Card style={styles.card}>
|
<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() {
|
getMembershipCar() {
|
||||||
return (
|
return (
|
||||||
<Card style={styles.card}>
|
<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) {
|
openClubDetailsScreen(id: number) {
|
||||||
this.props.navigation.navigate("club-information", {clubId: id});
|
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) => {
|
clubListItem = ({item}: Object) => {
|
||||||
const onPress = () => this.openClubDetailsScreen(0); // TODO get club id
|
const onPress = () => this.openClubDetailsScreen(0); // TODO get club id
|
||||||
const isManager = false; // TODO detect if manager
|
const isManager = false; // TODO detect if manager
|
||||||
|
|
@ -283,12 +187,6 @@ class ProfileScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
clubKeyExtractor = (item: Object) => item.name;
|
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>) {
|
getClubList(list: Array<string>) {
|
||||||
let dataset = [];
|
let dataset = [];
|
||||||
for (let i = 0; i < list.length; i++) {
|
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() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<AuthenticatedScreen
|
<AuthenticatedScreen
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,17 @@ type Props = {
|
||||||
*/
|
*/
|
||||||
class HomeScreen extends React.Component<Props> {
|
class HomeScreen extends React.Component<Props> {
|
||||||
|
|
||||||
|
getRenderItem: Function;
|
||||||
|
createDataset: Function;
|
||||||
|
|
||||||
colors: Object;
|
colors: Object;
|
||||||
|
|
||||||
isLoggedIn: boolean | null;
|
isLoggedIn: boolean | null;
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
|
this.getRenderItem = this.getRenderItem.bind(this);
|
||||||
|
this.createDataset = this.createDataset.bind(this);
|
||||||
this.colors = props.theme.colors;
|
this.colors = props.theme.colors;
|
||||||
|
|
||||||
this.isLoggedIn = null;
|
this.isLoggedIn = null;
|
||||||
|
|
@ -80,10 +85,10 @@ class HomeScreen extends React.Component<Props> {
|
||||||
|
|
||||||
handleNavigationParams = () => {
|
handleNavigationParams = () => {
|
||||||
if (this.props.route.params !== undefined) {
|
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);
|
this.props.navigation.navigate(this.props.route.params.nextScreen, this.props.route.params.data);
|
||||||
// reset params to prevent infinite loop
|
// 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
|
* @param fetchedData
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
createDataset = (fetchedData: Object) => {
|
createDataset(fetchedData: Object) {
|
||||||
// fetchedData = DATA;
|
// fetchedData = DATA;
|
||||||
let newsData = [];
|
let newsData = [];
|
||||||
let dashboardData = [];
|
let dashboardData = [];
|
||||||
|
|
@ -196,7 +201,7 @@ class HomeScreen extends React.Component<Props> {
|
||||||
return this.getDashboardEventItem(content);
|
return this.getDashboardEventItem(content);
|
||||||
else if (item['id'] === 'top')
|
else if (item['id'] === 'top')
|
||||||
return this.getDashboardTopItem(content);
|
return this.getDashboardTopItem(content);
|
||||||
else
|
else if (item['id'] === 'actions')
|
||||||
return this.getActionsDashboardItem();
|
return this.getActionsDashboardItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -457,11 +462,10 @@ class HomeScreen extends React.Component<Props> {
|
||||||
* @param section The current section
|
* @param section The current section
|
||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
getRenderItem = ({item, section}: Object) => {
|
getRenderItem({item, section}: Object) {
|
||||||
return (section['id'] === SECTIONS_ID[0]
|
return (section['id'] === SECTIONS_ID[0] ?
|
||||||
? this.getDashboardItem(item)
|
this.getDashboardItem(item) : this.getFeedItem(item));
|
||||||
: this.getFeedItem(item));
|
}
|
||||||
};
|
|
||||||
|
|
||||||
openScanner = () => this.props.navigation.navigate("scanner");
|
openScanner = () => this.props.navigation.navigate("scanner");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ export default class URLHandler {
|
||||||
static CLUB_INFO_URL_PATH = "club";
|
static CLUB_INFO_URL_PATH = "club";
|
||||||
static EVENT_INFO_URL_PATH = "event";
|
static EVENT_INFO_URL_PATH = "event";
|
||||||
|
|
||||||
static CLUB_INFO_ROUTE = "home-club-information";
|
static CLUB_INFO_ROUTE = "club-information";
|
||||||
static EVENT_INFO_ROUTE = "home-planning-information";
|
static EVENT_INFO_ROUTE = "planning-information";
|
||||||
|
|
||||||
onInitialURLParsed: Function;
|
onInitialURLParsed: Function;
|
||||||
onDetectURL: Function;
|
onDetectURL: Function;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue