Optimised imported and cleaned code
This commit is contained in:
parent
b62ad1fd4a
commit
c478a117b5
28 changed files with 169 additions and 256 deletions
|
@ -5,7 +5,7 @@ import {Container} from "native-base";
|
|||
import CustomHeader from "./CustomHeader";
|
||||
import CustomSideMenu from "./CustomSideMenu";
|
||||
import CustomMaterialIcon from "./CustomMaterialIcon";
|
||||
import {Platform, View, StatusBar} from "react-native";
|
||||
import {Platform, StatusBar, View} from "react-native";
|
||||
import ThemeManager from "../utils/ThemeManager";
|
||||
import Touchable from "react-native-platform-touchable";
|
||||
import {ScreenOrientation} from "expo";
|
||||
|
@ -32,9 +32,6 @@ type State = {
|
|||
|
||||
export default class BaseContainer extends React.Component<Props, State> {
|
||||
|
||||
willBlurSubscription: function;
|
||||
willFocusSubscription: function;
|
||||
|
||||
static defaultProps = {
|
||||
headerRightButton: <View/>,
|
||||
hasTabs: false,
|
||||
|
@ -43,8 +40,8 @@ export default class BaseContainer extends React.Component<Props, State> {
|
|||
enableRotation: false,
|
||||
hideHeaderOnLandscape: false,
|
||||
};
|
||||
|
||||
|
||||
willBlurSubscription: function;
|
||||
willFocusSubscription: function;
|
||||
state = {
|
||||
isOpen: false,
|
||||
isHeaderVisible: true,
|
||||
|
@ -66,7 +63,7 @@ export default class BaseContainer extends React.Component<Props, State> {
|
|||
componentDidMount() {
|
||||
this.willFocusSubscription = this.props.navigation.addListener(
|
||||
'willFocus',
|
||||
payload => {
|
||||
() => {
|
||||
if (this.props.enableRotation) {
|
||||
ScreenOrientation.unlockAsync();
|
||||
ScreenOrientation.addOrientationChangeListener((OrientationChangeEvent) => {
|
||||
|
@ -87,7 +84,7 @@ export default class BaseContainer extends React.Component<Props, State> {
|
|||
});
|
||||
this.willBlurSubscription = this.props.navigation.addListener(
|
||||
'willBlur',
|
||||
payload => {
|
||||
() => {
|
||||
if (this.props.enableRotation)
|
||||
ScreenOrientation.lockAsync(ScreenOrientation.Orientation.PORTRAIT);
|
||||
this.setState({isOpen: false});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
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 {getStatusBarHeight} from "react-native-status-bar-height";
|
||||
import Touchable from 'react-native-platform-touchable';
|
||||
|
|
|
@ -35,13 +35,6 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
|||
lastRefresh: Date;
|
||||
|
||||
minTimeBetweenRefresh = 60;
|
||||
|
||||
constructor(fetchUrl: string, refreshTime: number) {
|
||||
super();
|
||||
this.webDataManager = new WebDataManager(fetchUrl);
|
||||
this.refreshTime = refreshTime;
|
||||
}
|
||||
|
||||
state = {
|
||||
refreshing: false,
|
||||
firstLoading: true,
|
||||
|
@ -49,6 +42,12 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
|||
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
|
||||
* @return {string}
|
||||
|
@ -76,13 +75,13 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
|||
componentDidMount() {
|
||||
this.willFocusSubscription = this.props.navigation.addListener(
|
||||
'willFocus',
|
||||
payload => {
|
||||
() => {
|
||||
this.onScreenFocus();
|
||||
}
|
||||
);
|
||||
this.willBlurSubscription = this.props.navigation.addListener(
|
||||
'willBlur',
|
||||
payload => {
|
||||
() => {
|
||||
this.onScreenBlur();
|
||||
}
|
||||
);
|
||||
|
@ -136,7 +135,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
|||
});
|
||||
this.lastRefresh = new Date();
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch(() => {
|
||||
this.setState({
|
||||
fetchedData: {},
|
||||
refreshing: false,
|
||||
|
|
|
@ -2,12 +2,11 @@
|
|||
|
||||
import * as React from 'react';
|
||||
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 CustomMaterialIcon from '../components/CustomMaterialIcon';
|
||||
import ThemeManager from "../utils/ThemeManager";
|
||||
|
||||
const deviceHeight = Dimensions.get("window").height;
|
||||
const deviceWidth = Dimensions.get("window").width;
|
||||
|
||||
const drawerCover = require("../assets/drawer-cover.png");
|
||||
|
|
|
@ -2,13 +2,12 @@
|
|||
|
||||
import * as React from 'react';
|
||||
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 Touchable from "react-native-platform-touchable";
|
||||
import CustomMaterialIcon from "../components/CustomMaterialIcon";
|
||||
import ThemeManager from "../utils/ThemeManager";
|
||||
import BaseContainer from "../components/BaseContainer";
|
||||
import {NavigationActions} from 'react-navigation';
|
||||
|
||||
type Props = {
|
||||
navigation: Object,
|
||||
|
@ -153,7 +152,7 @@ export default class WebViewScreen extends React.Component<Props> {
|
|||
elevation: 0, // Fix for android shadow
|
||||
}}
|
||||
locked={true}
|
||||
style = {{
|
||||
style={{
|
||||
backgroundColor: Platform.OS === 'ios' ?
|
||||
ThemeManager.getCurrentThemeVariables().tabDefaultBg :
|
||||
ThemeManager.getCurrentThemeVariables().brandPrimary
|
||||
|
|
|
@ -52,4 +52,5 @@ function createAppContainerWithInitialRoute(initialRoute: string) {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
export {createAppContainerWithInitialRoute};
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
);
|
||||
|
|
@ -8,7 +8,6 @@ import ProximoMainScreen from '../screens/Proximo/ProximoMainScreen';
|
|||
import PlanexScreen from '../screens/Websites/PlanexScreen';
|
||||
import CustomMaterialIcon from "../components/CustomMaterialIcon";
|
||||
import ThemeManager from "../utils/ThemeManager";
|
||||
import AsyncStorageManager from "../utils/AsyncStorageManager";
|
||||
|
||||
const TAB_ICONS = {
|
||||
Home: 'triangle',
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
"eject": "expo eject"
|
||||
},
|
||||
"dependencies": {
|
||||
"@expo/vector-icons": "^10.0.0",
|
||||
"@react-native-community/status-bar": "^1.0.3",
|
||||
"expo": "^36.0.0",
|
||||
"expo-font": "~8.0.0",
|
||||
"expo-linear-gradient": "~8.0.0",
|
||||
|
@ -27,8 +25,10 @@
|
|||
"react-native-gesture-handler": "~1.5.0",
|
||||
"react-native-material-menu": "^0.6.7",
|
||||
"react-native-modalize": "^1.3.6",
|
||||
"react-native-paper": "^3.5.1",
|
||||
"react-native-platform-touchable": "^1.1.1",
|
||||
"react-native-render-html": "^4.1.2",
|
||||
"react-native-screens": "2.0.0-alpha.12",
|
||||
"react-native-side-menu": "^1.1.3",
|
||||
"react-native-status-bar-height": "^2.3.1",
|
||||
"react-native-webview": "7.4.3",
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
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 {FlatList} from "react-native";
|
||||
import i18n from "i18n-js";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import * as React from 'react';
|
||||
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 i18n from "i18n-js";
|
||||
import appJson from '../../app';
|
||||
|
@ -70,12 +70,6 @@ export default class AboutScreen extends React.Component<Props, State> {
|
|||
state = {
|
||||
isDebugUnlocked: AsyncStorageManager.getInstance().preferences.debugUnlocked.current === '1'
|
||||
};
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.modalRef = React.createRef();
|
||||
}
|
||||
|
||||
/**
|
||||
* Data to be displayed in the app card
|
||||
*/
|
||||
|
@ -118,7 +112,6 @@ export default class AboutScreen extends React.Component<Props, State> {
|
|||
showOnlyDebug: true
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Data to be displayed in the author card
|
||||
*/
|
||||
|
@ -142,7 +135,6 @@ export default class AboutScreen extends React.Component<Props, State> {
|
|||
showChevron: true
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Data to be displayed in the additional developer card
|
||||
*/
|
||||
|
@ -166,7 +158,6 @@ export default class AboutScreen extends React.Component<Props, State> {
|
|||
showChevron: true
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Data to be displayed in the technologies card
|
||||
*/
|
||||
|
@ -184,7 +175,6 @@ export default class AboutScreen extends React.Component<Props, State> {
|
|||
showChevron: true
|
||||
},
|
||||
];
|
||||
|
||||
dataOrder: Array<Object> = [
|
||||
{
|
||||
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() {
|
||||
return (
|
||||
<Card>
|
||||
|
|
|
@ -3,29 +3,28 @@
|
|||
import * as React from 'react';
|
||||
import {
|
||||
Body,
|
||||
Button,
|
||||
Card,
|
||||
CardItem,
|
||||
Container,
|
||||
Content,
|
||||
Form,
|
||||
H1,
|
||||
H3,
|
||||
Input,
|
||||
Item,
|
||||
Label,
|
||||
Left,
|
||||
List,
|
||||
ListItem,
|
||||
Right,
|
||||
Text,
|
||||
Form,
|
||||
Item,
|
||||
Label,
|
||||
Input,
|
||||
Button
|
||||
Text
|
||||
} from "native-base";
|
||||
import CustomHeader from "../components/CustomHeader";
|
||||
import ThemeManager from '../utils/ThemeManager';
|
||||
import i18n from "i18n-js";
|
||||
import CustomMaterialIcon from "../components/CustomMaterialIcon";
|
||||
import Touchable from "react-native-platform-touchable";
|
||||
import {Alert, View, Clipboard, Image} from "react-native";
|
||||
import {Alert, Clipboard, View} from "react-native";
|
||||
import AsyncStorageManager from "../utils/AsyncStorageManager";
|
||||
import NotificationsManager from "../utils/NotificationsManager";
|
||||
import {Modalize} from "react-native-modalize";
|
||||
|
@ -46,36 +45,16 @@ export default class DebugScreen extends React.Component<Props, State> {
|
|||
|
||||
modalRef: { current: null | Modalize };
|
||||
modalInputValue = '';
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.modalRef = React.createRef();
|
||||
}
|
||||
|
||||
state = {
|
||||
modalCurrentDisplayItem: {},
|
||||
currentPreferences: JSON.parse(JSON.stringify(AsyncStorageManager.getInstance().preferences))
|
||||
};
|
||||
|
||||
alertCurrentExpoToken() {
|
||||
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
|
||||
console.log(token);
|
||||
Alert.alert(
|
||||
'Expo Token',
|
||||
token,
|
||||
[
|
||||
{text: 'Copy', onPress: () => Clipboard.setString(token)},
|
||||
{text: 'OK'}
|
||||
]
|
||||
);
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.modalRef = React.createRef();
|
||||
}
|
||||
|
||||
async forceExpoTokenUpdate() {
|
||||
await NotificationsManager.forceExpoTokenUpdate();
|
||||
this.alertCurrentExpoToken();
|
||||
}
|
||||
|
||||
|
||||
static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) {
|
||||
return (
|
||||
<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) {
|
||||
this.setState({
|
||||
modalCurrentDisplayItem: item
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import * as React from 'react';
|
||||
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 CustomMaterialIcon from '../components/CustomMaterialIcon';
|
||||
import FetchedDataSectionList from "../components/FetchedDataSectionList";
|
||||
|
@ -42,6 +42,16 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
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() {
|
||||
return i18n.t("screens.home");
|
||||
}
|
||||
|
@ -119,17 +129,6 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
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) {
|
||||
if (title === '') {
|
||||
return <View/>;
|
||||
|
@ -294,7 +293,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
let icon = 'calendar-range';
|
||||
let color = ThemeManager.getCurrentThemeVariables().planningColor;
|
||||
let title = i18n.t('homeScreen.dashboard.todayEventsTitle');
|
||||
let subtitle = '';
|
||||
let subtitle;
|
||||
let futureEvents = this.getFutureEvents(content);
|
||||
let isAvailable = futureEvents.length > 0;
|
||||
if (isAvailable) {
|
||||
|
@ -336,7 +335,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
let proximoColor = ThemeManager.getCurrentThemeVariables().proximoColor;
|
||||
let proximoTitle = i18n.t('homeScreen.dashboard.proximoTitle');
|
||||
let isProximoAvailable = parseInt(proximoData) > 0;
|
||||
let proximoSubtitle = '';
|
||||
let proximoSubtitle;
|
||||
if (isProximoAvailable) {
|
||||
proximoSubtitle =
|
||||
<Text>
|
||||
|
@ -358,7 +357,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
let menuColor = ThemeManager.getCurrentThemeVariables().menuColor;
|
||||
let menuTitle = i18n.t('homeScreen.dashboard.menuTitle');
|
||||
let isMenuAvailable = menuData.length > 0;
|
||||
let menuSubtitle = '';
|
||||
let menuSubtitle;
|
||||
if (isMenuAvailable) {
|
||||
menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle');
|
||||
} else
|
||||
|
@ -410,39 +409,39 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
let availableWashers = proxiwashData['washers'];
|
||||
if (proxiwashIsAvailable) {
|
||||
proxiwashSubtitle =
|
||||
<Text>
|
||||
<Text style={{
|
||||
fontWeight: parseInt(proxiwashData['dryers']) > 0 ?
|
||||
'bold' :
|
||||
'normal',
|
||||
color: dryerColor
|
||||
}}>
|
||||
{availableDryers}
|
||||
</Text>
|
||||
<Text>
|
||||
<Text style={{
|
||||
fontWeight: parseInt(proxiwashData['dryers']) > 0 ?
|
||||
'bold' :
|
||||
'normal',
|
||||
color: dryerColor
|
||||
}}>
|
||||
{availableDryers}
|
||||
</Text>
|
||||
<Text>
|
||||
{
|
||||
availableDryers > 1 ?
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle1Plural') :
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle1')
|
||||
}
|
||||
</Text>
|
||||
{"\n"}
|
||||
<Text style={{
|
||||
fontWeight: parseInt(proxiwashData['washers']) > 0 ?
|
||||
'bold' :
|
||||
'normal',
|
||||
color: washerColor
|
||||
}}>
|
||||
{availableWashers}
|
||||
</Text>
|
||||
<Text>
|
||||
{
|
||||
availableWashers > 1 ?
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle2Plural') :
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle2')
|
||||
}
|
||||
</Text>
|
||||
</Text>;
|
||||
{
|
||||
availableDryers > 1 ?
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle1Plural') :
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle1')
|
||||
}
|
||||
</Text>
|
||||
{"\n"}
|
||||
<Text style={{
|
||||
fontWeight: parseInt(proxiwashData['washers']) > 0 ?
|
||||
'bold' :
|
||||
'normal',
|
||||
color: washerColor
|
||||
}}>
|
||||
{availableWashers}
|
||||
</Text>
|
||||
<Text>
|
||||
{
|
||||
availableWashers > 1 ?
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle2Plural') :
|
||||
i18n.t('homeScreen.dashboard.proxiwashSubtitle2')
|
||||
}
|
||||
</Text>
|
||||
</Text>;
|
||||
} else
|
||||
proxiwashSubtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA');
|
||||
let proxiwashClickAction = () => this.props.navigation.navigate('Proxiwash');
|
||||
|
@ -497,10 +496,8 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
|
||||
|
||||
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={{
|
||||
flex: 0,
|
||||
marginLeft: 10,
|
||||
|
@ -555,8 +552,6 @@ export default class HomeScreen extends FetchedDataSectionList {
|
|||
</Left>
|
||||
</CardItem>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import {BackHandler} from 'react-native';
|
||||
import {Content, H1, H3, Text, Button} from 'native-base';
|
||||
import {BackHandler, Image, View} from 'react-native';
|
||||
import {Button, Content, H1, H3, Text} from 'native-base';
|
||||
import i18n from "i18n-js";
|
||||
import {View, Image} from "react-native";
|
||||
import ThemeManager from "../utils/ThemeManager";
|
||||
import {Linking} from "expo";
|
||||
import BaseContainer from "../components/BaseContainer";
|
||||
|
@ -61,6 +60,12 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
|||
|
||||
didFocusSubscription: Function;
|
||||
willBlurSubscription: Function;
|
||||
state = {
|
||||
modalCurrentDisplayItem: {},
|
||||
refreshing: false,
|
||||
agendaItems: {},
|
||||
calendarShowing: false,
|
||||
};
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
|
@ -68,7 +73,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
|||
this.webDataManager = new WebDataManager(FETCH_URL);
|
||||
this.didFocusSubscription = props.navigation.addListener(
|
||||
'didFocus',
|
||||
payload =>
|
||||
() =>
|
||||
BackHandler.addEventListener(
|
||||
'hardwareBackPress',
|
||||
this.onBackButtonPressAndroid
|
||||
|
@ -83,7 +88,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
|||
this._onRefresh();
|
||||
this.willBlurSubscription = this.props.navigation.addListener(
|
||||
'willBlur',
|
||||
payload =>
|
||||
() =>
|
||||
BackHandler.removeEventListener(
|
||||
'hardwareBackPress',
|
||||
this.onBackButtonPressAndroid
|
||||
|
@ -105,13 +110,6 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
|||
this.willBlurSubscription && this.willBlurSubscription.remove();
|
||||
}
|
||||
|
||||
state = {
|
||||
modalCurrentDisplayItem: {},
|
||||
refreshing: false,
|
||||
agendaItems: {},
|
||||
calendarShowing: false,
|
||||
};
|
||||
|
||||
getCurrentDate() {
|
||||
let today = new Date();
|
||||
return this.getFormattedDate(today);
|
||||
|
@ -351,7 +349,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
|||
|
||||
getFormattedTime(event: Object) {
|
||||
if (this.getEventEndTime(event) !== "")
|
||||
return this.getEventStartTime(event) + " - " + this.getEventEndTime(event)
|
||||
return this.getEventStartTime(event) + " - " + this.getEventEndTime(event);
|
||||
else
|
||||
return this.getEventStartTime(event);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import * as React from 'react';
|
||||
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 i18n from "i18n-js";
|
||||
import CustomMaterialIcon from "../../components/CustomMaterialIcon";
|
||||
|
@ -11,14 +11,6 @@ type Props = {
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
// @flow
|
||||
|
||||
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 {FlatList, Platform, View, Image} from "react-native";
|
||||
import {FlatList, Image, Platform, View} from "react-native";
|
||||
import Touchable from 'react-native-platform-touchable';
|
||||
import Menu, {MenuItem} from 'react-native-material-menu';
|
||||
import i18n from "i18n-js";
|
||||
|
@ -62,13 +62,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
|||
originalData: Array<Object>;
|
||||
navData = this.props.navigation.getParam('data', []);
|
||||
shouldFocusSearchBar = this.props.navigation.getParam('shouldFocusSearchBar', false);
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
this.modalRef = React.createRef();
|
||||
this.originalData = this.navData['data'];
|
||||
}
|
||||
|
||||
state = {
|
||||
currentlyDisplayedData: this.navData['data'].sort(sortPrice),
|
||||
currentSortMode: sortMode.price,
|
||||
|
@ -77,9 +70,14 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
|||
sortNameIcon: '',
|
||||
modalCurrentDisplayItem: {},
|
||||
};
|
||||
|
||||
_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
|
||||
*
|
||||
|
@ -132,9 +130,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
|||
}
|
||||
break;
|
||||
}
|
||||
this.setState({
|
||||
navData: data,
|
||||
});
|
||||
this.setupSortIcons(mode, isReverse);
|
||||
this._menu.hide();
|
||||
}
|
||||
|
@ -297,7 +292,6 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
|||
|
||||
render() {
|
||||
const nav = this.props.navigation;
|
||||
const navType = nav.getParam('type', '{name: "Error"}');
|
||||
return (
|
||||
<Container>
|
||||
<Modalize ref={this.modalRef}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import * as React from 'react';
|
||||
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 CustomMaterialIcon from "../../components/CustomMaterialIcon";
|
||||
import FetchedDataSectionList from "../../components/FetchedDataSectionList";
|
||||
|
@ -22,6 +22,10 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
|
|||
super(DATA_URL, 0);
|
||||
}
|
||||
|
||||
static sortFinalData(a: Object, b: Object) {
|
||||
return a.type.id - b.type.id;
|
||||
}
|
||||
|
||||
getHeaderTranslation() {
|
||||
return i18n.t("screens.proximo");
|
||||
}
|
||||
|
@ -96,10 +100,6 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
|
|||
return availableArticles;
|
||||
}
|
||||
|
||||
static sortFinalData(a: Object, b: Object) {
|
||||
return a.type.id - b.type.id;
|
||||
}
|
||||
|
||||
getRightButton() {
|
||||
let searchScreenData = {
|
||||
shouldFocusSearchBar: true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
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 CustomHeader from "../../components/CustomHeader";
|
||||
import i18n from "i18n-js";
|
||||
|
@ -12,14 +12,6 @@ type Props = {
|
|||
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.
|
||||
*/
|
||||
|
|
|
@ -89,7 +89,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
|
|||
this.setState({machinesWatched: fetchedList})
|
||||
});
|
||||
// Get updated watchlist after received notification
|
||||
Expo.Notifications.addListener((notification) => {
|
||||
Expo.Notifications.addListener(() => {
|
||||
NotificationsManager.getMachineNotificationWatchlist((fetchedList) => {
|
||||
this.setState({machinesWatched: fetchedList})
|
||||
});
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
import * as React from 'react';
|
||||
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 i18n from "i18n-js";
|
||||
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";
|
||||
|
||||
|
@ -64,7 +63,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
|
|||
return true;
|
||||
}
|
||||
|
||||
hasSideMenu() : boolean {
|
||||
hasSideMenu(): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -150,7 +149,7 @@ export default class SelfMenuScreen extends FetchedDataSectionList {
|
|||
flexDirection: 'column',
|
||||
paddingTop: 0,
|
||||
}}>
|
||||
{item.dishes.map((object, i) =>
|
||||
{item.dishes.map((object) =>
|
||||
<View>
|
||||
{object.name !== "" ?
|
||||
<Text style={{
|
||||
|
|
|
@ -21,8 +21,6 @@ import i18n from "i18n-js";
|
|||
import {NavigationActions, StackActions} from "react-navigation";
|
||||
import CustomMaterialIcon from "../components/CustomMaterialIcon";
|
||||
import AsyncStorageManager from "../utils/AsyncStorageManager";
|
||||
import Touchable from "react-native-platform-touchable";
|
||||
import {Platform} from "react-native";
|
||||
import NotificationsManager from "../utils/NotificationsManager";
|
||||
|
||||
type Props = {
|
||||
|
@ -45,6 +43,39 @@ export default class SettingsScreen extends React.Component<Props, State> {
|
|||
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
|
||||
*
|
||||
|
@ -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() {
|
||||
const nav = this.props.navigation;
|
||||
return (
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import ThemeManager from "../../utils/ThemeManager";
|
||||
import WebViewScreen from "../../components/WebViewScreen";
|
||||
|
||||
type Props = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import ThemeManager from "../../utils/ThemeManager";
|
||||
import WebViewScreen from "../../components/WebViewScreen";
|
||||
import i18n from "i18n-js";
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import ThemeManager from "../../utils/ThemeManager";
|
||||
import WebViewScreen from "../../components/WebViewScreen";
|
||||
|
||||
type Props = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import ThemeManager from "../../utils/ThemeManager";
|
||||
import WebViewScreen from "../../components/WebViewScreen";
|
||||
import i18n from "i18n-js";
|
||||
|
||||
|
@ -50,7 +49,7 @@ export default class EntScreen extends React.Component<Props> {
|
|||
'let stylesheet = document.createElement(\'link\');\n' +
|
||||
'stylesheet.type = \'text/css\';\n' +
|
||||
'stylesheet.rel = \'stylesheet\';\n' +
|
||||
'stylesheet.href = \'' + CUSTOM_CSS_GENERAL +'\';\n' +
|
||||
'stylesheet.href = \'' + CUSTOM_CSS_GENERAL + '\';\n' +
|
||||
'let mobileSpec = document.createElement(\'meta\');\n' +
|
||||
'mobileSpec.name = \'viewport\';\n' +
|
||||
'mobileSpec.content = \'width=device-width, initial-scale=1.0\';\n' +
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import * as React from 'react';
|
||||
import ThemeManager from "../../utils/ThemeManager";
|
||||
import WebViewScreen from "../../components/WebViewScreen";
|
||||
import i18n from "i18n-js";
|
||||
|
||||
type Props = {
|
||||
navigation: Object,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import ThemeManager from "../../utils/ThemeManager";
|
||||
import WebViewScreen from "../../components/WebViewScreen";
|
||||
|
||||
type Props = {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
// @flow
|
||||
|
||||
import * as React from 'react';
|
||||
import ThemeManager from "../../utils/ThemeManager";
|
||||
import WebViewScreen from "../../components/WebViewScreen";
|
||||
|
||||
type Props = {
|
||||
|
|
Loading…
Reference in a new issue