This repository has been archived by the owner on Oct 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
88 lines (78 loc) · 2.44 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**
* Main app root.
*/
import React, { Component } from 'react';
import {Provider} from 'mobx-react';
import { Button, Text, View } from 'react-native';
import { Root } from 'native-base';
import { createStackNavigator, createAppContainer } from 'react-navigation';
import { HomeScreen } from './src/home/HomeScreen';
import { StartScreen } from './src/start/StartScreen';
import { StartUnlistedScreen } from './src/start/StartUnlistedScreen';
import { RecordScreen } from './src/record/RecordScreen';
import { ReviewScreen } from './src/review/ReviewScreen';
import { SettingsScreen } from './src/settings/SettingsScreen';
import { ViewMatchScreen } from './src/view_match/ViewMatchScreen';
import { MatchHistory, MatchList } from './src/store';
import { PermissionsAndroid } from 'react-native';
const AppNavigator = createStackNavigator({
Home: HomeScreen,
Start: StartScreen,
StartUnlisted: StartUnlistedScreen,
Record: RecordScreen,
Review: ReviewScreen,
Settings: SettingsScreen,
ViewMatch: ViewMatchScreen,
},
{
initialRouteName: "Home"
});
const AppContainer = createAppContainer(AppNavigator);
type Stores = {
matchList?: MatchList
}
// We need the external storage permission so we can read/write match
// data from the SD card.
async function requestFilePermission() {
try {
const granted = await PermissionsAndroid.request(
PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
{
title: 'External storage permission',
message:
'ScoutingApp needs to access external storage' +
'to save and read data.',
buttonPositive: 'ok, thanks'
},
);
if (granted === PermissionsAndroid.RESULTS.GRANTED) {
console.log('External storage granted');
} else {
console.log('External permission denied');
}
} catch (err) {
console.warn(err);
}
}
export default class App extends React.Component {
stores: Stores = {};
matchList: MatchList;
matchHistory: MatchHistory;
constructor(props: any) {
super(props);
this.matchList = new MatchList();
this.matchHistory = new MatchHistory();
}
async componentDidMount() {
await requestFilePermission();
this.matchList.loadData();
this.matchHistory.loadMatchHistory();
};
render() {
return (<Root>
<Provider {...{matchList: this.matchList, matchHistory: this.matchHistory}}>
<AppContainer persistenceKey={"NavigationState"} />
</Provider>
</Root>);
}
}