removed more arrow functions

This commit is contained in:
keplyx 2020-03-10 11:33:22 +01:00
parent 7bac5a6ddc
commit 67357227c0
3 changed files with 53 additions and 34 deletions

6
App.js
View file

@ -37,18 +37,20 @@ export default class App extends React.Component<Props, State> {
}; };
onIntroDone: Function; onIntroDone: Function;
onUpdateTheme: Function;
constructor() { constructor() {
super(); super();
LocaleManager.initTranslations(); LocaleManager.initTranslations();
this.onIntroDone = this.onIntroDone.bind(this); this.onIntroDone = this.onIntroDone.bind(this);
this.onUpdateTheme = this.onUpdateTheme.bind(this);
SplashScreen.preventAutoHide(); SplashScreen.preventAutoHide();
} }
/** /**
* Updates the theme * Updates the theme
*/ */
updateTheme() { onUpdateTheme() {
this.setState({ this.setState({
currentTheme: ThemeManager.getCurrentTheme() currentTheme: ThemeManager.getCurrentTheme()
}); });
@ -86,7 +88,7 @@ export default class App extends React.Component<Props, State> {
async loadAssetsAsync() { async loadAssetsAsync() {
// Wait for custom fonts to be loaded before showing the app // Wait for custom fonts to be loaded before showing the app
await AsyncStorageManager.getInstance().loadPreferences(); await AsyncStorageManager.getInstance().loadPreferences();
ThemeManager.getInstance().setUpdateThemeCallback(() => this.updateTheme()); ThemeManager.getInstance().setUpdateThemeCallback(this.onUpdateTheme);
// await NotificationsManager.initExpoToken(); // await NotificationsManager.initExpoToken();
this.onLoadFinished(); this.onLoadFinished();
} }

View file

@ -3,16 +3,6 @@
import * as React from 'react'; import * as React from 'react';
import {Avatar, Card, withTheme} from 'react-native-paper'; 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) { function EventDashBoardItem(props) {
const {colors} = props.theme; const {colors} = props.theme;
const iconColor = props.isAvailable ? const iconColor = props.isAvailable ?
@ -37,7 +27,12 @@ function EventDashBoardItem(props) {
titleStyle={{color: textColor}} titleStyle={{color: textColor}}
subtitle={props.subtitle} subtitle={props.subtitle}
subtitleStyle={{color: textColor}} subtitleStyle={{color: textColor}}
left={() => getIcon(props.icon, iconColor)} left={() =>
<Avatar.Icon
icon={props.icon}
color={iconColor}
size={60}
style={{backgroundColor: 'transparent'}}/>}
/> />
<Card.Content> <Card.Content>
{props.children} {props.children}

View file

@ -186,33 +186,47 @@ class AboutScreen extends React.Component<Props, State> {
getCardItem: Function; getCardItem: Function;
getMainCard: Function; getMainCard: Function;
onModalRef: Function; onModalRef: Function;
onPressMail: Function;
onPressGit: Function;
colors: object; colors: Object;
constructor(props) { constructor(props) {
super(props); super(props);
this.getCardItem = this.getCardItem.bind(this); this.getCardItem = this.getCardItem.bind(this);
this.getMainCard = this.getMainCard.bind(this); this.getMainCard = this.getMainCard.bind(this);
this.onModalRef = this.onModalRef.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; 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() { getAppCard() {
return ( return (
<Card style={{marginBottom: 10}}> <Card style={{marginBottom: 10}}>
<Card.Title <Card.Title
title={appJson.expo.name} title={appJson.expo.name}
subtitle={appJson.expo.version} subtitle={appJson.expo.version}
left={(props) => <Avatar.Image left={this.getAppIcon}/>
{...props}
source={require('../../assets/android.icon.png')}
style={{backgroundColor: 'transparent'}}
/>}/>
<Card.Content> <Card.Content>
<FlatList <FlatList
data={this.appData} data={this.appData}
extraData={this.state} extraData={this.state}
keyExtractor={(item) => item.icon} keyExtractor={this.keyExtractor}
listKey={"app"} listKey={"app"}
renderItem={this.getCardItem} renderItem={this.getCardItem}
/> />
@ -232,7 +246,7 @@ class AboutScreen extends React.Component<Props, State> {
<FlatList <FlatList
data={this.authorData} data={this.authorData}
extraData={this.state} extraData={this.state}
keyExtractor={(item) => item.icon} keyExtractor={this.keyExtractor}
listKey={"team1"} listKey={"team1"}
renderItem={this.getCardItem} renderItem={this.getCardItem}
/> />
@ -240,7 +254,7 @@ class AboutScreen extends React.Component<Props, State> {
<FlatList <FlatList
data={this.additionalDevData} data={this.additionalDevData}
extraData={this.state} extraData={this.state}
keyExtractor={(item) => item.icon} keyExtractor={this.keyExtractor}
listKey={"team2"} listKey={"team2"}
renderItem={this.getCardItem} renderItem={this.getCardItem}
/> />
@ -257,7 +271,7 @@ class AboutScreen extends React.Component<Props, State> {
<FlatList <FlatList
data={this.technoData} data={this.technoData}
extraData={this.state} extraData={this.state}
keyExtractor={(item) => item.icon} keyExtractor={this.keyExtractor}
listKey={"techno"} listKey={"techno"}
renderItem={this.getCardItem} 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. * 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) { getCardItem({item}: Object) {
let shouldShow = !item.showOnlyInDebug || (item.showOnlyInDebug && this.state.isDebugUnlocked); let shouldShow = !item.showOnlyInDebug || (item.showOnlyInDebug && this.state.isDebugUnlocked);
const getItemIcon = this.getItemIcon.bind(this, item);
if (shouldShow) { if (shouldShow) {
if (item.showChevron) { if (item.showChevron) {
return ( return (
<List.Item <List.Item
title={item.text} title={item.text}
left={props => <List.Icon {...props} icon={item.icon}/>} left={getItemIcon}
right={props => <List.Icon {...props} icon={'chevron-right'}/>} right={this.getChevronIcon}
onPress={item.onPressCallback} onPress={item.onPressCallback}
/> />
); );
@ -287,16 +314,13 @@ class AboutScreen extends React.Component<Props, State> {
return ( return (
<List.Item <List.Item
title={item.text} title={item.text}
left={props => <List.Icon {...props} icon={item.icon}/>} left={getItemIcon}
onPress={item.onPressCallback} onPress={item.onPressCallback}
/> />
); );
} }
} else
} else {
return null; return null;
}
} }
tryUnlockDebugMode() { tryUnlockDebugMode() {
@ -313,8 +337,6 @@ class AboutScreen extends React.Component<Props, State> {
} }
getBugReportModal() { getBugReportModal() {
const onPressMail = openWebLink.bind(this, links.bugsMail);
const onPressGit = openWebLink.bind(this, links.bugsGit);
return ( return (
<View style={{ <View style={{
flex: 1, flex: 1,
@ -334,7 +356,7 @@ class AboutScreen extends React.Component<Props, State> {
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
}} }}
onPress={onPressMail}> onPress={this.onPressMail}>
<Text>{i18n.t('aboutScreen.bugsMail')}</Text> <Text>{i18n.t('aboutScreen.bugsMail')}</Text>
</Button> </Button>
<Button <Button
@ -347,7 +369,7 @@ class AboutScreen extends React.Component<Props, State> {
marginLeft: 'auto', marginLeft: 'auto',
marginRight: 'auto', marginRight: 'auto',
}} }}
onPress={onPressGit}> onPress={this.onPressGit}>
<Text>{i18n.t('aboutScreen.bugsGit')}</Text> <Text>{i18n.t('aboutScreen.bugsGit')}</Text>
</Button> </Button>
</View> </View>