-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
151 lines (126 loc) · 4.31 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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import React, {Component} from 'react';
import { createStackNavigator, createAppContainer } from "react-navigation";
import { GoogleAnalyticsTracker } from "react-native-google-analytics-bridge";
import { Button, Text, View , ImageBackground } from 'react-native';
const tracker1 = new GoogleAnalyticsTracker("UA-8146561-2");
class HomeOne extends React.Component {
static navigationOptions = {
title: 'R-T-A Screen-One',
};
_triggerGA(){
tracker1.trackEvent("React-Test-App-Button-Click1","Click");
alert("Your event has been recorded to GA");
}
_triggerFA(){
alert('Coming soon!');
}
render(){
tracker1.trackScreenView("React-Test-App-Screen-One");
return(
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
}}>
<View style={{height: 180, marginTop: 5, paddingTop: 30, paddingLeft: 10, paddingRight: 10, backgroundColor: 'white'}}>
<ImageBackground style={{ width: '100%', height: '100%'}} source={require('./logo.png')} />
</View>
<View style={{height: 50, marginTop: 5, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={this._triggerGA}
title="GA Event Trigger"
/>
</View>
<View style={{height: 50, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={this._triggerFA}
title="Firebase Event Trigger"
/>
</View>
<View style={{height: 70, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white', flexDirection: 'row', justifyContent: 'space-around'}}>
<Button
onPress={() => this.props.navigation.navigate('Detail')}
title="Screeen 2"
/>
<Button
onPress={() => this.props.navigation.navigate('Detail2')}
title="Screeen 3"
/>
</View>
</View>
);
}
}
class DetailsScreen extends React.Component {
static navigationOptions = {
title: 'R-T-A Screen-Two',
};
render() {
tracker1.trackScreenView("React-Test-App-Screen-Two");
return (
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
}}>
<View style={{height: 180, marginTop: 5, paddingTop: 30, paddingLeft: 10, paddingRight: 10, backgroundColor: 'white'}}>
<ImageBackground style={{ width: '100%', height: '100%'}} source={require('./logo.png')} />
</View>
<View style={{height: 50, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={() => this.props.navigation.navigate('Home')}
title="Back Home"
/>
</View>
</View>
);
}
}
class DetailsScreen2 extends React.Component {
static navigationOptions = {
title: 'R-T-A Screen-Three',
};
render() {
tracker1.trackScreenView("React-Test-App-Screen-Three");
return (
<View style={{
flex: 1,
flexDirection: 'column',
justifyContent: 'flex-start',
alignItems: 'stretch',
}}>
<View style={{height: 180, marginTop: 5, paddingTop: 30, paddingLeft: 10, paddingRight: 10, backgroundColor: 'white'}}>
<ImageBackground style={{ width: '100%', height: '100%'}} source={require('./logo.png')} />
</View>
<View style={{height: 50, marginTop: 20, paddingTop: 30, paddingLeft: 40, paddingRight: 40, backgroundColor: 'white'}}>
<Button
onPress={() => this.props.navigation.navigate('Home')}
title="Back Home"
/>
</View>
</View>
);
}
}
const AppNavigator = createStackNavigator(
{
Home : HomeOne,
Detail : DetailsScreen,
Detail2 : DetailsScreen2
},
{
initialRouteName: "Home",
defaultNavigationOptions: {
headerStyle: {
backgroundColor: '#000000',
},
headerTintColor: '#fff',
headerTitleStyle: {
fontWeight: 'bold',
},
},
}
);
export default createAppContainer(AppNavigator);