-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
134 lines (131 loc) · 5.5 KB
/
App.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
Student ID: 20170158
Student Name: ABIODUN_AYANTAYO
________________________________
Module Title: Advanced Mobile Computing
Module Code: CMP7163
Assessment Title: Design and Implementation of a Cross-platform Mobile Application
Assessment Identifier: CWRK001
School: Computing and Digital Technology
Module Co-ordinator: Harjinder Singh
NOTE:
-The README.md file contain the project structure and point of interest,
-setup information of both server and client application.
-Introduction:
-This file is the entry point to the application, all main components are registered here.
-This application uses the Stack navigation to move between screens.
-The ui- uses nativebase ui theme to construct this elegant ui, details can be found here https://docs.nativebase.io/
-This application uses a promise based HTTP client rest-api called axios to transfer data from the backend.
-The axios baseURL control can found in the ./assets/js/utils/index.js.
-The axios instance for all http request can be found at ./assets/js/utils/axios.js.
-All http request made in this application was called from ./assets/js/action/actions.
-This application uses the async-storage to store local files.
-And all state data is managed by flux state manager and stored in the ./assets/js/action/store
-The first page loaded is the StartScreen, more information about the initialisation of the
application can be found there.
Engage AI:
Process of activating AI:
-long press the microphone button at the footer and the En ui will appear at the top
-press/tap to enable listening...
-say: hello and get a reply
features
1). Engage handles page navigation to by saying any thing relating to any page.
2). Engage can search for articles/ like the search input
3). Can answer any question regarding a page.
*/
import 'react-native-gesture-handler';
import React, {Component} from 'react';
import getTheme from './native-base-theme/components';
import material from './native-base-theme/variables/material';
import {Container, Root, StyleProvider} from 'native-base';
import {DeviceEventEmitter} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import {createStackNavigator} from '@react-navigation/stack';
//navigationRef enable me to create a a simple navigation in smaller component
import {navigationRef} from './RootNavigation';
// import {Text, View} from 'react-native';
//layout
import HeaderLayout from './components/layout/HeaderLayout';
import FooterLayout from './components/layout/FooterLayout';
//below are the screens
import StartScreen from './pages/StartScreen';
import HomeScreen from './pages/HomeScreen';
import AccountScreen from './pages/AccountScreen';
import ArticleScreen from './pages/ArticleScreen';
import FollowScreen from './pages/FollowScreen';
import ProfileScreen from './pages/ProfileScreen';
import NewScreen from './pages/NewScreen';
import NoticeScreen from './pages/NoticeScreen';
import SearchListComp from './components/SearchListComp';
//importing the navigation manager
const Stack = createStackNavigator();
class App extends Component {
//function to trigger opening and closing of the search component
is_search_empty(bool) {
console.log('is_search_empty', bool);
this.setState({is_search_empty: bool});
}
//function to trigger app state: this controls when the app goes to the home page
app_ready(bool) {
this.setState({isReady: bool});
}
//initial state false for both stages
constructor() {
super();
this.state = {
is_search_empty: false,
isReady: false,
};
this.is_search_empty = this.is_search_empty.bind(this);
this.app_ready = this.app_ready.bind(this);
}
// the 2 eventEmitter listens to the is_ready and is_search_empty data and
// update using the above function accordingly
componentDidMount() {
DeviceEventEmitter.addListener('event.ready', this.app_ready);
DeviceEventEmitter.addListener(
'event.is_search_empty',
this.is_search_empty,
);
}
// removes 2 eventEmitter to prevent data leak
componentWillUnmount() {
DeviceEventEmitter.removeListener('event.ready', this.app_ready);
DeviceEventEmitter.removeListener(
'event.is_search_empty',
this.is_search_empty,
);
}
render() {
//render state
let {isReady, is_search_empty} = this.state;
return (
<Root>
<StyleProvider style={getTheme(material)}>
<Container>
{/*Navigation Manager*/}
<NavigationContainer ref={navigationRef}>
{/*show header on isReady*/}
{isReady && <HeaderLayout />}
<Stack.Navigator headerMode="none" initialRouteName="Start">
<Stack.Screen name="Start" component={StartScreen} />
<Stack.Screen name="Account" component={AccountScreen} />
<Stack.Screen name="Profile" component={ProfileScreen} />
<Stack.Screen name="New" component={NewScreen} />
<Stack.Screen name="Home" component={HomeScreen} />
<Stack.Screen name="Follow" component={FollowScreen} />
<Stack.Screen name="Notice" component={NoticeScreen} />
<Stack.Screen name="Article" component={ArticleScreen} />
</Stack.Navigator>
{/*show footer on isReady*/}
{isReady && <FooterLayout />}
{/*show search component is_search_empty is true*/}
{is_search_empty && <SearchListComp />}
</NavigationContainer>
</Container>
</StyleProvider>
</Root>
);
}
}
export default App;