App.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834
  1. /**
  2. * Copyright (c) UNA, Inc - https://una.io
  3. * MIT License - https://opensource.org/licenses/MIT
  4. */
  5. import React, { Component } from 'react';
  6. import OneSignal from 'react-native-onesignal';
  7. import SplashScreen from 'react-native-splash-screen';
  8. import { WebView } from 'react-native-webview';
  9. import {
  10. Platform,
  11. StyleSheet,
  12. StyleProvider,
  13. Image,
  14. Linking,
  15. BackHandler,
  16. ActivityIndicator,
  17. Dimensions,
  18. Alert,
  19. Appearance,
  20. } from 'react-native';
  21. import {
  22. View,
  23. Container, Content,
  24. Header, Title, Left, Body, Right, Item, Input,
  25. Footer, FooterTab, Badge,
  26. Text, Icon, Button,
  27. Drawer,
  28. } from 'native-base';
  29. import RNIap, {
  30. purchaseErrorListener,
  31. purchaseUpdatedListener,
  32. type ProductPurchase,
  33. type PurchaseError
  34. } from 'react-native-iap';
  35. import JitsiMeet, { JitsiMeetView } from 'react-native-jitsi-meet';
  36. import VideoCall from './VideoCall';
  37. import ErrorPage from './ErrorPage';
  38. import { themeDark, themeLight, useTheme } from './Theme';
  39. import { version } from './package.json';
  40. type Props = {};
  41. const BASE_URL = 'https://una.io/'; // site URL
  42. const MIX_LIGHT = '12'; // template styles mix for light mode
  43. const MIX_DARK = '13'; // template styles mix for dark mode
  44. const TEMPLATE = 'protean'; // template name
  45. const TITLE = 'UNA.IO'; // app title
  46. const ONESIGNALAPPID = ''; // you can obtain one from https://onesignal.com/
  47. const PAYMENTS_CALLBACK = ''; // empty string means payment functionality is disabled
  48. export default class App extends Component<Props> {
  49. loading = false;
  50. videoCallAudio = false;
  51. purchaseUpdateSubscription = null;
  52. purchaseErrorSubscription = null;
  53. products = {};
  54. constructor(props) {
  55. super(props);
  56. var colorScheme = Appearance.getColorScheme();
  57. this.state = {
  58. url: `${BASE_URL}?skin=${TEMPLATE}&mix=${'dark' === colorScheme ? MIX_DARK : MIX_LIGHT}`,
  59. status: 'No Page Loaded',
  60. backButtonEnabled: false,
  61. forwardButtonEnabled: false,
  62. loading: this.loading,
  63. data: {},
  64. searchbar: false,
  65. key: 1,
  66. videoCall: 0,
  67. videoCallUri: false,
  68. };
  69. this.onBack.bind(this);
  70. this.onMainMenu.bind(this);
  71. this.onConferenceTerminated = this.onConferenceTerminated.bind(this);
  72. this.onConferenceJoined = this.onConferenceJoined.bind(this);
  73. this.onConferenceWillJoin = this.onConferenceWillJoin.bind(this);
  74. this.onVideoCallStart = this.onVideoCallStart.bind(this);
  75. }
  76. async onRequestPurchase (sku: string) {
  77. if ('ios' === Platform.OS)
  78. RNIap.clearTransactionIOS();
  79. try {
  80. await RNIap.requestPurchase(sku, false);
  81. } catch (err) {
  82. console.warn(err.code, err.message);
  83. Alert.alert(err.message);
  84. }
  85. }
  86. async onRequestSubscription (sku: string) {
  87. if ('ios' === Platform.OS)
  88. RNIap.clearTransactionIOS();
  89. try {
  90. await RNIap.requestSubscription(sku);
  91. } catch (err) {
  92. console.warn(err.code, err.message);
  93. Alert.alert(err.message);
  94. }
  95. }
  96. onConferenceTerminated(e) {
  97. this.endVideoCall();
  98. this.injectJavaScript("bx_mobile_apps_video_terminated(" + JSON.stringify(e.nativeEvent) + ")");
  99. }
  100. onConferenceJoined(e) {
  101. this.injectJavaScript("bx_mobile_apps_video_joined(" + JSON.stringify(e.nativeEvent) + ")");
  102. }
  103. onConferenceWillJoin(e) {
  104. this.injectJavaScript("bx_mobile_apps_video_will_join(" + JSON.stringify(e.nativeEvent) + ")");
  105. }
  106. endVideoCall() {
  107. this.videoCallAudio = false;
  108. this.setState ({
  109. videoCall: 0,
  110. videoCallUri: false,
  111. });
  112. JitsiMeet.endCall();
  113. }
  114. onVideoCallStart(sUri, bAudioOnly = false) {
  115. if (!this.state.videoCall) {
  116. this.videoCallAudio = bAudioOnly;
  117. this.setState ({
  118. videoCall: 1,
  119. videoCallUri: sUri,
  120. });
  121. }
  122. }
  123. onVideoCallToggle() {
  124. if (this.state.videoCall) {
  125. this.endVideoCall();
  126. }
  127. else {
  128. this.onVideoCallStart('testing-egr58t32g2');
  129. }
  130. }
  131. onBack() {
  132. this.endVideoCall();
  133. if (this.state.backButtonEnabled) {
  134. if ('android' === Platform.OS)
  135. this.onWebViewLoadStart(); // show loading screen
  136. this.refs.webView1.goBack();
  137. // this.injectJavaScript("window.history.go(-1)");
  138. return true;
  139. }
  140. return false;
  141. }
  142. onMainMenu() {
  143. this.endVideoCall();
  144. if (this.state.data.loggedin)
  145. this.injectJavaScript("bx_mobile_apps_show_main_menu()");
  146. else
  147. this.drawerOpen();
  148. }
  149. onBackAndMainMenu() {
  150. if (this.state.backButtonEnabled) {
  151. return this.onBack();
  152. }
  153. else {
  154. return this.onMainMenu();
  155. }
  156. }
  157. onProfileMenu() {
  158. this.endVideoCall();
  159. this.injectJavaScript("bx_mobile_apps_show_profile_menu()");
  160. return true;
  161. }
  162. onAddMenu() {
  163. this.endVideoCall();
  164. this.injectJavaScript("bx_mobile_apps_show_add_menu()");
  165. return true;
  166. }
  167. onNotificationsMenu() {
  168. this.endVideoCall();
  169. this.injectJavaScript("bx_mobile_apps_show_notifications_menu()");
  170. return true;
  171. }
  172. onMessengerMenu() {
  173. this.endVideoCall();
  174. this.injectJavaScript("bx_mobile_apps_show_messenger_menu()");
  175. return true;
  176. }
  177. onHomeMenu() {
  178. this.endVideoCall();
  179. if (`${BASE_URL}` == this.state.url || this.state.url.startsWith(`${BASE_URL}?skin=${TEMPLATE}`) || `${BASE_URL}index.php` == this.state.url) {
  180. this.injectJavaScript("bx_mobile_apps_close_sliding_menus()");
  181. } else {
  182. var colorScheme = Appearance.getColorScheme();
  183. this.setState ({
  184. url: `${BASE_URL}?skin=${TEMPLATE}&mix=${'dark' == colorScheme ? MIX_DARK : MIX_LIGHT}`,
  185. searchbar: false,
  186. key: this.state.key + 1,
  187. });
  188. }
  189. return true;
  190. }
  191. onSearch(event) {
  192. this.onSearchCancelMenu();
  193. this.injectJavaScript(`window.location = '${BASE_URL}searchKeyword.php?keyword=${event.nativeEvent.text}';`);
  194. }
  195. onSearchCancelMenu() {
  196. this.setState ({
  197. loading: this.loading,
  198. searchbar: false,
  199. });
  200. return true;
  201. }
  202. onSearchMenu() {
  203. this.endVideoCall();
  204. this.setState ({
  205. loading: this.loading,
  206. searchbar: true,
  207. });
  208. return true;
  209. }
  210. onDrawerLoginMenu() {
  211. this.onHomeMenu();
  212. this.drawerClose();
  213. return true;
  214. }
  215. onDrawerJoinMenu() {
  216. this.injectJavaScript(`window.location = '${BASE_URL}page/create-account';`);
  217. this.drawerClose();
  218. return true;
  219. }
  220. onDrawerForgotMenu() {
  221. this.injectJavaScript(`window.location = '${BASE_URL}page/forgot-password';`);
  222. this.drawerClose();
  223. return true;
  224. }
  225. onWebViewNavigationStateChange(navState) {
  226. if (-1 != navState.url.indexOf('#') && this.state.url == navState.url.substring(0, navState.url.indexOf('#'))) {
  227. this.onWebViewLoadEnd();
  228. return;
  229. }
  230. this.setState ({
  231. url: navState.url,
  232. status: navState.title,
  233. backButtonEnabled: navState.canGoBack,
  234. forwardButtonEnabled: navState.canGoForward,
  235. searchbar: false,
  236. });
  237. }
  238. onWebViewLoadStart (syntheticEvent) {
  239. if (-1 == this.state.url.indexOf(`${BASE_URL}`)) { // loading indicator is supported on original domains only
  240. this.onWebViewLoadEnd(syntheticEvent);
  241. return;
  242. }
  243. this.loading = true;
  244. this.setState ({
  245. loading: this.loading,
  246. searchbar: false,
  247. });
  248. }
  249. onWebViewLoadEnd (syntheticEvent) {
  250. this.loading = false;
  251. this.setState ({
  252. loading: this.loading,
  253. searchbar: false,
  254. });
  255. }
  256. onWebViewRenderError () {
  257. return (
  258. <ErrorPage onReload={() => (this.reload())}></ErrorPage>
  259. );
  260. }
  261. reload() {
  262. this.refs.webView1.reload();
  263. }
  264. postMessage (data) {
  265. // posts a message to web view
  266. this.refs.webView1.postMessage(data);
  267. }
  268. injectJavaScript (script) {
  269. // executes JavaScript immediately in web view
  270. this.refs.webView1.injectJavaScript(script);
  271. }
  272. onWebViewShouldStartLoadWithRequest (event) {
  273. var aExceptionsUrls = [
  274. 'redirect_uri=', 'redirect_uri%', 'redirectUri%', // Facebook/LinkedIn Connect and other Connect apps
  275. 'signin/oauth', 'signin%2Foauth', // Google Connect
  276. '/m/oauth2', // Dolphin/UNA Connect
  277. 'api.twitter.com', // Twitter Connect
  278. ];
  279. var bExceptionUrl = aExceptionsUrls.some(e => {
  280. return -1 !== event.url.indexOf(e);
  281. });
  282. if ('about:blank' === event.url)
  283. return false;
  284. if (0 != event.url.indexOf('http') || (!bExceptionUrl && -1 == event.url.indexOf(`${BASE_URL}`) && ('android' === Platform.OS || ('click' == event.navigationType && 'ios' === Platform.OS)))) {
  285. Linking.canOpenURL(event.url).then(supported => {
  286. if (supported) {
  287. Linking.openURL(event.url);
  288. }
  289. else {
  290. console.log('Don\'t know how to open URI: ' + event.url);
  291. }
  292. return false;
  293. });
  294. return false;
  295. }
  296. if ('android' === Platform.OS)
  297. this.onWebViewLoadStart(); // show loading screen
  298. return true;
  299. }
  300. javascriptToInject () {
  301. return 'glBxNexusApp = ' + JSON.stringify({ver:version});
  302. }
  303. componentDidCatch(error, info) {
  304. SplashScreen.hide();
  305. }
  306. async componentDidMount() {
  307. Appearance.addChangeListener(({ colorScheme }) => {
  308. this.setState ({
  309. key: this.state.key + 1,
  310. });
  311. });
  312. OneSignal.setLogLevel(6, 0);
  313. OneSignal.setAppId(ONESIGNALAPPID);
  314. // OneSignal.inFocusDisplaying(0);
  315. OneSignal.promptForPushNotificationsWithUserResponse(response => {
  316. console.log("OneSignal Prompt response:", response);
  317. });
  318. OneSignal.setNotificationWillShowInForegroundHandler(notificationReceivedEvent => {
  319. console.log("OneSignal: notification will show in foreground:", notificationReceivedEvent);
  320. let notification = notificationReceivedEvent.getNotification();
  321. console.log("OneSignal notification: ", notification);
  322. const data = notification.additionalData;
  323. console.log("OneSignal additionalData: ", data);
  324. const button1 = {
  325. text: "Cancel",
  326. onPress: () => {
  327. notificationReceivedEvent.complete();
  328. },
  329. style: "cancel"
  330. };
  331. const button2 = {
  332. text: "Complete",
  333. onPress: () => {
  334. notificationReceivedEvent.complete(notification);
  335. }
  336. };
  337. Alert.alert("Complete notification?", "Test", [button1, button2], {
  338. cancelable: true
  339. });
  340. });
  341. OneSignal.setNotificationOpenedHandler(notification => {
  342. // TODO:
  343. // if ('undefined' !== typeof(openResult.notification.payload.additionalData) && 'undefined' !== typeof(openResult.notification.payload.additionalData.url) && !openResult.notification.isAppInFocus) {
  344. // this.injectJavaScript(`window.location = '${openResult.notification.payload.additionalData.url}';`);
  345. // }
  346. console.log("OneSignal: notification opened:", notification);
  347. });
  348. const deviceState = await OneSignal.getDeviceState();
  349. this.setState({
  350. isSubscribed : deviceState.isSubscribed
  351. });
  352. if (Platform.OS === 'android') {
  353. this.backHandler = BackHandler.addEventListener('hardwareBackPress', () => {
  354. if (this.state.backButtonEnabled) {
  355. this.onBack(); // works best when the goBack is async
  356. return true;
  357. }
  358. else {
  359. return false;
  360. }
  361. });
  362. }
  363. if (PAYMENTS_CALLBACK != '') {
  364. var _self = this;
  365. try {
  366. await RNIap.initConnection();
  367. const sProducts = await fetch(BASE_URL + 'modules/?r=oauth2/com/get_products_names&module=system&class=BaseServices');
  368. _self.products = await sProducts.json();
  369. await RNIap.getSubscriptions(Object.keys(_self.products));
  370. await RNIap.getProducts(Object.keys(_self.products));
  371. } catch(err) {
  372. console.warn(err);
  373. }
  374. purchaseUpdateSubscription = purchaseUpdatedListener(async (oPurchaseData: ProductPurchase) => {
  375. console.log('purchaseUpdatedListener', oPurchaseData);
  376. if ('undefined' !== typeof(oPurchaseData.transactionId) && _self.state.data.loggedin != 0) {
  377. var sProductName = 'undefined' !== typeof(oPurchaseData.productId) ? oPurchaseData.productId : null;
  378. var sTxId = 'undefined' !== typeof(oPurchaseData.transactionId) ? oPurchaseData.transactionId : '';
  379. var sTxIdOriginal = 'undefined' !== typeof(oPurchaseData.originalTransactionIdentifierIOS) ? oPurchaseData.originalTransactionIdentifierIOS : '';
  380. await fetch(PAYMENTS_CALLBACK, {
  381. method: 'POST',
  382. headers: {
  383. Accept: 'application/json',
  384. 'Content-Type': 'application/json',
  385. 'User-Agent': "UNAMobileApp/Mobile (" + Platform.OS + ")",
  386. },
  387. body: JSON.stringify({
  388. notification_type: 'INITIAL_BUY_CUSTOM',
  389. module: 'undefined' !== typeof(_self.products[sProductName]) ? _self.products[sProductName] : null,
  390. product: sProductName,
  391. count: 1,
  392. original_transaction: sTxIdOriginal,
  393. transaction: sTxId,
  394. profile_id: _self.state.data.loggedin ? _self.state.data.user_info.id : 0,
  395. original_data: oPurchaseData,
  396. })
  397. });
  398. if ('ios' === Platform.OS)
  399. RNIap.finishTransactionIOS(sTxId);
  400. }
  401. });
  402. purchaseErrorSubscription = purchaseErrorListener((error: PurchaseError) => {
  403. console.log('purchaseErrorListener', error);
  404. });
  405. }
  406. SplashScreen.hide();
  407. }
  408. componentWillUnmount() {
  409. if (this.purchaseUpdateSubscription) {
  410. this.purchaseUpdateSubscription.remove();
  411. this.purchaseUpdateSubscription = null;
  412. }
  413. if (this.purchaseErrorSubscription) {
  414. this.purchaseErrorSubscription.remove();
  415. this.purchaseErrorSubscription = null;
  416. }
  417. if (Platform.OS === 'android') {
  418. this.backHandler.remove();
  419. }
  420. }
  421. onWebViewMessage(event) {
  422. let oMsgData;
  423. try {
  424. oMsgData = JSON.parse(event.nativeEvent.data);
  425. }
  426. catch(err) {
  427. console.warn(err);
  428. return;
  429. }
  430. if ('undefined' !== typeof(oMsgData.loggedin)) {
  431. this.setState ({
  432. loading: this.loading,
  433. data: oMsgData,
  434. searchbar: false,
  435. key: 'undefined' === typeof(this.state.data.loggedin) || this.state.data.loggedin != oMsgData.loggedin ? this.state.key + 1 : this.state.key,
  436. });
  437. }
  438. if ('undefined' !== typeof(oMsgData['push_tags']) && oMsgData['push_tags'] !== false) {
  439. if ('undefined' !== typeof(oMsgData['push_tags']['email']) && oMsgData['push_tags']['email'].length) {
  440. OneSignal.setEmail(oMsgData['push_tags']['email'], oMsgData['push_tags']['email_hash'], (sError) => {
  441. if ('undefined' !== typeof(sError))
  442. console.warn("OneSignal set email error: " + sError);
  443. });
  444. delete oMsgData['push_tags']['email'];
  445. delete oMsgData['push_tags']['email_hash'];
  446. }
  447. OneSignal.sendTags(oMsgData['push_tags']);
  448. }
  449. if ('undefined' !== typeof(oMsgData['stop_loading']) && oMsgData['stop_loading']) {
  450. // this.onWebViewLoadEnd (event);
  451. }
  452. if ('undefined' !== typeof(oMsgData['video_call_start'])) {
  453. this.onVideoCallStart (oMsgData['video_call_start']['uri'], 'undefined' === typeof(oMsgData['video_call_start']['audio']) ? false : oMsgData['video_call_start']['audio']);
  454. }
  455. if ('undefined' !== typeof(oMsgData['video_call_stop']) && oMsgData['video_call_stop']) {
  456. this.endVideoCall ();
  457. }
  458. if ('undefined' !== typeof(oMsgData['request_purchase']) && oMsgData['request_purchase']) {
  459. this.onRequestPurchase (oMsgData['request_purchase']);
  460. }
  461. if ('undefined' !== typeof(oMsgData['request_subscription']) && oMsgData['request_subscription']) {
  462. this.onRequestSubscription (oMsgData['request_subscription']);
  463. }
  464. if ('undefined' !== typeof(oMsgData['goto_home']) && oMsgData['goto_home']) {
  465. this.onHomeMenu ();
  466. }
  467. if ('undefined' !== typeof(oMsgData['reload']) && oMsgData['reload']) {
  468. this.reload ();
  469. }
  470. }
  471. drawerClose () {
  472. this.refs.drawer._root.close()
  473. }
  474. drawerOpen () {
  475. this.refs.drawer._root.open()
  476. }
  477. render() {
  478. var colorScheme = Appearance.getColorScheme();
  479. var sWebview = (
  480. <WebView
  481. useWebKit={true}
  482. ref="webView1"
  483. key={this.state.key}
  484. geolocationEnabled={true}
  485. builtInZoomControls={false}
  486. decelerationRate="normal"
  487. cacheEnabled={true}
  488. allowsLinkPreview={true}
  489. hideKeyboardAccessoryView={true}
  490. injectedJavaScript={this.javascriptToInject()}
  491. onShouldStartLoadWithRequest={this.onWebViewShouldStartLoadWithRequest.bind(this)}
  492. onNavigationStateChange={this.onWebViewNavigationStateChange.bind(this)}
  493. style={{flex: 1}}
  494. source={{uri: `${BASE_URL}?skin=${TEMPLATE}&mix=${'dark' == colorScheme ? MIX_DARK : MIX_LIGHT}`}}
  495. userAgent={"UNAMobileApp/Mobile (" + Platform.OS + ")"}
  496. onMessage={this.onWebViewMessage.bind(this)}
  497. allowFileAccess={true}
  498. onLoad={this.onWebViewLoadEnd.bind(this)}
  499. onLoadStart={this.onWebViewLoadStart.bind(this)}
  500. renderError={this.onWebViewRenderError.bind(this)}
  501. />
  502. );
  503. return (
  504. <Container>
  505. <Drawer ref="drawer" content={<UnaDrawer onLogin={this.onDrawerLoginMenu.bind(this)} onJoin={this.onDrawerJoinMenu.bind(this)} onForotPassword={this.onDrawerForgotMenu.bind(this)} onClose={this.drawerClose.bind(this)} />} onClose={this.drawerClose.bind(this)}>
  506. <UnaApp
  507. webview={sWebview}
  508. state={this.state}
  509. videoCallAudio={this.videoCallAudio}
  510. onSearch={this.onSearch.bind(this)}
  511. onSearchCancelMenu={this.onSearchCancelMenu.bind(this)}
  512. onMainMenu={this.onMainMenu.bind(this)}
  513. onBackAndMainMenu={this.onBackAndMainMenu.bind(this)}
  514. onHomeMenu={this.onHomeMenu.bind(this)}
  515. onAddMenu={this.onAddMenu.bind(this)}
  516. onSearchMenu={this.onSearchMenu.bind(this)}
  517. onNotificationsMenu={this.onNotificationsMenu.bind(this)}
  518. onMessengerMenu={this.onMessengerMenu.bind(this)}
  519. onProfileMenu={this.onProfileMenu.bind(this)}
  520. onVideoCallToggle={this.onVideoCallToggle.bind(this)}
  521. onRequestSubscription={this.onRequestSubscription}
  522. onRequestPurchase={this.onRequestPurchase}
  523. onConferenceTerminated={this.onConferenceTerminated}
  524. onConferenceJoined={this.onConferenceJoined}
  525. onConferenceWillJoin={this.onConferenceWillJoin} />
  526. </Drawer>
  527. </Container>
  528. );
  529. }
  530. }
  531. function UnaApp(o) {
  532. return (<Container>
  533. {o.state.searchbar ? (
  534. <UnaToolbarSearch onSearch={o.onSearch} onSearchCancel={o.onSearchCancelMenu} />
  535. ) : (
  536. <UnaToolbar loading={o.state.loading} loggedin={o.state.data.loggedin} backButtonEnabled={o.state.backButtonEnabled} onMainMenu={o.onMainMenu} onHomeMenu={o.onHomeMenu} onSearchMenu={o.onSearchMenu} onBackAndMainMenu={o.onBackAndMainMenu} />
  537. ) }
  538. {o.state.videoCall && o.state.videoCallUri ? (
  539. <View style={styles.containerVideoCall}><VideoCall onConferenceTerminated={o.onConferenceTerminated} onConferenceJoined={o.onConferenceJoined} onConferenceWillJoin={o.onConferenceWillJoin} conferenceUri={o.state.videoCallUri} audio={o.videoCallAudio} userInfo={o.state.data.user_info} /></View>
  540. ) : (
  541. <View />
  542. )}
  543. {o.webview}
  544. {o.state.data.loggedin && (
  545. <UnaFooter bubblesNum={o.state.data.bubbles_num} bubbles={o.state.data.bubbles} onMainMenu={o.onMainMenu} onNotificationsMenu={o.onNotificationsMenu} onVideoCallToggle={o.onVideoCallToggle} onRequestPurchase={o.onRequestPurchase} onRequestSubscription={o.onRequestSubscription} onAddMenu={o.onAddMenu} onMessengerMenu={o.onMessengerMenu} onProfileMenu={o.onProfileMenu} />
  546. )}
  547. </Container>
  548. );
  549. }
  550. function UnaFooter(o) {
  551. return (
  552. <Footer style={styles.footer}>
  553. {!('decorous' == TEMPLATE && Platform.isPad) &&
  554. (<FooterTab style={styles.footerTab}>
  555. <Button vertical onPress={o.onMainMenu}>
  556. <Icon style={styles.footerIcon} name="bars" type="FontAwesome5" />
  557. </Button>
  558. </FooterTab>)
  559. }
  560. <FooterTab style={styles.footerTab}>
  561. <Button vertical onPress={o.onNotificationsMenu} badge={o.bubbles['notifications-preview'] > 0 ? true : false}>
  562. {o.bubbles['notifications-preview'] > 0 &&
  563. (<Badge><Text>{o.bubbles['notifications-preview']}</Text></Badge>)
  564. }
  565. <Icon style={styles.footerIcon} name="bell" type="FontAwesome5" solid />
  566. </Button>
  567. </FooterTab>
  568. {/*
  569. <FooterTab style={styles.footerTab}>
  570. <Button vertical onPress={o.onVideoCallToggle}>
  571. <Icon style={styles.footerIcon} name="video" type="FontAwesome5" solid />
  572. </Button>
  573. </FooterTab>
  574. */}
  575. <FooterTab style={styles.footerTab}>
  576. <Button vertical onPress={o.onAddMenu}>
  577. <Icon style={styles.footerIcon} name="plus-circle" type="FontAwesome5" solid />
  578. </Button>
  579. </FooterTab>
  580. <FooterTab style={styles.footerTab}>
  581. <Button vertical onPress={o.onMessengerMenu} badge={o.bubbles['notifications-messenger'] > 0 ? true : false}>
  582. {o.bubbles['notifications-messenger'] > 0 &&
  583. (<Badge><Text>{o.bubbles['notifications-messenger']}</Text></Badge>)
  584. }
  585. <Icon style={styles.footerIcon} name="comments" type="FontAwesome5" solid />
  586. </Button>
  587. </FooterTab>
  588. <FooterTab style={styles.footerTab}>
  589. <Button vertical onPress={o.onProfileMenu} badge={o.bubbles['account'] > 0 ? true : false}>
  590. {o.bubbles['account'] > 0 &&
  591. (<Badge><Text>{o.bubbles['account']}</Text></Badge>)
  592. }
  593. <Icon style={styles.footerIcon} name="user" type="FontAwesome5" solid />
  594. </Button>
  595. </FooterTab>
  596. </Footer>
  597. );
  598. }
  599. function UnaToolbar(o) {
  600. var colorScheme = Appearance.getColorScheme();
  601. return (
  602. <Header androidStatusBarColor={useTheme('colors.statusBar')} transparent={false} iosBarStyle={useTheme('iosBarStyle')} style={styles.header}>
  603. <Left>
  604. {o.loading ? (
  605. <ActivityIndicator size="small" color={useTheme('colors.activityIndicator')} style={styles.loadingIndicator} />
  606. ):(
  607. o.loggedin ? (
  608. (o.backButtonEnabled || Platform.OS === 'android') &&
  609. (<Button style={Platform.OS === 'android' ? styles.buttonLeftTopAndroid : styles.buttonLeftTopIos} transparent disabled={!o.backButtonEnabled} onPress={o.onBackAndMainMenu}>
  610. <Icon name="ios-arrow-back" style={styles.headerIcon} />
  611. </Button>)
  612. ) : (
  613. <Button style={Platform.OS === 'android' ? styles.buttonLeftTopAndroid : styles.buttonLeftTopIos} transparent onPress={o.onMainMenu}>
  614. <Icon name='menu' style={styles.headerIcon} />
  615. </Button>
  616. )
  617. )}
  618. </Left>
  619. <Body style={Platform.OS === 'android' && {flexDirection: 'row', justifyContent: 'flex-start'}}>
  620. <Title style={styles.headerTitle} onPress={o.onHomeMenu}>{TITLE}</Title>
  621. </Body>
  622. <Right>
  623. {o.loggedin && (
  624. <Button transparent>
  625. <Icon name='search' onPress={o.onSearchMenu} style={styles.headerIcon} />
  626. </Button>
  627. )}
  628. </Right>
  629. </Header>
  630. );
  631. }
  632. function UnaToolbarSearch(o) {
  633. var colorScheme = Appearance.getColorScheme();
  634. return (
  635. <Header androidStatusBarColor={useTheme('colors.statusBar')} transparent={false} iosBarStyle={useTheme('iosBarStyle')} style={styles.header} searchBar rounded>
  636. <Item>
  637. <Icon name="search" />
  638. <Input placeholder="Search" onEndEditing={o.onSearchCancel} onSubmitEditing={o.onSearch} />
  639. </Item>
  640. <Button transparent onPress={o.onSearchCancel}>
  641. <Text style={styles.headerIcon}>Cancel</Text>
  642. </Button>
  643. </Header>
  644. );
  645. }
  646. function UnaDrawer(o) {
  647. return (
  648. <Container style={styles.drawerContainer}>
  649. <Content>
  650. <View style={styles.drawerImageContainer}>
  651. <Image style={styles.drawerImage} source={require('./img/logo-loading.png')} />
  652. </View>
  653. <Button style={styles.drawerButton} iconLeft transparent onPress={o.onLogin}>
  654. <Icon style={styles.drawerButtonIcon} name='key' type="FontAwesome5" solid />
  655. <Text style={styles.drawerButtonText}>Login</Text>
  656. </Button>
  657. <Button style={styles.drawerButton} iconLeft transparent onPress={o.onJoin}>
  658. <Icon style={styles.drawerButtonIcon} name='plus-circle' type="FontAwesome5" solid />
  659. <Text style={styles.drawerButtonText}>Join</Text>
  660. </Button>
  661. <Button style={styles.drawerButton} iconLeft transparent onPress={o.onForotPassword}>
  662. <Icon style={styles.drawerButtonIcon} name='lock' type="FontAwesome5" solid />
  663. <Text style={styles.drawerButtonText}>Forgot Password</Text>
  664. </Button>
  665. </Content>
  666. </Container>
  667. );
  668. }
  669. const styles = new StyleSheet.create({
  670. container: {
  671. backgroundColor: useTheme('colors.background'),
  672. flex: 1
  673. },
  674. header: {
  675. backgroundColor: useTheme('colors.primary'),
  676. height: 46, paddingTop:0, // tmp fix - https://github.com/GeekyAnts/NativeBase/issues/3095
  677. },
  678. headerTitle: {
  679. color: useTheme('colors.textOnPrimary'),
  680. },
  681. headerIcon: {
  682. color: useTheme('colors.textOnPrimary'),
  683. },
  684. footer: {
  685. backgroundColor: useTheme('colors.primary'),
  686. },
  687. footerTab: {
  688. backgroundColor: useTheme('colors.primary'),
  689. },
  690. footerIcon: {
  691. color: useTheme('colors.textOnPrimary'),
  692. },
  693. containerVideoCall: {
  694. backgroundColor: '#000',
  695. flex: 999999999999,
  696. },
  697. loadingIndicator: {
  698. marginLeft: 5,
  699. marginTop: 5,
  700. },
  701. buttonLeftTopAndroid: {
  702. },
  703. buttonLeftTopIos: {
  704. marginLeft: 5,
  705. },
  706. drawerContainer: {
  707. backgroundColor: useTheme('colors.drawerBackground'),
  708. },
  709. drawerImageContainer: {
  710. height:100,
  711. justifyContent: 'center',
  712. alignItems: 'center',
  713. backgroundColor: useTheme('colors.drawerBackground'),
  714. },
  715. drawerImage: {
  716. height:33.5,
  717. width:125,
  718. },
  719. drawerButton: {
  720. justifyContent: 'flex-start',
  721. },
  722. drawerButtonIcon: {
  723. width: 20,
  724. fontSize: 20,
  725. justifyContent: 'center',
  726. textAlign: 'center',
  727. color: useTheme('colors.drawerText'),
  728. },
  729. drawerButtonText: {
  730. color: useTheme('colors.drawerText'),
  731. }
  732. });