From 67357227c055bb1138cafa92e071b0cd49df0aa2 Mon Sep 17 00:00:00 2001 From: keplyx Date: Tue, 10 Mar 2020 11:33:22 +0100 Subject: [PATCH] removed more arrow functions --- App.js | 6 ++- components/EventDashboardItem.js | 17 +++------ screens/About/AboutScreen.js | 64 +++++++++++++++++++++----------- 3 files changed, 53 insertions(+), 34 deletions(-) diff --git a/App.js b/App.js index e97ad3a..5ebd217 100644 --- a/App.js +++ b/App.js @@ -37,18 +37,20 @@ export default class App extends React.Component { }; 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 { 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(); } diff --git a/components/EventDashboardItem.js b/components/EventDashboardItem.js index a265caa..cfcd2ee 100644 --- a/components/EventDashboardItem.js +++ b/components/EventDashboardItem.js @@ -3,16 +3,6 @@ import * as React from 'react'; import {Avatar, Card, withTheme} from 'react-native-paper'; -function getIcon(icon, color) { - return ( - - ); -} - 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={() => + } /> {props.children} diff --git a/screens/About/AboutScreen.js b/screens/About/AboutScreen.js index d93fb0c..ac890e8 100644 --- a/screens/About/AboutScreen.js +++ b/screens/About/AboutScreen.js @@ -186,33 +186,47 @@ class AboutScreen extends React.Component { 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 ( + + ); + } + + keyExtractor(item: Object) { + return item.icon; + } + getAppCard() { return ( }/> + left={this.getAppIcon}/> item.icon} + keyExtractor={this.keyExtractor} listKey={"app"} renderItem={this.getCardItem} /> @@ -232,7 +246,7 @@ class AboutScreen extends React.Component { item.icon} + keyExtractor={this.keyExtractor} listKey={"team1"} renderItem={this.getCardItem} /> @@ -240,7 +254,7 @@ class AboutScreen extends React.Component { item.icon} + keyExtractor={this.keyExtractor} listKey={"team2"} renderItem={this.getCardItem} /> @@ -257,7 +271,7 @@ class AboutScreen extends React.Component { item.icon} + keyExtractor={this.keyExtractor} listKey={"techno"} renderItem={this.getCardItem} /> @@ -266,6 +280,18 @@ class AboutScreen extends React.Component { ); } + getChevronIcon(props: Object) { + return ( + + ); + } + + getItemIcon(item: Object, props: Object) { + return ( + + ); + } + /** * Get a clickable card item to be rendered inside a card. * @@ -273,13 +299,14 @@ class AboutScreen extends React.Component { */ 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 ( } - right={props => } + left={getItemIcon} + right={this.getChevronIcon} onPress={item.onPressCallback} /> ); @@ -287,16 +314,13 @@ class AboutScreen extends React.Component { return ( } + left={getItemIcon} onPress={item.onPressCallback} /> ); } - - } else { + } else return null; - } - } tryUnlockDebugMode() { @@ -313,8 +337,6 @@ class AboutScreen extends React.Component { } getBugReportModal() { - const onPressMail = openWebLink.bind(this, links.bugsMail); - const onPressGit = openWebLink.bind(this, links.bugsGit); return ( { marginLeft: 'auto', marginRight: 'auto', }} - onPress={onPressMail}> + onPress={this.onPressMail}> {i18n.t('aboutScreen.bugsMail')}