forked from vergnet/application-amicale
removed more arrow functions
This commit is contained in:
parent
7bac5a6ddc
commit
67357227c0
3 changed files with 53 additions and 34 deletions
6
App.js
6
App.js
|
@ -37,18 +37,20 @@ export default class App extends React.Component<Props, State> {
|
|||
};
|
||||
|
||||
onIntroDone: Function;
|
||||
onUpdateTheme: Function;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
LocaleManager.initTranslations();
|
||||
this.onIntroDone = this.onIntroDone.bind(this);
|
||||
this.onUpdateTheme = this.onUpdateTheme.bind(this);
|
||||
SplashScreen.preventAutoHide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the theme
|
||||
*/
|
||||
updateTheme() {
|
||||
onUpdateTheme() {
|
||||
this.setState({
|
||||
currentTheme: ThemeManager.getCurrentTheme()
|
||||
});
|
||||
|
@ -86,7 +88,7 @@ export default class App extends React.Component<Props, State> {
|
|||
async loadAssetsAsync() {
|
||||
// Wait for custom fonts to be loaded before showing the app
|
||||
await AsyncStorageManager.getInstance().loadPreferences();
|
||||
ThemeManager.getInstance().setUpdateThemeCallback(() => this.updateTheme());
|
||||
ThemeManager.getInstance().setUpdateThemeCallback(this.onUpdateTheme);
|
||||
// await NotificationsManager.initExpoToken();
|
||||
this.onLoadFinished();
|
||||
}
|
||||
|
|
|
@ -3,16 +3,6 @@
|
|||
import * as React from 'react';
|
||||
import {Avatar, Card, withTheme} from 'react-native-paper';
|
||||
|
||||
function getIcon(icon, color) {
|
||||
return (
|
||||
<Avatar.Icon
|
||||
icon={icon}
|
||||
color={color}
|
||||
size={60}
|
||||
style={{backgroundColor: 'transparent'}}/>
|
||||
);
|
||||
}
|
||||
|
||||
function EventDashBoardItem(props) {
|
||||
const {colors} = props.theme;
|
||||
const iconColor = props.isAvailable ?
|
||||
|
@ -37,7 +27,12 @@ function EventDashBoardItem(props) {
|
|||
titleStyle={{color: textColor}}
|
||||
subtitle={props.subtitle}
|
||||
subtitleStyle={{color: textColor}}
|
||||
left={() => getIcon(props.icon, iconColor)}
|
||||
left={() =>
|
||||
<Avatar.Icon
|
||||
icon={props.icon}
|
||||
color={iconColor}
|
||||
size={60}
|
||||
style={{backgroundColor: 'transparent'}}/>}
|
||||
/>
|
||||
<Card.Content>
|
||||
{props.children}
|
||||
|
|
|
@ -186,33 +186,47 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
getCardItem: Function;
|
||||
getMainCard: Function;
|
||||
onModalRef: Function;
|
||||
onPressMail: Function;
|
||||
onPressGit: Function;
|
||||
|
||||
colors: object;
|
||||
colors: Object;
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.getCardItem = this.getCardItem.bind(this);
|
||||
this.getMainCard = this.getMainCard.bind(this);
|
||||
this.onModalRef = this.onModalRef.bind(this);
|
||||
this.onPressMail = openWebLink.bind(this, links.bugsMail);
|
||||
this.onPressGit = openWebLink.bind(this, links.bugsGit);
|
||||
this.colors = props.theme.colors;
|
||||
}
|
||||
|
||||
getAppIcon(props) {
|
||||
return (
|
||||
<Avatar.Image
|
||||
{...props}
|
||||
source={require('../../assets/android.icon.png')}
|
||||
style={{backgroundColor: 'transparent'}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
keyExtractor(item: Object) {
|
||||
return item.icon;
|
||||
}
|
||||
|
||||
getAppCard() {
|
||||
return (
|
||||
<Card style={{marginBottom: 10}}>
|
||||
<Card.Title
|
||||
title={appJson.expo.name}
|
||||
subtitle={appJson.expo.version}
|
||||
left={(props) => <Avatar.Image
|
||||
{...props}
|
||||
source={require('../../assets/android.icon.png')}
|
||||
style={{backgroundColor: 'transparent'}}
|
||||
/>}/>
|
||||
left={this.getAppIcon}/>
|
||||
<Card.Content>
|
||||
<FlatList
|
||||
data={this.appData}
|
||||
extraData={this.state}
|
||||
keyExtractor={(item) => item.icon}
|
||||
keyExtractor={this.keyExtractor}
|
||||
listKey={"app"}
|
||||
renderItem={this.getCardItem}
|
||||
/>
|
||||
|
@ -232,7 +246,7 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
<FlatList
|
||||
data={this.authorData}
|
||||
extraData={this.state}
|
||||
keyExtractor={(item) => item.icon}
|
||||
keyExtractor={this.keyExtractor}
|
||||
listKey={"team1"}
|
||||
renderItem={this.getCardItem}
|
||||
/>
|
||||
|
@ -240,7 +254,7 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
<FlatList
|
||||
data={this.additionalDevData}
|
||||
extraData={this.state}
|
||||
keyExtractor={(item) => item.icon}
|
||||
keyExtractor={this.keyExtractor}
|
||||
listKey={"team2"}
|
||||
renderItem={this.getCardItem}
|
||||
/>
|
||||
|
@ -257,7 +271,7 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
<FlatList
|
||||
data={this.technoData}
|
||||
extraData={this.state}
|
||||
keyExtractor={(item) => item.icon}
|
||||
keyExtractor={this.keyExtractor}
|
||||
listKey={"techno"}
|
||||
renderItem={this.getCardItem}
|
||||
/>
|
||||
|
@ -266,6 +280,18 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
);
|
||||
}
|
||||
|
||||
getChevronIcon(props: Object) {
|
||||
return (
|
||||
<List.Icon {...props} icon={'chevron-right'}/>
|
||||
);
|
||||
}
|
||||
|
||||
getItemIcon(item: Object, props: Object) {
|
||||
return (
|
||||
<List.Icon {...props} icon={item.icon}/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a clickable card item to be rendered inside a card.
|
||||
*
|
||||
|
@ -273,13 +299,14 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
*/
|
||||
getCardItem({item}: Object) {
|
||||
let shouldShow = !item.showOnlyInDebug || (item.showOnlyInDebug && this.state.isDebugUnlocked);
|
||||
const getItemIcon = this.getItemIcon.bind(this, item);
|
||||
if (shouldShow) {
|
||||
if (item.showChevron) {
|
||||
return (
|
||||
<List.Item
|
||||
title={item.text}
|
||||
left={props => <List.Icon {...props} icon={item.icon}/>}
|
||||
right={props => <List.Icon {...props} icon={'chevron-right'}/>}
|
||||
left={getItemIcon}
|
||||
right={this.getChevronIcon}
|
||||
onPress={item.onPressCallback}
|
||||
/>
|
||||
);
|
||||
|
@ -287,16 +314,13 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
return (
|
||||
<List.Item
|
||||
title={item.text}
|
||||
left={props => <List.Icon {...props} icon={item.icon}/>}
|
||||
left={getItemIcon}
|
||||
onPress={item.onPressCallback}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
} else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tryUnlockDebugMode() {
|
||||
|
@ -313,8 +337,6 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
getBugReportModal() {
|
||||
const onPressMail = openWebLink.bind(this, links.bugsMail);
|
||||
const onPressGit = openWebLink.bind(this, links.bugsGit);
|
||||
return (
|
||||
<View style={{
|
||||
flex: 1,
|
||||
|
@ -334,7 +356,7 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
}}
|
||||
onPress={onPressMail}>
|
||||
onPress={this.onPressMail}>
|
||||
<Text>{i18n.t('aboutScreen.bugsMail')}</Text>
|
||||
</Button>
|
||||
<Button
|
||||
|
@ -347,7 +369,7 @@ class AboutScreen extends React.Component<Props, State> {
|
|||
marginLeft: 'auto',
|
||||
marginRight: 'auto',
|
||||
}}
|
||||
onPress={onPressGit}>
|
||||
onPress={this.onPressGit}>
|
||||
<Text>{i18n.t('aboutScreen.bugsGit')}</Text>
|
||||
</Button>
|
||||
</View>
|
||||
|
|
Loading…
Reference in a new issue