-
Notifications
You must be signed in to change notification settings - Fork 5
/
LeagueScannerScreen.js
47 lines (42 loc) · 1.28 KB
/
LeagueScannerScreen.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
import React from "react";
import { StyleSheet, ActivityIndicator } from "react-native";
import * as Amplitude from 'expo-analytics-amplitude';
import AddLeagueIdMutation from "../graphql/AddLeagueIdMutation";
import LeagueScanner from "../base/LeagueScanner";
import { ModalBackground } from "../elements";
const styles = StyleSheet.create({
header: {
backgroundColor: "#fff",
borderBottomWidth: 0,
elevation: 0
}
});
class LeagueScannerScreen extends React.Component {
static navigationOptions = {
title: "Scan League QR-Code",
headerStyle: styles.header
};
render() {
return (
<AddLeagueIdMutation>
{(addLeagueId, { loading }) => {
const wrappedAddLeagueId = async leagueId => {
await addLeagueId({ leagueId });
Amplitude.logEventWithProperties("AddLeagueFromQRCode", {
leagueId
});
this.props.navigation.goBack();
};
let content;
if (loading) {
content = <ActivityIndicator />;
} else {
content = <LeagueScanner addLeagueId={wrappedAddLeagueId} />;
}
return <ModalBackground>{content}</ModalBackground>;
}}
</AddLeagueIdMutation>
);
}
}
export default LeagueScannerScreen;