Optimised imported and cleaned code

This commit is contained in:
keplyx 2020-01-31 16:51:43 +01:00
parent b62ad1fd4a
commit c478a117b5
28 changed files with 169 additions and 256 deletions

View file

@ -5,7 +5,7 @@ import {Container} from "native-base";
import CustomHeader from "./CustomHeader"; import CustomHeader from "./CustomHeader";
import CustomSideMenu from "./CustomSideMenu"; import CustomSideMenu from "./CustomSideMenu";
import CustomMaterialIcon from "./CustomMaterialIcon"; import CustomMaterialIcon from "./CustomMaterialIcon";
import {Platform, View, StatusBar} from "react-native"; import {Platform, StatusBar, View} from "react-native";
import ThemeManager from "../utils/ThemeManager"; import ThemeManager from "../utils/ThemeManager";
import Touchable from "react-native-platform-touchable"; import Touchable from "react-native-platform-touchable";
import {ScreenOrientation} from "expo"; import {ScreenOrientation} from "expo";
@ -32,9 +32,6 @@ type State = {
export default class BaseContainer extends React.Component<Props, State> { export default class BaseContainer extends React.Component<Props, State> {
willBlurSubscription: function;
willFocusSubscription: function;
static defaultProps = { static defaultProps = {
headerRightButton: <View/>, headerRightButton: <View/>,
hasTabs: false, hasTabs: false,
@ -43,8 +40,8 @@ export default class BaseContainer extends React.Component<Props, State> {
enableRotation: false, enableRotation: false,
hideHeaderOnLandscape: false, hideHeaderOnLandscape: false,
}; };
willBlurSubscription: function;
willFocusSubscription: function;
state = { state = {
isOpen: false, isOpen: false,
isHeaderVisible: true, isHeaderVisible: true,
@ -66,7 +63,7 @@ export default class BaseContainer extends React.Component<Props, State> {
componentDidMount() { componentDidMount() {
this.willFocusSubscription = this.props.navigation.addListener( this.willFocusSubscription = this.props.navigation.addListener(
'willFocus', 'willFocus',
payload => { () => {
if (this.props.enableRotation) { if (this.props.enableRotation) {
ScreenOrientation.unlockAsync(); ScreenOrientation.unlockAsync();
ScreenOrientation.addOrientationChangeListener((OrientationChangeEvent) => { ScreenOrientation.addOrientationChangeListener((OrientationChangeEvent) => {
@ -87,7 +84,7 @@ export default class BaseContainer extends React.Component<Props, State> {
}); });
this.willBlurSubscription = this.props.navigation.addListener( this.willBlurSubscription = this.props.navigation.addListener(
'willBlur', 'willBlur',
payload => { () => {
if (this.props.enableRotation) if (this.props.enableRotation)
ScreenOrientation.lockAsync(ScreenOrientation.Orientation.PORTRAIT); ScreenOrientation.lockAsync(ScreenOrientation.Orientation.PORTRAIT);
this.setState({isOpen: false}); this.setState({isOpen: false});

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as React from "react"; import * as React from "react";
import {Body, Header, Input, Item, Left, Right, Title, Form} from "native-base"; import {Body, Header, Input, Item, Left, Right, Title} from "native-base";
import {Platform, StyleSheet, View} from "react-native"; import {Platform, StyleSheet, View} from "react-native";
import {getStatusBarHeight} from "react-native-status-bar-height"; import {getStatusBarHeight} from "react-native-status-bar-height";
import Touchable from 'react-native-platform-touchable'; import Touchable from 'react-native-platform-touchable';

View file

@ -35,13 +35,6 @@ export default class FetchedDataSectionList extends React.Component<Props, State
lastRefresh: Date; lastRefresh: Date;
minTimeBetweenRefresh = 60; minTimeBetweenRefresh = 60;
constructor(fetchUrl: string, refreshTime: number) {
super();
this.webDataManager = new WebDataManager(fetchUrl);
this.refreshTime = refreshTime;
}
state = { state = {
refreshing: false, refreshing: false,
firstLoading: true, firstLoading: true,
@ -49,6 +42,12 @@ export default class FetchedDataSectionList extends React.Component<Props, State
machinesWatched: [], machinesWatched: [],
}; };
constructor(fetchUrl: string, refreshTime: number) {
super();
this.webDataManager = new WebDataManager(fetchUrl);
this.refreshTime = refreshTime;
}
/** /**
* Get the translation for the header in the current language * Get the translation for the header in the current language
* @return {string} * @return {string}
@ -76,13 +75,13 @@ export default class FetchedDataSectionList extends React.Component<Props, State
componentDidMount() { componentDidMount() {
this.willFocusSubscription = this.props.navigation.addListener( this.willFocusSubscription = this.props.navigation.addListener(
'willFocus', 'willFocus',
payload => { () => {
this.onScreenFocus(); this.onScreenFocus();
} }
); );
this.willBlurSubscription = this.props.navigation.addListener( this.willBlurSubscription = this.props.navigation.addListener(
'willBlur', 'willBlur',
payload => { () => {
this.onScreenBlur(); this.onScreenBlur();
} }
); );
@ -136,7 +135,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
}); });
this.lastRefresh = new Date(); this.lastRefresh = new Date();
}) })
.catch((err) => { .catch(() => {
this.setState({ this.setState({
fetchedData: {}, fetchedData: {},
refreshing: false, refreshing: false,

View file

@ -2,12 +2,11 @@
import * as React from 'react'; import * as React from 'react';
import {Dimensions, FlatList, Image, Linking, Platform, StyleSheet} from 'react-native'; import {Dimensions, FlatList, Image, Linking, Platform, StyleSheet} from 'react-native';
import {Badge, Container, Content, Left, ListItem, Right, Text} from "native-base"; import {Badge, Container, Left, ListItem, Right, Text} from "native-base";
import i18n from "i18n-js"; import i18n from "i18n-js";
import CustomMaterialIcon from '../components/CustomMaterialIcon'; import CustomMaterialIcon from '../components/CustomMaterialIcon';
import ThemeManager from "../utils/ThemeManager"; import ThemeManager from "../utils/ThemeManager";
const deviceHeight = Dimensions.get("window").height;
const deviceWidth = Dimensions.get("window").width; const deviceWidth = Dimensions.get("window").width;
const drawerCover = require("../assets/drawer-cover.png"); const drawerCover = require("../assets/drawer-cover.png");

View file

@ -2,13 +2,12 @@
import * as React from 'react'; import * as React from 'react';
import {Linking, Platform, View} from 'react-native'; import {Linking, Platform, View} from 'react-native';
import {Spinner, Footer, Right, Left, Body, Tab, TabHeading, Text, Tabs} from 'native-base'; import {Body, Footer, Left, Right, Spinner, Tab, TabHeading, Tabs, Text} from 'native-base';
import WebView from "react-native-webview"; import WebView from "react-native-webview";
import Touchable from "react-native-platform-touchable"; import Touchable from "react-native-platform-touchable";
import CustomMaterialIcon from "../components/CustomMaterialIcon"; import CustomMaterialIcon from "../components/CustomMaterialIcon";
import ThemeManager from "../utils/ThemeManager"; import ThemeManager from "../utils/ThemeManager";
import BaseContainer from "../components/BaseContainer"; import BaseContainer from "../components/BaseContainer";
import {NavigationActions} from 'react-navigation';
type Props = { type Props = {
navigation: Object, navigation: Object,
@ -153,7 +152,7 @@ export default class WebViewScreen extends React.Component<Props> {
elevation: 0, // Fix for android shadow elevation: 0, // Fix for android shadow
}} }}
locked={true} locked={true}
style = {{ style={{
backgroundColor: Platform.OS === 'ios' ? backgroundColor: Platform.OS === 'ios' ?
ThemeManager.getCurrentThemeVariables().tabDefaultBg : ThemeManager.getCurrentThemeVariables().tabDefaultBg :
ThemeManager.getCurrentThemeVariables().brandPrimary ThemeManager.getCurrentThemeVariables().brandPrimary

View file

@ -52,4 +52,5 @@ function createAppContainerWithInitialRoute(initialRoute: string) {
}) })
); );
} }
export {createAppContainerWithInitialRoute}; export {createAppContainerWithInitialRoute};

View file

@ -1,34 +0,0 @@
// @flow
import * as React from 'react';
import {createDrawerNavigator} from 'react-navigation';
import HomeScreen from '../screens/HomeScreen';
import PlanningScreen from '../screens/PlanningScreen';
import ProxiwashScreen from '../screens/Proxiwash/ProxiwashScreen';
import ProximoMainScreen from '../screens/Proximo/ProximoMainScreen';
import PlanexScreen from '../screens/Websites/PlanexScreen';
import SettingsScreen from '../screens/SettingsScreen';
import AboutScreen from '../screens/About/AboutScreen';
import Sidebar from "../components/Sidebar";
/**
* Creates the drawer navigation stack
*/
export default createDrawerNavigator({
Home: {screen: HomeScreen},
Planning: {screen: PlanningScreen,},
Proxiwash: {screen: ProxiwashScreen,},
Proximo: {screen: ProximoMainScreen,},
Planex: {screen: PlanexScreen},
Settings: {screen: SettingsScreen,},
About: {screen: AboutScreen,},
}, {
contentComponent: Sidebar,
initialRouteName: 'Home',
backBehavior: 'initialRoute',
drawerType: 'front',
useNativeAnimations: true,
}
);

View file

@ -8,7 +8,6 @@ import ProximoMainScreen from '../screens/Proximo/ProximoMainScreen';
import PlanexScreen from '../screens/Websites/PlanexScreen'; import PlanexScreen from '../screens/Websites/PlanexScreen';
import CustomMaterialIcon from "../components/CustomMaterialIcon"; import CustomMaterialIcon from "../components/CustomMaterialIcon";
import ThemeManager from "../utils/ThemeManager"; import ThemeManager from "../utils/ThemeManager";
import AsyncStorageManager from "../utils/AsyncStorageManager";
const TAB_ICONS = { const TAB_ICONS = {
Home: 'triangle', Home: 'triangle',

View file

@ -8,8 +8,6 @@
"eject": "expo eject" "eject": "expo eject"
}, },
"dependencies": { "dependencies": {
"@expo/vector-icons": "^10.0.0",
"@react-native-community/status-bar": "^1.0.3",
"expo": "^36.0.0", "expo": "^36.0.0",
"expo-font": "~8.0.0", "expo-font": "~8.0.0",
"expo-linear-gradient": "~8.0.0", "expo-linear-gradient": "~8.0.0",
@ -27,8 +25,10 @@
"react-native-gesture-handler": "~1.5.0", "react-native-gesture-handler": "~1.5.0",
"react-native-material-menu": "^0.6.7", "react-native-material-menu": "^0.6.7",
"react-native-modalize": "^1.3.6", "react-native-modalize": "^1.3.6",
"react-native-paper": "^3.5.1",
"react-native-platform-touchable": "^1.1.1", "react-native-platform-touchable": "^1.1.1",
"react-native-render-html": "^4.1.2", "react-native-render-html": "^4.1.2",
"react-native-screens": "2.0.0-alpha.12",
"react-native-side-menu": "^1.1.3", "react-native-side-menu": "^1.1.3",
"react-native-status-bar-height": "^2.3.1", "react-native-status-bar-height": "^2.3.1",
"react-native-webview": "7.4.3", "react-native-webview": "7.4.3",

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {Body, Container, Content, ListItem, Text} from 'native-base'; import {Body, Container, ListItem, Text} from 'native-base';
import CustomHeader from "../../components/CustomHeader"; import CustomHeader from "../../components/CustomHeader";
import {FlatList} from "react-native"; import {FlatList} from "react-native";
import i18n from "i18n-js"; import i18n from "i18n-js";

View file

@ -2,7 +2,7 @@
import * as React from 'react'; import * as React from 'react';
import {FlatList, Linking, Platform, View} from 'react-native'; import {FlatList, Linking, Platform, View} from 'react-native';
import {Body, Card, CardItem, Container, Content, H1, Left, Right, Text, Thumbnail, Button} from 'native-base'; import {Body, Button, Card, CardItem, Container, H1, Left, Right, Text, Thumbnail} from 'native-base';
import CustomHeader from "../../components/CustomHeader"; import CustomHeader from "../../components/CustomHeader";
import i18n from "i18n-js"; import i18n from "i18n-js";
import appJson from '../../app'; import appJson from '../../app';
@ -70,12 +70,6 @@ export default class AboutScreen extends React.Component<Props, State> {
state = { state = {
isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1' isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
}; };
constructor(props: any) {
super(props);
this.modalRef = React.createRef();
}
/** /**
* Data to be displayed in the app card * Data to be displayed in the app card
*/ */
@ -118,7 +112,6 @@ export default class AboutScreen extends React.Component<Props, State> {
showOnlyDebug: true showOnlyDebug: true
}, },
]; ];
/** /**
* Data to be displayed in the author card * Data to be displayed in the author card
*/ */
@ -142,7 +135,6 @@ export default class AboutScreen extends React.Component<Props, State> {
showChevron: true showChevron: true
}, },
]; ];
/** /**
* Data to be displayed in the additional developer card * Data to be displayed in the additional developer card
*/ */
@ -166,7 +158,6 @@ export default class AboutScreen extends React.Component<Props, State> {
showChevron: true showChevron: true
}, },
]; ];
/** /**
* Data to be displayed in the technologies card * Data to be displayed in the technologies card
*/ */
@ -184,7 +175,6 @@ export default class AboutScreen extends React.Component<Props, State> {
showChevron: true showChevron: true
}, },
]; ];
dataOrder: Array<Object> = [ dataOrder: Array<Object> = [
{ {
id: 'app', id: 'app',
@ -197,6 +187,11 @@ export default class AboutScreen extends React.Component<Props, State> {
}, },
]; ];
constructor(props: any) {
super(props);
this.modalRef = React.createRef();
}
getAppCard() { getAppCard() {
return ( return (
<Card> <Card>

View file

@ -3,29 +3,28 @@
import * as React from 'react'; import * as React from 'react';
import { import {
Body, Body,
Button,
Card, Card,
CardItem, CardItem,
Container, Container,
Content, Content,
Form,
H1, H1,
H3, H3,
Input,
Item,
Label,
Left, Left,
List, List,
ListItem, ListItem,
Right, Right,
Text, Text
Form,
Item,
Label,
Input,
Button
} from "native-base"; } from "native-base";
import CustomHeader from "../components/CustomHeader"; import CustomHeader from "../components/CustomHeader";
import ThemeManager from '../utils/ThemeManager'; import ThemeManager from '../utils/ThemeManager';
import i18n from "i18n-js"; import i18n from "i18n-js";
import CustomMaterialIcon from "../components/CustomMaterialIcon"; import CustomMaterialIcon from "../components/CustomMaterialIcon";
import Touchable from "react-native-platform-touchable"; import {Alert, Clipboard, View} from "react-native";
import {Alert, View, Clipboard, Image} from "react-native";
import AsyncStorageManager from "../utils/AsyncStorageManager"; import AsyncStorageManager from "../utils/AsyncStorageManager";
import NotificationsManager from "../utils/NotificationsManager"; import NotificationsManager from "../utils/NotificationsManager";
import {Modalize} from "react-native-modalize"; import {Modalize} from "react-native-modalize";
@ -46,36 +45,16 @@ export default class DebugScreen extends React.Component<Props, State> {
modalRef: { current: null | Modalize }; modalRef: { current: null | Modalize };
modalInputValue = ''; modalInputValue = '';
constructor(props: any) {
super(props);
this.modalRef = React.createRef();
}
state = { state = {
modalCurrentDisplayItem: {}, modalCurrentDisplayItem: {},
currentPreferences: JSON.parse(JSON.stringify(AsyncStorageManager.getInstance().preferences)) currentPreferences: JSON.parse(JSON.stringify(AsyncStorageManager.getInstance().preferences))
}; };
alertCurrentExpoToken() { constructor(props: any) {
let token = AsyncStorageManager.getInstance().preferences.expoToken.current; super(props);
console.log(token); this.modalRef = React.createRef();
Alert.alert(
'Expo Token',
token,
[
{text: 'Copy', onPress: () => Clipboard.setString(token)},
{text: 'OK'}
]
);
} }
async forceExpoTokenUpdate() {
await NotificationsManager.forceExpoTokenUpdate();
this.alertCurrentExpoToken();
}
static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) { static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) {
return ( return (
<ListItem <ListItem
@ -102,6 +81,24 @@ export default class DebugScreen extends React.Component<Props, State> {
); );
} }
alertCurrentExpoToken() {
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
console.log(token);
Alert.alert(
'Expo Token',
token,
[
{text: 'Copy', onPress: () => Clipboard.setString(token)},
{text: 'OK'}
]
);
}
async forceExpoTokenUpdate() {
await NotificationsManager.forceExpoTokenUpdate();
this.alertCurrentExpoToken();
}
showEditModal(item: Object) { showEditModal(item: Object) {
this.setState({ this.setState({
modalCurrentDisplayItem: item modalCurrentDisplayItem: item

View file

@ -2,7 +2,7 @@
import * as React from 'react'; import * as React from 'react';
import {Image, Linking, TouchableOpacity, View} from 'react-native'; import {Image, Linking, TouchableOpacity, View} from 'react-native';
import {Body, Button, Card, CardItem, Left, Text, Thumbnail, H1, H3} from 'native-base'; import {Body, Button, Card, CardItem, H1, Left, Text, Thumbnail} from 'native-base';
import i18n from "i18n-js"; import i18n from "i18n-js";
import CustomMaterialIcon from '../components/CustomMaterialIcon'; import CustomMaterialIcon from '../components/CustomMaterialIcon';
import FetchedDataSectionList from "../components/FetchedDataSectionList"; import FetchedDataSectionList from "../components/FetchedDataSectionList";
@ -42,6 +42,16 @@ export default class HomeScreen extends FetchedDataSectionList {
super(DATA_URL, REFRESH_TIME); super(DATA_URL, REFRESH_TIME);
} }
/**
* Converts a dateString using Unix Timestamp to a formatted date
* @param dateString {string} The Unix Timestamp representation of a date
* @return {string} The formatted output date
*/
static getFormattedDate(dateString: string) {
let date = new Date(Number.parseInt(dateString) * 1000);
return date.toLocaleString();
}
getHeaderTranslation() { getHeaderTranslation() {
return i18n.t("screens.home"); return i18n.t("screens.home");
} }
@ -119,17 +129,6 @@ export default class HomeScreen extends FetchedDataSectionList {
return dataset return dataset
} }
/**
* Converts a dateString using Unix Timestamp to a formatted date
* @param dateString {string} The Unix Timestamp representation of a date
* @return {string} The formatted output date
*/
static getFormattedDate(dateString: string) {
let date = new Date(Number.parseInt(dateString) * 1000);
return date.toLocaleString();
}
getRenderSectionHeader(title: string) { getRenderSectionHeader(title: string) {
if (title === '') { if (title === '') {
return <View/>; return <View/>;
@ -294,7 +293,7 @@ export default class HomeScreen extends FetchedDataSectionList {
let icon = 'calendar-range'; let icon = 'calendar-range';
let color = ThemeManager.getCurrentThemeVariables().planningColor; let color = ThemeManager.getCurrentThemeVariables().planningColor;
let title = i18n.t('homeScreen.dashboard.todayEventsTitle'); let title = i18n.t('homeScreen.dashboard.todayEventsTitle');
let subtitle = ''; let subtitle;
let futureEvents = this.getFutureEvents(content); let futureEvents = this.getFutureEvents(content);
let isAvailable = futureEvents.length > 0; let isAvailable = futureEvents.length > 0;
if (isAvailable) { if (isAvailable) {
@ -336,7 +335,7 @@ export default class HomeScreen extends FetchedDataSectionList {
let proximoColor = ThemeManager.getCurrentThemeVariables().proximoColor; let proximoColor = ThemeManager.getCurrentThemeVariables().proximoColor;
let proximoTitle = i18n.t('homeScreen.dashboard.proximoTitle'); let proximoTitle = i18n.t('homeScreen.dashboard.proximoTitle');
let isProximoAvailable = parseInt(proximoData) > 0; let isProximoAvailable = parseInt(proximoData) > 0;
let proximoSubtitle = ''; let proximoSubtitle;
if (isProximoAvailable) { if (isProximoAvailable) {
proximoSubtitle = proximoSubtitle =
<Text> <Text>
@ -358,7 +357,7 @@ export default class HomeScreen extends FetchedDataSectionList {
let menuColor = ThemeManager.getCurrentThemeVariables().menuColor; let menuColor = ThemeManager.getCurrentThemeVariables().menuColor;
let menuTitle = i18n.t('homeScreen.dashboard.menuTitle'); let menuTitle = i18n.t('homeScreen.dashboard.menuTitle');
let isMenuAvailable = menuData.length > 0; let isMenuAvailable = menuData.length > 0;
let menuSubtitle = ''; let menuSubtitle;
if (isMenuAvailable) { if (isMenuAvailable) {
menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle'); menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
} else } else
@ -497,10 +496,8 @@ export default class HomeScreen extends FetchedDataSectionList {
getRenderItem(item: Object, section: Object, data: Object) { getRenderItem(item: Object, section: Object, data: Object) {
if (section['id'] === SECTIONS_ID[0]) {
return this.getDashboardItem(item);
} else {
return ( return (
section['id'] === SECTIONS_ID[0] ? this.getDashboardItem(item) :
<Card style={{ <Card style={{
flex: 0, flex: 0,
marginLeft: 10, marginLeft: 10,
@ -557,6 +554,4 @@ export default class HomeScreen extends FetchedDataSectionList {
</Card> </Card>
); );
} }
}
} }

View file

@ -1,10 +1,9 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {BackHandler} from 'react-native'; import {BackHandler, Image, View} from 'react-native';
import {Content, H1, H3, Text, Button} from 'native-base'; import {Button, Content, H1, H3, Text} from 'native-base';
import i18n from "i18n-js"; import i18n from "i18n-js";
import {View, Image} from "react-native";
import ThemeManager from "../utils/ThemeManager"; import ThemeManager from "../utils/ThemeManager";
import {Linking} from "expo"; import {Linking} from "expo";
import BaseContainer from "../components/BaseContainer"; import BaseContainer from "../components/BaseContainer";
@ -61,6 +60,12 @@ export default class PlanningScreen extends React.Component<Props, State> {
didFocusSubscription: Function; didFocusSubscription: Function;
willBlurSubscription: Function; willBlurSubscription: Function;
state = {
modalCurrentDisplayItem: {},
refreshing: false,
agendaItems: {},
calendarShowing: false,
};
constructor(props: any) { constructor(props: any) {
super(props); super(props);
@ -68,7 +73,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
this.webDataManager = new WebDataManager(FETCH_URL); this.webDataManager = new WebDataManager(FETCH_URL);
this.didFocusSubscription = props.navigation.addListener( this.didFocusSubscription = props.navigation.addListener(
'didFocus', 'didFocus',
payload => () =>
BackHandler.addEventListener( BackHandler.addEventListener(
'hardwareBackPress', 'hardwareBackPress',
this.onBackButtonPressAndroid this.onBackButtonPressAndroid
@ -83,7 +88,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
this._onRefresh(); this._onRefresh();
this.willBlurSubscription = this.props.navigation.addListener( this.willBlurSubscription = this.props.navigation.addListener(
'willBlur', 'willBlur',
payload => () =>
BackHandler.removeEventListener( BackHandler.removeEventListener(
'hardwareBackPress', 'hardwareBackPress',
this.onBackButtonPressAndroid this.onBackButtonPressAndroid
@ -105,13 +110,6 @@ export default class PlanningScreen extends React.Component<Props, State> {
this.willBlurSubscription && this.willBlurSubscription.remove(); this.willBlurSubscription && this.willBlurSubscription.remove();
} }
state = {
modalCurrentDisplayItem: {},
refreshing: false,
agendaItems: {},
calendarShowing: false,
};
getCurrentDate() { getCurrentDate() {
let today = new Date(); let today = new Date();
return this.getFormattedDate(today); return this.getFormattedDate(today);
@ -351,7 +349,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
getFormattedTime(event: Object) { getFormattedTime(event: Object) {
if (this.getEventEndTime(event) !== "") if (this.getEventEndTime(event) !== "")
return this.getEventStartTime(event) + " - " + this.getEventEndTime(event) return this.getEventStartTime(event) + " - " + this.getEventEndTime(event);
else else
return this.getEventStartTime(event); return this.getEventStartTime(event);
} }

View file

@ -2,7 +2,7 @@
import * as React from 'react'; import * as React from 'react';
import {Image, Linking, View} from 'react-native'; import {Image, Linking, View} from 'react-native';
import {Body, Card, CardItem, Container, Content, H2, Left, Text} from 'native-base'; import {Card, CardItem, Container, Content, H2, Left, Text} from 'native-base';
import CustomHeader from "../../components/CustomHeader"; import CustomHeader from "../../components/CustomHeader";
import i18n from "i18n-js"; import i18n from "i18n-js";
import CustomMaterialIcon from "../../components/CustomMaterialIcon"; import CustomMaterialIcon from "../../components/CustomMaterialIcon";
@ -11,14 +11,6 @@ type Props = {
navigation: Object, navigation: Object,
}; };
/**
* Opens a link in the device's browser
* @param link The link to open
*/
function openWebLink(link) {
Linking.openURL(link).catch((err) => console.error('Error opening link', err));
}
/** /**
* Class defining an about screen. This screen shows the user information about the app and it's author. * Class defining an about screen. This screen shows the user information about the app and it's author.
*/ */

View file

@ -1,9 +1,9 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {Body, Container, Content, Left, ListItem, Right, Text, Thumbnail, H1, H3} from 'native-base'; import {Body, Container, Content, H1, H3, Left, ListItem, Right, Text, Thumbnail} from 'native-base';
import CustomHeader from "../../components/CustomHeader"; import CustomHeader from "../../components/CustomHeader";
import {FlatList, Platform, View, Image} from "react-native"; import {FlatList, Image, Platform, View} from "react-native";
import Touchable from 'react-native-platform-touchable'; import Touchable from 'react-native-platform-touchable';
import Menu, {MenuItem} from 'react-native-material-menu'; import Menu, {MenuItem} from 'react-native-material-menu';
import i18n from "i18n-js"; import i18n from "i18n-js";
@ -62,13 +62,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
originalData: Array<Object>; originalData: Array<Object>;
navData = this.props.navigation.getParam('data', []); navData = this.props.navigation.getParam('data', []);
shouldFocusSearchBar = this.props.navigation.getParam('shouldFocusSearchBar', false); shouldFocusSearchBar = this.props.navigation.getParam('shouldFocusSearchBar', false);
constructor(props: any) {
super(props);
this.modalRef = React.createRef();
this.originalData = this.navData['data'];
}
state = { state = {
currentlyDisplayedData: this.navData['data'].sort(sortPrice), currentlyDisplayedData: this.navData['data'].sort(sortPrice),
currentSortMode: sortMode.price, currentSortMode: sortMode.price,
@ -77,9 +70,14 @@ export default class ProximoListScreen extends React.Component<Props, State> {
sortNameIcon: '', sortNameIcon: '',
modalCurrentDisplayItem: {}, modalCurrentDisplayItem: {},
}; };
_menu: Menu; _menu: Menu;
constructor(props: any) {
super(props);
this.modalRef = React.createRef();
this.originalData = this.navData['data'];
}
/** /**
* Saves the reference to the sort menu for later use * Saves the reference to the sort menu for later use
* *
@ -132,9 +130,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
} }
break; break;
} }
this.setState({
navData: data,
});
this.setupSortIcons(mode, isReverse); this.setupSortIcons(mode, isReverse);
this._menu.hide(); this._menu.hide();
} }
@ -297,7 +292,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
render() { render() {
const nav = this.props.navigation; const nav = this.props.navigation;
const navType = nav.getParam('type', '{name: "Error"}');
return ( return (
<Container> <Container>
<Modalize ref={this.modalRef} <Modalize ref={this.modalRef}

View file

@ -2,7 +2,7 @@
import * as React from 'react'; import * as React from 'react';
import {Platform, View} from 'react-native' import {Platform, View} from 'react-native'
import {Badge, Body, Left, ListItem, Right, Text} from 'native-base'; import {Body, Left, ListItem, Right, Text} from 'native-base';
import i18n from "i18n-js"; import i18n from "i18n-js";
import CustomMaterialIcon from "../../components/CustomMaterialIcon"; import CustomMaterialIcon from "../../components/CustomMaterialIcon";
import FetchedDataSectionList from "../../components/FetchedDataSectionList"; import FetchedDataSectionList from "../../components/FetchedDataSectionList";
@ -22,6 +22,10 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
super(DATA_URL, 0); super(DATA_URL, 0);
} }
static sortFinalData(a: Object, b: Object) {
return a.type.id - b.type.id;
}
getHeaderTranslation() { getHeaderTranslation() {
return i18n.t("screens.proximo"); return i18n.t("screens.proximo");
} }
@ -96,10 +100,6 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
return availableArticles; return availableArticles;
} }
static sortFinalData(a: Object, b: Object) {
return a.type.id - b.type.id;
}
getRightButton() { getRightButton() {
let searchScreenData = { let searchScreenData = {
shouldFocusSearchBar: true, shouldFocusSearchBar: true,

View file

@ -1,7 +1,7 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {Image, Linking, View} from 'react-native'; import {Image, View} from 'react-native';
import {Body, Card, CardItem, Container, Content, H2, H3, Left, Tab, TabHeading, Tabs, Text} from 'native-base'; import {Body, Card, CardItem, Container, Content, H2, H3, Left, Tab, TabHeading, Tabs, Text} from 'native-base';
import CustomHeader from "../../components/CustomHeader"; import CustomHeader from "../../components/CustomHeader";
import i18n from "i18n-js"; import i18n from "i18n-js";
@ -12,14 +12,6 @@ type Props = {
navigation: Object, navigation: Object,
}; };
/**
* Opens a link in the device's browser
* @param link The link to open
*/
function openWebLink(link) {
Linking.openURL(link).catch((err) => console.error('Error opening link', err));
}
/** /**
* Class defining an about screen. This screen shows the user information about the app and it's author. * Class defining an about screen. This screen shows the user information about the app and it's author.
*/ */

View file

@ -89,7 +89,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
this.setState({machinesWatched: fetchedList}) this.setState({machinesWatched: fetchedList})
}); });
// Get updated watchlist after received notification // Get updated watchlist after received notification
Expo.Notifications.addListener((notification) => { Expo.Notifications.addListener(() => {
NotificationsManager.getMachineNotificationWatchlist((fetchedList) => { NotificationsManager.getMachineNotificationWatchlist((fetchedList) => {
this.setState({machinesWatched: fetchedList}) this.setState({machinesWatched: fetchedList})
}); });

View file

@ -2,11 +2,10 @@
import * as React from 'react'; import * as React from 'react';
import {View} from 'react-native'; import {View} from 'react-native';
import {Text, H2, H3, Card, CardItem} from 'native-base'; import {Card, CardItem, H2, H3, Text} from 'native-base';
import ThemeManager from "../utils/ThemeManager"; import ThemeManager from "../utils/ThemeManager";
import i18n from "i18n-js"; import i18n from "i18n-js";
import FetchedDataSectionList from "../components/FetchedDataSectionList"; import FetchedDataSectionList from "../components/FetchedDataSectionList";
import LocaleManager from "../utils/LocaleManager";
const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/menu/menu_data.json"; const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~amicale_app/menu/menu_data.json";
@ -64,7 +63,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
return true; return true;
} }
hasSideMenu() : boolean { hasSideMenu(): boolean {
return false; return false;
} }
@ -150,7 +149,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
flexDirection: 'column', flexDirection: 'column',
paddingTop: 0, paddingTop: 0,
}}> }}>
{item.dishes.map((object, i) => {item.dishes.map((object) =>
<View> <View>
{object.name !== "" ? {object.name !== "" ?
<Text style={{ <Text style={{

View file

@ -21,8 +21,6 @@ import i18n from "i18n-js";
import {NavigationActions, StackActions} from "react-navigation"; import {NavigationActions, StackActions} from "react-navigation";
import CustomMaterialIcon from "../components/CustomMaterialIcon"; import CustomMaterialIcon from "../components/CustomMaterialIcon";
import AsyncStorageManager from "../utils/AsyncStorageManager"; import AsyncStorageManager from "../utils/AsyncStorageManager";
import Touchable from "react-native-platform-touchable";
import {Platform} from "react-native";
import NotificationsManager from "../utils/NotificationsManager"; import NotificationsManager from "../utils/NotificationsManager";
type Props = { type Props = {
@ -45,6 +43,39 @@ export default class SettingsScreen extends React.Component<Props, State> {
startScreenPickerSelected: AsyncStorageManager.getInstance().preferences.defaultStartScreen.current, startScreenPickerSelected: AsyncStorageManager.getInstance().preferences.defaultStartScreen.current,
}; };
/**
* Get a list item using the specified control
*
* @param control The custom control to use
* @param icon The icon name to display on the list item
* @param title The text to display as this list item title
* @param subtitle The text to display as this list item subtitle
* @returns {React.Node}
*/
static getGeneralItem(control: React.Node, icon: string, title: string, subtitle: string) {
return (
<ListItem
thumbnail
>
<Left>
<CustomMaterialIcon icon={icon}/>
</Left>
<Body>
<Text>
{title}
</Text>
<Text note>
{subtitle}
</Text>
</Body>
<Right>
{control}
</Right>
</ListItem>
);
}
/** /**
* Save the value for the proxiwash reminder notification time * Save the value for the proxiwash reminder notification time
* *
@ -179,39 +210,6 @@ export default class SettingsScreen extends React.Component<Props, State> {
); );
} }
/**
* Get a list item using the specified control
*
* @param control The custom control to use
* @param icon The icon name to display on the list item
* @param title The text to display as this list item title
* @param subtitle The text to display as this list item subtitle
* @returns {React.Node}
*/
static getGeneralItem(control: React.Node, icon: string, title: string, subtitle: string) {
return (
<ListItem
thumbnail
>
<Left>
<CustomMaterialIcon icon={icon}/>
</Left>
<Body>
<Text>
{title}
</Text>
<Text note>
{subtitle}
</Text>
</Body>
<Right>
{control}
</Right>
</ListItem>
);
}
render() { render() {
const nav = this.props.navigation; const nav = this.props.navigation;
return ( return (

View file

@ -1,7 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import ThemeManager from "../../utils/ThemeManager";
import WebViewScreen from "../../components/WebViewScreen"; import WebViewScreen from "../../components/WebViewScreen";
type Props = { type Props = {

View file

@ -1,7 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import ThemeManager from "../../utils/ThemeManager";
import WebViewScreen from "../../components/WebViewScreen"; import WebViewScreen from "../../components/WebViewScreen";
import i18n from "i18n-js"; import i18n from "i18n-js";

View file

@ -1,7 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import ThemeManager from "../../utils/ThemeManager";
import WebViewScreen from "../../components/WebViewScreen"; import WebViewScreen from "../../components/WebViewScreen";
type Props = { type Props = {

View file

@ -1,7 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import ThemeManager from "../../utils/ThemeManager";
import WebViewScreen from "../../components/WebViewScreen"; import WebViewScreen from "../../components/WebViewScreen";
import i18n from "i18n-js"; import i18n from "i18n-js";
@ -50,7 +49,7 @@ export default class EntScreen extends React.Component<Props> {
'let stylesheet = document.createElement(\'link\');\n' + 'let stylesheet = document.createElement(\'link\');\n' +
'stylesheet.type = \'text/css\';\n' + 'stylesheet.type = \'text/css\';\n' +
'stylesheet.rel = \'stylesheet\';\n' + 'stylesheet.rel = \'stylesheet\';\n' +
'stylesheet.href = \'' + CUSTOM_CSS_GENERAL +'\';\n' + 'stylesheet.href = \'' + CUSTOM_CSS_GENERAL + '\';\n' +
'let mobileSpec = document.createElement(\'meta\');\n' + 'let mobileSpec = document.createElement(\'meta\');\n' +
'mobileSpec.name = \'viewport\';\n' + 'mobileSpec.name = \'viewport\';\n' +
'mobileSpec.content = \'width=device-width, initial-scale=1.0\';\n' + 'mobileSpec.content = \'width=device-width, initial-scale=1.0\';\n' +

View file

@ -3,7 +3,6 @@
import * as React from 'react'; import * as React from 'react';
import ThemeManager from "../../utils/ThemeManager"; import ThemeManager from "../../utils/ThemeManager";
import WebViewScreen from "../../components/WebViewScreen"; import WebViewScreen from "../../components/WebViewScreen";
import i18n from "i18n-js";
type Props = { type Props = {
navigation: Object, navigation: Object,

View file

@ -1,7 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import ThemeManager from "../../utils/ThemeManager";
import WebViewScreen from "../../components/WebViewScreen"; import WebViewScreen from "../../components/WebViewScreen";
type Props = { type Props = {

View file

@ -1,7 +1,6 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import ThemeManager from "../../utils/ThemeManager";
import WebViewScreen from "../../components/WebViewScreen"; import WebViewScreen from "../../components/WebViewScreen";
type Props = { type Props = {