// @flow import * as React from 'react'; import { Body, Card, CardItem, Container, Content, H1, H3, Left, List, ListItem, Right, Text, Form, Item, Label, Input, Button } 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 AsyncStorageManager from "../utils/AsyncStorageManager"; import NotificationsManager from "../utils/NotificationsManager"; import Modalize from "react-native-modalize"; type Props = { navigation: Object, }; type State = { modalCurrentDisplayItem: Object, currentPreferences: Object, } /** * Class defining the Debug screen. This screen allows the user to get detailed information on the app/device. */ export default class DebugScreen extends React.Component { 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'} ] ); } async forceExpoTokenUpdate() { await NotificationsManager.forceExpoTokenUpdate(); this.alertCurrentExpoToken(); } static getGeneralItem(onPressCallback: Function, icon: ?string, title: string, subtitle: string) { return ( {icon !== undefined ? : } {title} {subtitle} ); } showEditModal(item: Object) { this.setState({ modalCurrentDisplayItem: item }); if (this.modalRef.current) { this.modalRef.current.open(); } } getModalContent() { return (

{this.state.modalCurrentDisplayItem.key}

Default: {this.state.modalCurrentDisplayItem.default}

Current: {this.state.modalCurrentDisplayItem.current}

this.modalInputValue = text}/>
); } saveNewPrefs(key: string, value: string) { this.setState((prevState) => { let currentPreferences = {...prevState.currentPreferences}; currentPreferences[key].current = value; return {currentPreferences}; }); AsyncStorageManager.getInstance().savePref(key, value); } render() { const nav = this.props.navigation; return ( {this.getModalContent()} Notifications {DebugScreen.getGeneralItem(() => this.alertCurrentExpoToken(), 'bell', 'Get current Expo Token', '')} {DebugScreen.getGeneralItem(() => this.forceExpoTokenUpdate(), 'bell-ring', 'Force Expo token update', '')} Preferences {Object.values(this.state.currentPreferences).map((object) => {DebugScreen.getGeneralItem(() => this.showEditModal(object), undefined, object.key, 'Click to edit')} )} ); } }