Advertisement
Guest User

Untitled

a guest
Apr 16th, 2018
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 87.05 KB | None | 0 0
  1. /**
  2. * Niagara Fitness App
  3. * https://github.com/facebook/react-native
  4. * @flow
  5. */
  6.  
  7. import React, { Component } from "react";
  8. import {
  9. KeyboardAvoidingView,
  10. TouchableOpacity,
  11. ImageBackground,
  12. AsyncStorage,
  13. BackAndroid,
  14. ScrollView,
  15. StyleSheet,
  16. FlatList,
  17. Platform,
  18. StatusBar,
  19. TextInput,
  20. WebView,
  21. Image,
  22. Text,
  23. View
  24. } from "react-native";
  25.  
  26. import { StackNavigator, NavigationActions } from "react-navigation";
  27. import PushNotificationAndroid from "react-native-push-notification";
  28. import { send, subscribe } from "react-native-training-chat-server";
  29.  
  30. import BackgroundJob from "react-native-background-job";
  31. import Communications from "react-native-communications";
  32. import Swiper from "react-native-swiper";
  33.  
  34. import single_offer from "./assets/singleOffer_styles";
  35. import virtual_styles from "./assets/virtual_styles";
  36. import offers from "./assets/offersArchive_styles";
  37. import trainers from "./assets/trainers_styles";
  38. import schedule from "./assets/schedule_styles";
  39. import profile from "./assets/profile_styles";
  40. import clients from "./assets/clients_styles";
  41. import manager from "./assets/manager_styles";
  42. import styles from "./assets/global_styles";
  43. import zones from "./assets/zones_styles";
  44. import chat from "./assets/chat_styles";
  45.  
  46. import config from "./config";
  47. // import translations from "./lang";
  48.  
  49. import LoadingScreen from "./views/loading";
  50. import Day from "./views/day";
  51. import Content from "./views/offer_content";
  52.  
  53. /*
  54. * Push Notification ( Start )
  55. */
  56. var PushNotification = require("react-native-push-notification");
  57.  
  58. PushNotification.configure({
  59. // (optional) Called when Token is generated (iOS and Android)
  60. onRegister: function(token) {
  61. console.log("TOKEN:", token);
  62. },
  63.  
  64. // (required) Called when a remote or local notification is opened or received
  65. onNotification: function(notification) {
  66. const { navigate } = this.props.navigation;
  67. navigate("Home", { isLoggedIn: false });
  68. // process the notification
  69.  
  70. // required on iOS only (see fetchCompletionHandler docs: https://facebook.github.io/react-native/docs/pushnotificationios.html)
  71. notification.finish(PushNotificationIOS.FetchResult.NoData);
  72. },
  73.  
  74. // ANDROID ONLY: GCM Sender ID (optional - not required for local notifications, but is need to receive remote push notifications)
  75. senderID: "YOUR GCM SENDER ID",
  76.  
  77. // IOS ONLY (optional): default: all - Permissions to register.
  78. permissions: {
  79. alert: true,
  80. badge: true,
  81. sound: true
  82. },
  83.  
  84. // Should the initial notification be popped automatically
  85. // default: true
  86. popInitialNotification: true,
  87.  
  88. /**
  89. * (optional) default: true
  90. * - Specified if permissions (ios) and token (android and ios) will requested or not,
  91. * - if not, you must call PushNotificationsHandler.requestPermissions() later
  92. */
  93. requestPermissions: true
  94. });
  95.  
  96. async function GetLatestNews(lastOfferID) {
  97. console.log("Running in background");
  98. var PushNotification = require("react-native-push-notification");
  99. fetch(
  100. "http://app.niagara.md/api/?ApiToken=eb5a65e694c10a534e53167967daf6f8&action=get_notification"
  101. )
  102. .then(response => response.json())
  103. .then(responseJson => {
  104. if (lastOfferID !== responseJson.item.notificationID) {
  105. PushNotification.localNotification({
  106. /* Android Only Properties */
  107. foreground: true,
  108. id: "0", // (optional) Valid unique 32 bit integer specified as string. default: Autogenerated Unique ID
  109. ticker: GetNotificationID(), // (optional)
  110. autoCancel: true, // (optional) default: true
  111. largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
  112. smallIcon: "ic_notification", // (optional) default: "ic_notification" with fallback for "ic_launcher"
  113. bigText: JSON.stringify(responseJson.item.post_content), // (optional) default: "message" prop
  114. subText: "This is a subText", // (optional) default: none
  115. color: "red", // (optional) default: system default
  116. vibrate: true, // (optional) default: true
  117. vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
  118. tag: "some_tag", // (optional) add tag to message
  119. group: "group", // (optional) add group to message
  120. ongoing: true, // (optional) set whether this is an "ongoing" notification
  121.  
  122. /* iOS and Android properties */
  123. title: JSON.stringify(responseJson.item.post_title), // (optional, for iOS this is only used in apple watch, the title will be the app name on other iOS devices)
  124. message: JSON.stringify(responseJson.item.post_content), // (required)
  125. playSound: false, // (optional) default: true
  126. soundName: "default", // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
  127. number: "10", // (optional) Valid 32 bit integer specified as string. default: none (Cannot be zero)
  128. repeatType: "day", // (Android only) Repeating interval. Could be one of `week`, `day`, `hour`, `minute, `time`. If specified as time, it should be accompanied by one more parameter 'repeatTime` which should the number of milliseconds between each interval
  129. actions: false,
  130. date: new Date(Date.now() + 60 * 0) // in 60 secs
  131. });
  132. let notificationID = responseJson.item.notificationID;
  133. SetNotificationID(notificationID);
  134. }
  135.  
  136. return notificationID;
  137. })
  138. .catch(error => {});
  139. }
  140.  
  141. const backgroundJob = {
  142. jobKey: "myJob",
  143. job: async () => {
  144. try {
  145. let lastOfferID = await AsyncStorage.getItem("@Common:lastOfferID");
  146. if (lastOfferID == null) {
  147. lastOfferID = "1";
  148. } else {
  149. }
  150. } catch (error) {
  151. // console.log(error);
  152. }
  153. if (lastOfferID !== null) {
  154. alert("1");
  155. let res = GetLatestNews(lastOfferID);
  156. } else {
  157. alert("2");
  158. let res = GetLatestNews(1);
  159. }
  160.  
  161. try {
  162. await AsyncStorage.setItem(
  163. "@Common:lastOfferID",
  164. JSON.stringify(lastOfferID)
  165. );
  166. } catch (error) {
  167. console.log(error);
  168. }
  169. }
  170. };
  171.  
  172. BackgroundJob.register(backgroundJob);
  173.  
  174. var backgroundSchedule = {
  175. jobKey: "myJob",
  176. period: 1000,
  177. exact: true,
  178. allowExecutionInForeground: true
  179. };
  180.  
  181. BackgroundJob.schedule(backgroundSchedule);
  182.  
  183. /*
  184. * Push Notification ( End )
  185. */
  186. /*
  187. * Common functions ( Start )
  188. * That are running over all screens
  189. *
  190. * Disable warnings in the test mode
  191. */
  192. console.disableYellowBox = true;
  193.  
  194. /*
  195. * Reset navigation after login
  196. * to disable login screen for logged in users
  197. */
  198. const resetAction = NavigationActions.reset({
  199. index: 0,
  200. actions: [NavigationActions.navigate({ routeName: "Home" })]
  201. });
  202.  
  203. // Common functions ( End )
  204.  
  205. class WebScreen extends Component {
  206. static navigationOptions = {
  207. title: "WebScreen"
  208. };
  209.  
  210. constructor(props) {
  211. super(props);
  212. this.state = {
  213. isLoading: true
  214. };
  215. }
  216.  
  217. async componentWillMount() {
  218. const { params } = this.props.navigation.state;
  219.  
  220. this.setState({
  221. isLoading: false,
  222. targetLink: params.targetLink
  223. });
  224. }
  225.  
  226. render() {
  227. let targetLink = this.state.targetLink;
  228.  
  229. if (this.state.isLoading) {
  230. return <LoadingScreen />;
  231. }
  232.  
  233. return <WebView source={{ uri: targetLink }} />;
  234. }
  235. }
  236.  
  237. class VirtualScreen extends React.Component {
  238. static navigationOptions = {
  239. title: "VirtualPage"
  240. };
  241.  
  242. constructor(props) {
  243. super(props);
  244. this.state = {
  245. isLoading: true
  246. };
  247. }
  248.  
  249. componentDidMount() {
  250. this.setState({
  251. isLoading: false
  252. });
  253. }
  254.  
  255. render() {
  256. if (this.state.isLoading) {
  257. return <LoadingScreen />;
  258. }
  259.  
  260. return (
  261. <ScrollView style={single_offer.fullScreenContainer}>
  262. <StatusBar
  263. backgroundColor="transparent"
  264. barStyle="light-content"
  265. translucent
  266. />
  267. <View style={single_offer.offerWrapper}>
  268. <ImageBackground
  269. source={require("./images/virtual.png")}
  270. style={virtual_styles.HeadingImage}
  271. >
  272. <Text style={single_offer.swiperTriangle} />
  273. </ImageBackground>
  274. </View>
  275.  
  276. <View style={manager.contactsWrapper}>
  277. <Text style={virtual_styles.HeadingTitle}>Niagara fitness club</Text>
  278.  
  279. <TouchableOpacity
  280. style={manager.contactItem}
  281. onPress={() => Communications.phonecall("022 01 10 21", true)}
  282. >
  283. <Image
  284. source={require("./images/mobile_phone.png")}
  285. style={manager.contactIcon}
  286. />
  287. <Text style={manager.contactText}>022 01 10 21</Text>
  288. </TouchableOpacity>
  289.  
  290. <TouchableOpacity
  291. style={manager.contactItem}
  292. onPress={() =>
  293. Communications.email(
  294. ["marketing@niagara.md"],
  295. null,
  296. null,
  297. null,
  298. null
  299. )
  300. }
  301. >
  302. <Image
  303. source={require("./images/mail.png")}
  304. style={manager.contactIcon}
  305. />
  306. <Text style={manager.contactText}>marketing@niagara.md</Text>
  307. </TouchableOpacity>
  308.  
  309. <TouchableOpacity style={manager.contactItem}>
  310. <Image
  311. source={require("./images/pointer.png")}
  312. style={manager.contactIcon}
  313. />
  314. <Text style={manager.contactText}>str. Ghidighici 5</Text>
  315. </TouchableOpacity>
  316.  
  317. <View style={virtual_styles.hoursWrapper}>
  318. <View style={virtual_styles.hoursSingle}>
  319. <Text style={virtual_styles.hoursSingleLabel}>Luni-Simbata:</Text>
  320. <Text style={virtual_styles.hoursSingleValue}>07:00 - 23:00</Text>
  321. </View>
  322. <View style={virtual_styles.hoursSingle}>
  323. <Text style={virtual_styles.hoursSingleLabel}>Duminica:</Text>
  324. <Text style={virtual_styles.hoursSingleValue}>09:00 - 22:00</Text>
  325. </View>
  326.  
  327. <TouchableOpacity
  328. onPress={() => Communications.phonecall("022 01 10 21", true)}
  329. style={styles.halfWidthButton}
  330. >
  331. <Text style={[styles.fullWidthButtonLabel]}>Call Now</Text>
  332. </TouchableOpacity>
  333. </View>
  334. </View>
  335. </ScrollView>
  336. );
  337. }
  338. }
  339.  
  340. class FaqScreen extends React.Component {
  341. static navigationOptions = {
  342. title: "FaqPage"
  343. };
  344.  
  345. constructor(props) {
  346. super(props);
  347. this.state = {
  348. isLoading: true
  349. };
  350. }
  351.  
  352. componentDidMount() {
  353. this.setState({
  354. isLoading: false
  355. });
  356. }
  357.  
  358. render() {
  359. if (this.state.isLoading) {
  360. return <LoadingScreen />;
  361. }
  362.  
  363. return (
  364. <ScrollView style={single_offer.fullScreenContainer}>
  365. <StatusBar
  366. backgroundColor="transparent"
  367. barStyle="light-content"
  368. translucent
  369. />
  370. <View style={single_offer.offerWrapper}>
  371. <ImageBackground
  372. source={require("./images/faq_bg.jpg")}
  373. style={virtual_styles.HeadingImage}
  374. >
  375. <Text style={single_offer.swiperTriangle} />
  376. </ImageBackground>
  377. </View>
  378.  
  379. <View style={manager.contactsWrapper}>
  380. <Text style={virtual_styles.HeadingTitle}>Niagara fitness club</Text>
  381.  
  382. <TouchableOpacity
  383. style={manager.contactItem}
  384. onPress={() => Communications.phonecall("022 01 10 21", true)}
  385. >
  386. <Image
  387. source={require("./images/mobile_phone.png")}
  388. style={manager.contactIcon}
  389. />
  390. <Text style={manager.contactText}>022 01 10 21</Text>
  391. </TouchableOpacity>
  392.  
  393. <TouchableOpacity
  394. style={manager.contactItem}
  395. onPress={() =>
  396. Communications.email(
  397. ["marketing@niagara.md"],
  398. null,
  399. null,
  400. null,
  401. null
  402. )
  403. }
  404. >
  405. <Image
  406. source={require("./images/mail.png")}
  407. style={manager.contactIcon}
  408. />
  409. <Text style={manager.contactText}>marketing@niagara.md</Text>
  410. </TouchableOpacity>
  411.  
  412. <TouchableOpacity style={manager.contactItem}>
  413. <Image
  414. source={require("./images/pointer.png")}
  415. style={manager.contactIcon}
  416. />
  417. <Text style={manager.contactText}>str. Ghidighici 5</Text>
  418. </TouchableOpacity>
  419.  
  420. <View style={virtual_styles.hoursWrapper}>
  421. <View style={virtual_styles.hoursSingle}>
  422. <Text style={virtual_styles.hoursSingleLabel}>Luni-Simbata:</Text>
  423. <Text style={virtual_styles.hoursSingleValue}>07:00 - 23:00</Text>
  424. </View>
  425. <View style={virtual_styles.hoursSingle}>
  426. <Text style={virtual_styles.hoursSingleLabel}>Duminica:</Text>
  427. <Text style={virtual_styles.hoursSingleValue}>09:00 - 22:00</Text>
  428. </View>
  429.  
  430. <TouchableOpacity
  431. onPress={() => Communications.phonecall("022 01 10 21", true)}
  432. style={styles.halfWidthButton}
  433. >
  434. <Text style={[styles.fullWidthButtonLabel]}>Call Now</Text>
  435. </TouchableOpacity>
  436. </View>
  437. </View>
  438. </ScrollView>
  439. );
  440. }
  441. }
  442.  
  443. class ChatScreen extends React.Component {
  444. static navigationOptions = {
  445. title: "ChatPage"
  446. };
  447.  
  448. state = {
  449. isLoading: true,
  450. typing: "",
  451. messages: []
  452. };
  453.  
  454. async componentWillMount() {
  455. const { params } = this.props.navigation.state;
  456.  
  457. chatName = await AsyncStorage.getItem("@User:firstName");
  458. let userID = await AsyncStorage.getItem("@User:userID");
  459. let userToken = await AsyncStorage.getItem("@User:userToken");
  460. let signedManager = await AsyncStorage.getItem("@User:signedManager");
  461.  
  462. this.setState({
  463. userManager: JSON.parse(signedManager),
  464. isLoading: false,
  465. localID: userID
  466. });
  467.  
  468. channel = JSON.parse(userToken) + "_" + params.chatToken;
  469.  
  470. CHANNEL = channel;
  471. USERID = userID;
  472.  
  473. subscribe(CHANNEL, messages => {
  474. this.setState({ messages });
  475. });
  476. }
  477.  
  478. sendMessage = async () => {
  479. // read message from component state
  480. const message = this.state.typing;
  481.  
  482. // send message to our channel, with sender name
  483. await send({
  484. channel: CHANNEL,
  485. sender: chatName,
  486. id: USERID,
  487. message
  488. });
  489.  
  490. // set the component state (clears text input)
  491. this.setState({
  492. typing: ""
  493. });
  494. };
  495.  
  496. renderItem({ item }) {
  497. if (chatName == item.sender) {
  498. return (
  499. <View style={chat.row}>
  500. <View style={chat.rowText}>
  501. <View style={chat.bubble}>
  502. <Text style={chat.message}>{item.message}</Text>
  503. </View>
  504. </View>
  505. </View>
  506. );
  507. }
  508. return (
  509. <View style={chat.rowReverse}>
  510. <View style={chat.rowText}>
  511. <View style={chat.bubbleReverse}>
  512. <Text style={chat.message}>{item.message}</Text>
  513. </View>
  514. </View>
  515. </View>
  516. );
  517. }
  518.  
  519. render() {
  520. if (this.state.isLoading) {
  521. return <LoadingScreen />;
  522. }
  523.  
  524. return (
  525. <View style={chat.container}>
  526. <View style={chat.header}>
  527. <Text style={chat.managerTitle}>
  528. {this.state.userManager.display_name}
  529. </Text>
  530. <Image
  531. source={{ uri: this.state.userManager.avatar }}
  532. style={chat.managerAvatar}
  533. />
  534. </View>
  535. <FlatList
  536. data={this.state.messages}
  537. renderItem={this.renderItem}
  538. inverted
  539. />
  540. <KeyboardAvoidingView>
  541. <View style={chat.footer}>
  542. <TextInput
  543. value={this.state.typing}
  544. style={chat.input}
  545. underlineColorAndroid="transparent"
  546. placeholder="Type something nice"
  547. onChangeText={text => this.setState({ typing: text })}
  548. />
  549. <TouchableOpacity onPress={this.sendMessage}>
  550. <Text style={chat.send}>Send</Text>
  551. </TouchableOpacity>
  552. </View>
  553. </KeyboardAvoidingView>
  554. </View>
  555. );
  556. }
  557. }
  558.  
  559. class ManagerChatScreen extends React.Component {
  560. static navigationOptions = {
  561. title: "ChatPage"
  562. };
  563.  
  564. state = {
  565. isLoading: true,
  566. typing: "",
  567. messages: [],
  568. clientToken: "",
  569. clientAvatar: "",
  570. clientDisplayName: ""
  571. };
  572.  
  573. async componentWillMount() {
  574. const { params } = this.props.navigation.state;
  575.  
  576. chatName = await AsyncStorage.getItem("@User:firstName");
  577. let userID = await AsyncStorage.getItem("@User:userID");
  578. let userToken = await AsyncStorage.getItem("@User:userToken");
  579.  
  580. this.setState({
  581. isLoading: false,
  582. localID: userID,
  583. clientToken: params.clientToken,
  584. clientAvatar: params.clientAvatar,
  585. clientDisplayName: params.clientDisplayName
  586. });
  587.  
  588. channel = params.clientToken + "_" + JSON.parse(userToken);
  589.  
  590. CHANNEL = channel;
  591. USERID = userID;
  592.  
  593. subscribe(CHANNEL, messages => {
  594. this.setState({ messages });
  595. });
  596. }
  597.  
  598. sendMessage = async () => {
  599. // read message from component state
  600. const message = this.state.typing;
  601.  
  602. // send message to our channel, with sender name
  603. await send({
  604. channel: CHANNEL,
  605. sender: chatName,
  606. id: USERID,
  607. message
  608. });
  609.  
  610. // set the component state (clears text input)
  611. this.setState({
  612. typing: ""
  613. });
  614. };
  615.  
  616. renderItem({ item }) {
  617. if (chatName == item.sender) {
  618. return (
  619. <View style={chat.row}>
  620. <View style={chat.rowText}>
  621. <View style={chat.bubble}>
  622. <Text style={chat.message}>{item.message}</Text>
  623. </View>
  624. </View>
  625. </View>
  626. );
  627. }
  628. return (
  629. <View style={chat.rowReverse}>
  630. <View style={chat.rowText}>
  631. <View style={chat.bubbleReverse}>
  632. <Text style={chat.message}>{item.message}</Text>
  633. </View>
  634. </View>
  635. </View>
  636. );
  637. }
  638.  
  639. render() {
  640. if (this.state.isLoading) {
  641. return <LoadingScreen />;
  642. }
  643.  
  644. return (
  645. <View style={chat.container}>
  646. <View style={chat.header}>
  647. <Text style={chat.managerTitle}>{this.state.clientDisplayName}</Text>
  648. <Image
  649. source={{ uri: this.state.clientAvatar }}
  650. style={chat.managerAvatar}
  651. />
  652. </View>
  653. <FlatList
  654. data={this.state.messages}
  655. renderItem={this.renderItem}
  656. inverted
  657. />
  658. <KeyboardAvoidingView>
  659. <View style={chat.footer}>
  660. <TextInput
  661. value={this.state.typing}
  662. style={chat.input}
  663. underlineColorAndroid="transparent"
  664. placeholder="Type something nice"
  665. onChangeText={text => this.setState({ typing: text })}
  666. />
  667. <TouchableOpacity onPress={this.sendMessage}>
  668. <Text style={chat.send}>Send</Text>
  669. </TouchableOpacity>
  670. </View>
  671. </KeyboardAvoidingView>
  672. </View>
  673. );
  674. }
  675. }
  676.  
  677. class LoginScreen extends React.Component {
  678. static navigationOptions = {
  679. title: "LoginPage"
  680. };
  681.  
  682. constructor(props) {
  683. super(props);
  684. this.state = {
  685. isLoading: true
  686. };
  687. }
  688.  
  689. FetchLogin = async () => {
  690. const { navigate } = this.props.navigation;
  691.  
  692. return fetch(
  693. config.hostProtocol +
  694. config.hostName +
  695. config.APIBreakPoint +
  696. config.ApiTokenParam +
  697. config.APIToken +
  698. config.actionUserData +
  699. config.usernameParam +
  700. this.state.name +
  701. config.passwordParam +
  702. this.state.password
  703. )
  704. .then(response => response.json())
  705. .then(responseJson => {
  706. this.setState(
  707. {
  708. isLoading: false,
  709. errorMsg: responseJson.response.message,
  710. userID: responseJson.response.userID
  711. },
  712. async function() {
  713. if (responseJson.response.userRole == "manager") {
  714. try {
  715. await AsyncStorage.setItem(
  716. "@User:isLoggedIn",
  717. JSON.stringify(true)
  718. );
  719. await AsyncStorage.setItem(
  720. "@User:userRole",
  721. JSON.stringify(responseJson.response.userRole)
  722. );
  723. await AsyncStorage.setItem(
  724. "@User:userID",
  725. JSON.stringify(responseJson.response.userID)
  726. );
  727. await AsyncStorage.setItem(
  728. "@User:userAvatar",
  729. JSON.stringify(responseJson.user.manager_user_avatar)
  730. );
  731. await AsyncStorage.setItem(
  732. "@User:signedClients",
  733. JSON.stringify(responseJson.user.signed_clients)
  734. );
  735. await AsyncStorage.setItem(
  736. "@User:mobilePhone",
  737. JSON.stringify(responseJson.user.manager_phone_number)
  738. );
  739. await AsyncStorage.setItem(
  740. "@User:firstName",
  741. responseJson.user.firstName
  742. );
  743. await AsyncStorage.setItem(
  744. "@User:lastName",
  745. responseJson.user.lastName
  746. );
  747. await AsyncStorage.setItem(
  748. "@User:email",
  749. JSON.stringify(responseJson.user.manager_email)
  750. );
  751. await AsyncStorage.setItem(
  752. "@User:userToken",
  753. JSON.stringify(responseJson.user.user_token)
  754. );
  755.  
  756. const { navigate } = this.props.navigation;
  757.  
  758. this.props.navigation.dispatch(resetAction);
  759. } catch (error) {
  760. // Error saving data
  761. }
  762. } else {
  763. try {
  764. await AsyncStorage.setItem(
  765. "@User:isLoggedIn",
  766. JSON.stringify(true)
  767. );
  768. await AsyncStorage.setItem(
  769. "@User:userRole",
  770. JSON.stringify(responseJson.response.userRole)
  771. );
  772. await AsyncStorage.setItem(
  773. "@User:userID",
  774. JSON.stringify(responseJson.response.userID)
  775. );
  776. await AsyncStorage.setItem(
  777. "@User:userSex",
  778. JSON.stringify(responseJson.user.sex)
  779. );
  780. await AsyncStorage.setItem(
  781. "@User:userAvatar",
  782. JSON.stringify(responseJson.user.client_user_avatar)
  783. );
  784. await AsyncStorage.setItem(
  785. "@User:mobilePhone",
  786. JSON.stringify(responseJson.user.mobile_phone)
  787. );
  788. await AsyncStorage.setItem(
  789. "@User:clubCardType",
  790. JSON.stringify(responseJson.user.club_card_type)
  791. );
  792. await AsyncStorage.setItem(
  793. "@User:birthdayDate",
  794. JSON.stringify(responseJson.user.birthday_date)
  795. );
  796. await AsyncStorage.setItem(
  797. "@User:firstName",
  798. responseJson.user.firstName
  799. );
  800. await AsyncStorage.setItem(
  801. "@User:lastName",
  802. responseJson.user.lastName
  803. );
  804. await AsyncStorage.setItem(
  805. "@User:email",
  806. JSON.stringify(responseJson.user.email)
  807. );
  808. await AsyncStorage.setItem(
  809. "@User:userToken",
  810. JSON.stringify(responseJson.user.user_token)
  811. );
  812. await AsyncStorage.setItem(
  813. "@User:signedTrainer",
  814. JSON.stringify(responseJson.user.signed_trainer)
  815. );
  816. await AsyncStorage.setItem(
  817. "@User:signedManager",
  818. JSON.stringify(responseJson.user.signed_manager)
  819. );
  820.  
  821. const { navigate } = this.props.navigation;
  822.  
  823. this.props.navigation.dispatch(resetAction);
  824. } catch (error) {
  825. // Error saving data
  826. }
  827. }
  828. }
  829. );
  830. });
  831. };
  832.  
  833. async componentDidMount() {
  834. try {
  835. let isLoggedIn = await AsyncStorage.getItem("@User:isLoggedIn");
  836. if (isLoggedIn !== null) {
  837. this.setState({
  838. isLoggedIn: isLoggedIn,
  839. isLoading: false
  840. });
  841. } else {
  842. this.setState({
  843. isLoggedIn: false,
  844. isLoading: false
  845. });
  846. }
  847. } catch (error) {
  848. // Error retrieving data
  849. }
  850. if (this.state.isLoggedIn) {
  851. const { navigate } = this.props.navigation;
  852. this.props.navigation.dispatch(resetAction);
  853. }
  854. }
  855.  
  856. render() {
  857. if (this.state.isLoading) {
  858. return <LoadingScreen />;
  859. }
  860.  
  861. return (
  862. <View style={styles.fullScreenContainer}>
  863. <StatusBar
  864. backgroundColor="transparent"
  865. barStyle="light-content"
  866. translucent
  867. />
  868.  
  869. <ImageBackground
  870. source={require("./images/menu.jpg")}
  871. style={styles.fullScreenImage}
  872. >
  873. <Image
  874. source={require("./images/logologin.png")}
  875. style={styles.loginLogo}
  876. />
  877. <Text style={styles.smallText}>{this.state.errorMsg}</Text>
  878. <TextInput
  879. placeholder="Phone Number *"
  880. style={styles.inputsText}
  881. onChangeText={text => this.setState({ name: text })}
  882. value={this.state.name}
  883. multiline={false}
  884. placeholderTextColor="white"
  885. underlineColorAndroid="transparent"
  886. returnKeyType="next"
  887. />
  888. <TextInput
  889. placeholder="Password"
  890. style={styles.inputsText}
  891. onChangeText={text => this.setState({ password: text })}
  892. value={this.state.password}
  893. multiline={false}
  894. placeholderTextColor="white"
  895. underlineColorAndroid="transparent"
  896. returnKeyType="go"
  897. secureTextEntry={true}
  898. />
  899. <View style={styles.halfScreenContainer}>
  900. <TouchableOpacity
  901. onPress={this.FetchLogin}
  902. style={styles.halfWidthButton}
  903. >
  904. <Text style={[styles.fullWidthButtonLabel]}>Sign in</Text>
  905. </TouchableOpacity>
  906.  
  907. <TouchableOpacity
  908. onPress={async () => {
  909. try {
  910. await AsyncStorage.removeItem("@User:isLoggedIn");
  911. await AsyncStorage.removeItem("@User:userID");
  912. await AsyncStorage.removeItem("@User:userRole");
  913. // BackAndroid.exitApp();
  914.  
  915. const { navigate } = this.props.navigation;
  916. navigate("Middle");
  917. } catch (error) {
  918. // Error saving data
  919. const { navigate } = this.props.navigation;
  920. navigate("Middle");
  921. }
  922. }}
  923. style={styles.halfWidthButtonBlue}
  924. >
  925. <Text style={styles.fullWidthButtonLabel}>Back</Text>
  926. </TouchableOpacity>
  927. </View>
  928. </ImageBackground>
  929. </View>
  930. );
  931. }
  932. }
  933.  
  934. class MiddleScreen extends React.Component {
  935. static navigationOptions = {
  936. title: "MiddlePage"
  937. };
  938.  
  939. constructor(props) {
  940. super(props);
  941. this.state = {
  942. isLoading: true
  943. };
  944. }
  945.  
  946. async componentWillMount() {
  947. const { navigate } = this.props.navigation;
  948.  
  949. this.props.navigation.dispatch(resetAction);
  950. }
  951.  
  952. render() {
  953. return <LoadingScreen />;
  954. }
  955. }
  956.  
  957. class HomeScreen extends React.Component {
  958. static navigationOptions = {
  959. title: "HomePage"
  960. };
  961.  
  962. constructor(props) {
  963. super(props);
  964. this.state = {
  965. isLoading: true
  966. };
  967. }
  968.  
  969. FetchCommonData = async () => {
  970. return fetch(
  971. config.hostProtocol +
  972. config.hostName +
  973. config.APIBreakPoint +
  974. config.ApiTokenParam +
  975. config.APIToken +
  976. config.actionCommonData
  977. )
  978. .then(response => response.json())
  979. .then(responseJson => {
  980. this.setState(
  981. {
  982. isLoading: false,
  983. JSON_Array: responseJson
  984. },
  985. async function() {
  986. try {
  987. await AsyncStorage.setItem(
  988. "@CommonData:offersCounter",
  989. JSON.stringify(responseJson.offers_counter)
  990. );
  991. await AsyncStorage.setItem(
  992. "@CommonData:offersArray",
  993. JSON.stringify(responseJson.offers)
  994. );
  995. await AsyncStorage.setItem(
  996. "@CommonData:scheduleArray",
  997. JSON.stringify(responseJson.schedule)
  998. );
  999. await AsyncStorage.setItem(
  1000. "@CommonData:clubzonesArray",
  1001. JSON.stringify(responseJson.clubzones)
  1002. );
  1003. } catch (error) {
  1004. // Error saving data
  1005. }
  1006. }
  1007. );
  1008. })
  1009. .catch(error => {
  1010. console.error(error);
  1011. });
  1012. };
  1013.  
  1014. async componentWillMount() {
  1015. let isLoggedIn = await AsyncStorage.getItem("@User:isLoggedIn");
  1016. let firstName = await AsyncStorage.getItem("@User:firstName");
  1017. let lastName = await AsyncStorage.getItem("@User:lastName");
  1018. let userAvatar = await AsyncStorage.getItem("@User:userAvatar");
  1019. let clubCardType = await AsyncStorage.getItem("@User:clubCardType");
  1020. let userRole = await AsyncStorage.getItem("@User:userRole");
  1021. let lastOfferID = await AsyncStorage.getItem("@Common:lastOfferID");
  1022.  
  1023. this.FetchCommonData();
  1024.  
  1025. let offersCounter = await AsyncStorage.getItem("@CommonData:offersCounter");
  1026.  
  1027. if (isLoggedIn) {
  1028. this.setState({
  1029. isLoggedIn: isLoggedIn,
  1030. lastName: lastName,
  1031. firstName: firstName,
  1032. clubCardType: JSON.parse(clubCardType),
  1033. userAvatar: JSON.parse(userAvatar),
  1034. userRole: JSON.parse(userRole),
  1035. isLoading: true
  1036. });
  1037. }
  1038. this.setState({
  1039. isLoggedIn: isLoggedIn,
  1040. offersCounter: offersCounter,
  1041. isLoading: false
  1042. });
  1043. }
  1044.  
  1045. async componentDidMount() {
  1046. this.setState({
  1047. isLoading: false
  1048. });
  1049.  
  1050. let offersCounter = await AsyncStorage.getItem("@CommonData:offersCounter");
  1051.  
  1052. this.setState({
  1053. offersCounter: offersCounter,
  1054. isLoading: false
  1055. });
  1056. }
  1057.  
  1058. render() {
  1059. if (this.state.isLoading) {
  1060. return <LoadingScreen />;
  1061. }
  1062.  
  1063. if (this.state.userRole == "subscriber") {
  1064. return (
  1065. <View style={styles.fullScreenContainer}>
  1066. <ImageBackground
  1067. source={require("./images/menu.jpg")}
  1068. style={(styles.fullScreenImage, styles.fullScreenImageLeft)}
  1069. >
  1070. <StatusBar
  1071. backgroundColor="transparent"
  1072. barStyle="light-content"
  1073. translucent
  1074. />
  1075. <Image
  1076. source={require("./images/logonavigation.png")}
  1077. style={styles.navigationLogo}
  1078. />
  1079.  
  1080. <TouchableOpacity
  1081. onPress={() => {
  1082. const { navigate } = this.props.navigation;
  1083. navigate("OffersArchive", { isLoggedIn: false });
  1084. }}
  1085. style={styles.menuWrapper}
  1086. >
  1087. <Text style={styles.menuItem}>New Offers</Text>
  1088. <Text style={styles.menuOffersCounter}>
  1089. {this.state.offersCounter}
  1090. </Text>
  1091. </TouchableOpacity>
  1092.  
  1093. <TouchableOpacity
  1094. onPress={() => {
  1095. const { navigate } = this.props.navigation;
  1096. navigate("Schedule", { isLoggedIn: false });
  1097. }}
  1098. style={styles.menuWrapper}
  1099. >
  1100. <Text style={styles.menuItem}>Schedule</Text>
  1101. </TouchableOpacity>
  1102.  
  1103. <TouchableOpacity
  1104. onPress={() => {
  1105. const { navigate } = this.props.navigation;
  1106. navigate("TrainingsArchive", { isLoggedIn: false });
  1107. }}
  1108. style={styles.menuWrapper}
  1109. >
  1110. <Text style={styles.menuItem}>Club Zones</Text>
  1111. </TouchableOpacity>
  1112.  
  1113. <TouchableOpacity style={styles.menuWrapper}>
  1114. <Text style={styles.menuItem}>Messages</Text>
  1115. </TouchableOpacity>
  1116.  
  1117. <TouchableOpacity
  1118. onPress={() => {
  1119. const { navigate } = this.props.navigation;
  1120. navigate("Web", {
  1121. targetLink: "https://n71694.yclients.com/"
  1122. });
  1123. }}
  1124. style={styles.menuWrapper}
  1125. >
  1126. <Text style={styles.menuItem}>Spa&Beauty</Text>
  1127. </TouchableOpacity>
  1128.  
  1129. <View style={styles.actionLinksWrapper}>
  1130. <TouchableOpacity
  1131. onPress={() => {
  1132. const { navigate } = this.props.navigation;
  1133. navigate("Manager", { isLoggedIn: false });
  1134. }}
  1135. style={styles.menuWrapperSpecial}
  1136. >
  1137. <Text style={styles.menuItemSpecial}>Manager</Text>
  1138. </TouchableOpacity>
  1139.  
  1140. <TouchableOpacity
  1141. onPress={() => {
  1142. const { navigate } = this.props.navigation;
  1143. navigate("Trainers", { isLoggedIn: false });
  1144. }}
  1145. style={styles.menuWrapperSpecial}
  1146. >
  1147. <Text style={styles.menuItemSpecial}>Personal Trainers</Text>
  1148. </TouchableOpacity>
  1149. </View>
  1150.  
  1151. <TouchableOpacity
  1152. onPress={() => {
  1153. const { navigate } = this.props.navigation;
  1154. navigate("Profile", { UserID: this.state.userID });
  1155. }}
  1156. >
  1157. <View style={profile.userInfoBox}>
  1158. <Image
  1159. source={{ uri: this.state.userAvatar }}
  1160. style={profile.infoUserAvatar}
  1161. />
  1162.  
  1163. <Text style={profile.userInfoName}>
  1164. {this.state.firstName} {this.state.lastName}
  1165. </Text>
  1166. <Text style={profile.userInfoCard}>
  1167. {this.state.clubCardType}
  1168. </Text>
  1169. </View>
  1170. </TouchableOpacity>
  1171. </ImageBackground>
  1172. </View>
  1173. );
  1174. }
  1175. if (this.state.userRole == "manager") {
  1176. return (
  1177. <View style={styles.fullScreenContainer}>
  1178. <ImageBackground
  1179. source={require("./images/menu.jpg")}
  1180. style={(styles.fullScreenImage, styles.fullScreenImageLeft)}
  1181. >
  1182. <StatusBar
  1183. backgroundColor="transparent"
  1184. barStyle="light-content"
  1185. translucent
  1186. />
  1187. <Image
  1188. source={require("./images/logonavigation.png")}
  1189. style={styles.navigationLogo}
  1190. />
  1191.  
  1192. <TouchableOpacity
  1193. onPress={() => {
  1194. const { navigate } = this.props.navigation;
  1195. navigate("OffersArchive", { isLoggedIn: false });
  1196. }}
  1197. style={styles.menuWrapper}
  1198. >
  1199. <Text style={styles.menuItem}>New Offers</Text>
  1200. <Text style={styles.menuOffersCounter}>
  1201. {this.state.offersCounter}
  1202. </Text>
  1203. </TouchableOpacity>
  1204.  
  1205. <TouchableOpacity
  1206. onPress={() => {
  1207. const { navigate } = this.props.navigation;
  1208. navigate("Schedule", { isLoggedIn: false });
  1209. }}
  1210. style={styles.menuWrapper}
  1211. >
  1212. <Text style={styles.menuItem}>Schedule</Text>
  1213. </TouchableOpacity>
  1214.  
  1215. <TouchableOpacity
  1216. onPress={() => {
  1217. const { navigate } = this.props.navigation;
  1218. navigate("TrainingsArchive", { isLoggedIn: false });
  1219. }}
  1220. style={styles.menuWrapper}
  1221. >
  1222. <Text style={styles.menuItem}>Club Zones</Text>
  1223. </TouchableOpacity>
  1224.  
  1225. <TouchableOpacity style={styles.menuWrapper}>
  1226. <Text style={styles.menuItem}>Messages</Text>
  1227. </TouchableOpacity>
  1228.  
  1229. <TouchableOpacity
  1230. onPress={() => {
  1231. const { navigate } = this.props.navigation;
  1232. navigate("Web", {
  1233. targetLink: "https://n71694.yclients.com/"
  1234. });
  1235. }}
  1236. style={styles.menuWrapper}
  1237. >
  1238. <Text style={styles.menuItem}>Spa&Beauty</Text>
  1239. </TouchableOpacity>
  1240.  
  1241. <View style={styles.actionLinksWrapper}>
  1242. <TouchableOpacity
  1243. onPress={() => {
  1244. const { navigate } = this.props.navigation;
  1245. navigate("Clients", { isLoggedIn: false });
  1246. }}
  1247. style={styles.menuWrapperSpecial}
  1248. >
  1249. <Text style={styles.menuItemSpecial}>Clients List</Text>
  1250. </TouchableOpacity>
  1251.  
  1252. <TouchableOpacity
  1253. onPress={async () => {
  1254. try {
  1255. await AsyncStorage.removeItem("@User:isLoggedIn");
  1256. await AsyncStorage.removeItem("@User:userID");
  1257. await AsyncStorage.removeItem("@User:userRole");
  1258. // BackAndroid.exitApp();
  1259.  
  1260. const { navigate } = this.props.navigation;
  1261. navigate("Middle");
  1262. } catch (error) {
  1263. // Error saving data
  1264. const { navigate } = this.props.navigation;
  1265. navigate("Middle");
  1266. }
  1267. }}
  1268. style={styles.menuWrapperSpecial}
  1269. >
  1270. <Text style={styles.menuItemSpecial}>Log Out</Text>
  1271. </TouchableOpacity>
  1272. </View>
  1273.  
  1274. <TouchableOpacity
  1275. onPress={() => {
  1276. const { navigate } = this.props.navigation;
  1277. navigate("Profile", { UserID: this.state.userID });
  1278. }}
  1279. >
  1280. <View style={profile.userInfoBox}>
  1281. <Image
  1282. source={{ uri: this.state.userAvatar }}
  1283. style={profile.infoUserAvatar}
  1284. />
  1285.  
  1286. <Text style={profile.userInfoName}>
  1287. {this.state.firstName} {this.state.lastName}
  1288. </Text>
  1289. <Text style={profile.userInfoCard}>
  1290. {this.state.clubCardType}
  1291. </Text>
  1292. </View>
  1293. </TouchableOpacity>
  1294. </ImageBackground>
  1295. </View>
  1296. );
  1297. }
  1298.  
  1299. if (this.state.userRole == null) {
  1300. return (
  1301. <View style={styles.fullScreenContainer}>
  1302. <ImageBackground
  1303. source={require("./images/menu.jpg")}
  1304. style={(styles.fullScreenImage, styles.fullScreenImageLeft)}
  1305. >
  1306. <StatusBar
  1307. backgroundColor="transparent"
  1308. barStyle="light-content"
  1309. translucent
  1310. />
  1311. <Image
  1312. source={require("./images/logonavigation.png")}
  1313. style={styles.navigationLogo}
  1314. />
  1315.  
  1316. <TouchableOpacity
  1317. onPress={() => {
  1318. const { navigate } = this.props.navigation;
  1319. navigate("OffersArchive", { isLoggedIn: false });
  1320. }}
  1321. style={styles.menuWrapper}
  1322. >
  1323. <Text style={styles.menuItem}>New Offers</Text>
  1324. <Text style={styles.menuOffersCounter}>
  1325. {this.state.offersCounter}
  1326. </Text>
  1327. </TouchableOpacity>
  1328.  
  1329. <TouchableOpacity
  1330. onPress={() => {
  1331. const { navigate } = this.props.navigation;
  1332. navigate("Schedule", { isLoggedIn: false });
  1333. }}
  1334. style={styles.menuWrapper}
  1335. >
  1336. <Text style={styles.menuItem}>Schedule</Text>
  1337. </TouchableOpacity>
  1338.  
  1339. <TouchableOpacity
  1340. onPress={() => {
  1341. const { navigate } = this.props.navigation;
  1342. navigate("TrainingsArchive", { isLoggedIn: false });
  1343. }}
  1344. style={styles.menuWrapper}
  1345. >
  1346. <Text style={styles.menuItem}>Club Zones</Text>
  1347. </TouchableOpacity>
  1348.  
  1349. <TouchableOpacity style={styles.menuWrapper}>
  1350. <Text style={styles.menuItem}>Kids Club</Text>
  1351. </TouchableOpacity>
  1352.  
  1353. <TouchableOpacity
  1354. onPress={() => {
  1355. const { navigate } = this.props.navigation;
  1356. navigate("Web", {
  1357. targetLink: "https://n71694.yclients.com/"
  1358. });
  1359. }}
  1360. style={styles.menuWrapper}
  1361. >
  1362. <Text style={styles.menuItem}>Spa&Beauty</Text>
  1363. </TouchableOpacity>
  1364.  
  1365. <View style={styles.actionLinksWrapper}>
  1366. <TouchableOpacity
  1367. onPress={() => {
  1368. const { navigate } = this.props.navigation;
  1369. navigate("Virtual", { isLoggedIn: false });
  1370. }}
  1371. style={styles.menuWrapperSpecial}
  1372. >
  1373. <Text style={styles.menuItemSpecial}>Order a tour</Text>
  1374. </TouchableOpacity>
  1375.  
  1376. <TouchableOpacity
  1377. onPress={() => {
  1378. const { navigate } = this.props.navigation;
  1379. navigate("Faq", { isLoggedIn: false });
  1380. }}
  1381. style={styles.menuWrapperSpecial}
  1382. >
  1383. <Text style={styles.menuItemSpecial}>F.A.Q</Text>
  1384. </TouchableOpacity>
  1385. </View>
  1386.  
  1387. <View style={styles.guestWrapper}>
  1388. <TouchableOpacity
  1389. onPress={() => {
  1390. const { navigate } = this.props.navigation;
  1391. navigate("Login", { isLoggedIn: false });
  1392. }}
  1393. style={styles.guestLogin}
  1394. >
  1395. <Image
  1396. source={require("./images/guestlogin.png")}
  1397. style={styles.guestLoginIcon}
  1398. />
  1399. <Text style={styles.fullWidthButtonLabel}>Login as client</Text>
  1400. </TouchableOpacity>
  1401.  
  1402. <TouchableOpacity
  1403. style={styles.guestPhoneWrapper}
  1404. onPress={() => Communications.phonecall("022 21 00 21", true)}
  1405. >
  1406. <Image
  1407. source={require("./images/phone.png")}
  1408. style={styles.guestPhoneIcon}
  1409. />
  1410. <Text style={styles.guestPhoneText}>022 21 00 21</Text>
  1411. </TouchableOpacity>
  1412.  
  1413. <TouchableOpacity style={styles.guestAdressWrapper}>
  1414. <Image
  1415. source={require("./images/pointer.png")}
  1416. style={styles.guestAdressIcon}
  1417. />
  1418. <Text style={styles.guestAdressText}>str. Ghidighici, 5</Text>
  1419. </TouchableOpacity>
  1420. </View>
  1421. </ImageBackground>
  1422. </View>
  1423. );
  1424. } else {
  1425. return (
  1426. <View style={styles.guestWrapper}>
  1427. <TouchableOpacity
  1428. onPress={async () => {
  1429. try {
  1430. await AsyncStorage.removeItem("@User:isLoggedIn");
  1431. await AsyncStorage.removeItem("@User:userID");
  1432. await AsyncStorage.removeItem("@User:userRole");
  1433. // BackAndroid.exitApp();
  1434.  
  1435. const { navigate } = this.props.navigation;
  1436. navigate("Middle");
  1437. } catch (error) {
  1438. // Error saving data
  1439. const { navigate } = this.props.navigation;
  1440. navigate("Middle");
  1441. }
  1442. }}
  1443. style={profile.logoutWrapper}
  1444. >
  1445. <Text style={profile.logoutLabel}>Log Out</Text>
  1446. </TouchableOpacity>
  1447. </View>
  1448. );
  1449. }
  1450. }
  1451. }
  1452.  
  1453. class OffersArchiveScreen extends React.Component {
  1454. static navigationOptions = {
  1455. title: "OffersArchivePage"
  1456. };
  1457.  
  1458. constructor(props) {
  1459. super(props);
  1460. this.state = {
  1461. isLoading: true,
  1462. offersArray: []
  1463. };
  1464. }
  1465.  
  1466. async componentWillMount() {
  1467. let offersArray = await AsyncStorage.getItem("@CommonData:offersArray");
  1468.  
  1469. this.setState({
  1470. isLoading: false,
  1471. offersArray: JSON.parse(offersArray)
  1472. });
  1473. }
  1474.  
  1475. render() {
  1476. if (this.state.isLoading) {
  1477. return <LoadingScreen />;
  1478. }
  1479. let offersArray = this.state.offersArray;
  1480.  
  1481. return (
  1482. <View style={styles.fullScreenContainer}>
  1483. <StatusBar
  1484. backgroundColor="transparent"
  1485. barStyle="light-content"
  1486. translucent
  1487. />
  1488.  
  1489. <ImageBackground
  1490. source={require("./images/menu.jpg")}
  1491. style={offers.fullScreenImage}
  1492. >
  1493. <View style={offers.offersContainer}>
  1494. <Swiper
  1495. style={offers.swiper}
  1496. showsButtons={false}
  1497. dot={<View style={offers.swiperDot} />}
  1498. activeDot={<View style={offers.activeDot} />}
  1499. paginationStyle={offers.swiperPagination}
  1500. >
  1501. {offersArray.map((prop, key) => {
  1502. return (
  1503. <View style={offers.swiperWrapper} key={key}>
  1504. <View style={offers.swiperInnerContainer}>
  1505. <View style={offers.swiperInnerHeader}>
  1506. <TouchableOpacity
  1507. onPress={() => {
  1508. const { navigate } = this.props.navigation;
  1509. navigate("Offers", { offerID: prop.index });
  1510. }}
  1511. >
  1512. <Image
  1513. source={{ uri: prop.image_url }}
  1514. style={offers.swiperImage}
  1515. />
  1516. </TouchableOpacity>
  1517.  
  1518. <Text style={offers.swiperTriangle} />
  1519. </View>
  1520.  
  1521. <TouchableOpacity
  1522. onPress={() => {
  1523. const { navigate } = this.props.navigation;
  1524. navigate("Offers", { offerID: prop.index });
  1525. }}
  1526. >
  1527. <Text key={key} style={offers.swiperTitle}>
  1528. {prop.post_title}
  1529. </Text>
  1530. </TouchableOpacity>
  1531.  
  1532. <View style={offers.swiperInnerBody}>
  1533. <Text style={offers.swiperTitleDivider} />
  1534.  
  1535. <Text style={offers.swiperContent}>
  1536. {prop.post_excerpt}
  1537. </Text>
  1538. </View>
  1539. </View>
  1540. </View>
  1541. );
  1542. })}
  1543. </Swiper>
  1544. </View>
  1545. </ImageBackground>
  1546. </View>
  1547. );
  1548. }
  1549. }
  1550.  
  1551. class OffersScreen extends React.Component {
  1552. static navigationOptions = {
  1553. title: "OffersPage"
  1554. };
  1555.  
  1556. constructor(props) {
  1557. super(props);
  1558. this.state = {
  1559. isLoading: true
  1560. };
  1561. }
  1562.  
  1563. async componentWillMount() {
  1564. const { params } = this.props.navigation.state;
  1565.  
  1566. let offersArray = await AsyncStorage.getItem("@CommonData:offersArray");
  1567.  
  1568. this.setState({
  1569. isLoading: false,
  1570. offersArray: JSON.parse(offersArray),
  1571. offerID: params.offerID
  1572. });
  1573.  
  1574. // alert(offersArray);
  1575. }
  1576.  
  1577. async componentDidMount() {
  1578. return this.setState((isLoading: false));
  1579. }
  1580.  
  1581. render() {
  1582. let offersArray = this.state.offersArray;
  1583.  
  1584. if (this.state.isLoading) {
  1585. return <LoadingScreen />;
  1586. }
  1587.  
  1588. return (
  1589. <ScrollView style={single_offer.fullScreenContainer}>
  1590. <StatusBar
  1591. backgroundColor="transparent"
  1592. barStyle="light-content"
  1593. translucent
  1594. />
  1595. {offersArray.map((prop, key) => {
  1596. if (prop.index == this.state.offerID) {
  1597. return (
  1598. <View style={single_offer.offerWrapper} key={key}>
  1599. <ImageBackground
  1600. source={{ uri: prop.image_url }}
  1601. style={single_offer.offerImage}
  1602. >
  1603. <Text style={single_offer.offerTitle}>{prop.post_title}</Text>
  1604.  
  1605. <Text style={single_offer.offerTitleDivider} />
  1606.  
  1607. <Text style={single_offer.offerSubTitle}>
  1608. Niagara Fitness Club
  1609. </Text>
  1610.  
  1611. <Text style={single_offer.swiperTriangle} />
  1612. </ImageBackground>
  1613.  
  1614. <View style={single_offer.offerBody} key={key}>
  1615. <Content post_content={prop.post_content} />
  1616. </View>
  1617.  
  1618. <View style={single_offer.halfScreenContainer}>
  1619. <TouchableOpacity
  1620. onPress={() => {
  1621. const { navigate } = this.props.navigation;
  1622. navigate("Web", {
  1623. targetLink: prop.single_offer_action_link
  1624. });
  1625. }}
  1626. style={single_offer.halfWidthButtonBlue}
  1627. >
  1628. <Text style={[single_offer.fullWidthButtonLabel]}>
  1629. Register online
  1630. </Text>
  1631. </TouchableOpacity>
  1632.  
  1633. <TouchableOpacity
  1634. onPress={() => {
  1635. const { navigate } = this.props.navigation;
  1636. navigate("Manager", {
  1637. targetLink: prop.single_offer_action_link
  1638. });
  1639. }}
  1640. style={single_offer.halfWidthButton}
  1641. >
  1642. <Text style={single_offer.fullWidthButtonLabel}>
  1643. Call Manager
  1644. </Text>
  1645. </TouchableOpacity>
  1646. </View>
  1647. </View>
  1648. );
  1649. } else {
  1650. return;
  1651. }
  1652. })}
  1653. </ScrollView>
  1654. );
  1655. }
  1656. }
  1657.  
  1658. class TrainingsArchiveScreen extends React.Component {
  1659. static navigationOptions = {
  1660. title: "TrainingsArchivePage"
  1661. };
  1662.  
  1663. constructor(props) {
  1664. super(props);
  1665. this.state = {
  1666. isLoading: true,
  1667. offersArray: []
  1668. };
  1669. }
  1670.  
  1671. async componentWillMount() {
  1672. let clubzonesArray = await AsyncStorage.getItem(
  1673. "@CommonData:clubzonesArray"
  1674. );
  1675.  
  1676. this.setState({
  1677. isLoading: false,
  1678. clubzonesArray: JSON.parse(clubzonesArray)
  1679. });
  1680. }
  1681.  
  1682. render() {
  1683. if (this.state.isLoading) {
  1684. return <LoadingScreen />;
  1685. }
  1686.  
  1687. let clubzonesArray = this.state.clubzonesArray;
  1688.  
  1689. return (
  1690. <ScrollView style={zones.a}>
  1691. <StatusBar
  1692. backgroundColor="transparent"
  1693. barStyle="light-content"
  1694. translucent
  1695. />
  1696. <View style={clients.header}>
  1697. <Text style={clients.clientsTitle}>Club Zones</Text>
  1698. </View>
  1699. <View style={zones.wrapper}>
  1700. {clubzonesArray.map((prop, key) => {
  1701. return (
  1702. <View style={zones.column} key={key}>
  1703. <View style={zones.item}>
  1704. <TouchableOpacity
  1705. onPress={() => {
  1706. const { navigate } = this.props.navigation;
  1707. navigate("Offers", { offerID: prop.index });
  1708. }}
  1709. >
  1710. <ImageBackground
  1711. source={{ uri: prop.image_url }}
  1712. style={zones.image}
  1713. />
  1714. </TouchableOpacity>
  1715. <View style={zones.itemContent}>
  1716. <Text style={zones.title}>{prop.post_title}</Text>
  1717. <View style={zones.dotsWrapper}>
  1718. <Text style={zones.dots} />
  1719. <Text style={zones.dots} />
  1720. <Text style={zones.dots} />
  1721. </View>
  1722. </View>
  1723. </View>
  1724. </View>
  1725. );
  1726. })}
  1727. </View>
  1728. </ScrollView>
  1729. );
  1730. }
  1731. }
  1732.  
  1733. class TrainingsScreen extends React.Component {
  1734. static navigationOptions = {
  1735. title: "TrainingsPage"
  1736. };
  1737.  
  1738. constructor(props) {
  1739. super(props);
  1740. this.state = {
  1741. isLoading: true
  1742. };
  1743. }
  1744.  
  1745. async componentWillMount() {
  1746. this.setState({
  1747. isLoading: false
  1748. });
  1749. }
  1750.  
  1751. render() {
  1752. if (this.state.isLoading) {
  1753. return <LoadingScreen />;
  1754. }
  1755.  
  1756. return (
  1757. <View>
  1758. <StatusBar
  1759. backgroundColor="transparent"
  1760. barStyle="light-content"
  1761. translucent
  1762. />
  1763.  
  1764. <Text>Trainings Screen</Text>
  1765. </View>
  1766. );
  1767. }
  1768. }
  1769.  
  1770. class ScheduleScreen extends React.Component {
  1771. static navigationOptions = {
  1772. title: "SchedulePage"
  1773. };
  1774.  
  1775. constructor(props) {
  1776. super(props);
  1777. this.state = {
  1778. isLoading: true
  1779. };
  1780. }
  1781.  
  1782. async componentWillMount() {
  1783. let scheduleArray = await AsyncStorage.getItem("@CommonData:scheduleArray");
  1784.  
  1785. this.setState({
  1786. isLoading: false,
  1787. index: 4,
  1788. scheduleArray: JSON.parse(scheduleArray)
  1789. });
  1790. }
  1791.  
  1792. render() {
  1793. if (this.state.isLoading) {
  1794. return <LoadingScreen />;
  1795. }
  1796. let scheduleArray = this.state.scheduleArray;
  1797. let scheduleArrayDay = scheduleArray[this.state.index].items;
  1798.  
  1799. return (
  1800. <ScrollView style={schedule.fullScreenContainer}>
  1801. <StatusBar
  1802. backgroundColor="transparent"
  1803. barStyle="light-content"
  1804. translucent
  1805. />
  1806.  
  1807. <ImageBackground
  1808. source={require("./images/header_profile.jpg")}
  1809. style={schedule.monthView}
  1810. >
  1811. <View style={schedule.headerWrapper}>
  1812. <Text style={schedule.headerTitle}>April</Text>
  1813. <Text style={schedule.headerDivider} />
  1814. </View>
  1815. <View style={schedule.weekView}>
  1816. <TouchableOpacity
  1817. onPress={() =>
  1818. this.setState({
  1819. index: 0
  1820. })
  1821. }
  1822. style={schedule.singlelWrapperAction}
  1823. >
  1824. <Day style={schedule.dayInactive} index="1" number="26" />
  1825. </TouchableOpacity>
  1826. <TouchableOpacity
  1827. onPress={() =>
  1828. this.setState({
  1829. index: 1
  1830. })
  1831. }
  1832. style={schedule.singlelWrapperAction}
  1833. >
  1834. <Day style={schedule.dayInactive} index="2" number="27" />
  1835. </TouchableOpacity>
  1836. <TouchableOpacity
  1837. onPress={() =>
  1838. this.setState({
  1839. index: 2
  1840. })
  1841. }
  1842. style={schedule.singlelWrapperAction}
  1843. >
  1844. <Day style={schedule.dayInactive} index="3" number="28" />
  1845. </TouchableOpacity>
  1846. <TouchableOpacity
  1847. onPress={() =>
  1848. this.setState({
  1849. index: 3
  1850. })
  1851. }
  1852. style={schedule.singlelWrapperAction}
  1853. >
  1854. <Day style={schedule.dayInactive} index="4" number="29" />
  1855. </TouchableOpacity>
  1856. <TouchableOpacity
  1857. onPress={() =>
  1858. this.setState({
  1859. index: 4
  1860. })
  1861. }
  1862. style={schedule.singlelWrapperAction}
  1863. >
  1864. <Day style={schedule.dayCurrent} index="5" number="30" />
  1865. </TouchableOpacity>
  1866. <TouchableOpacity
  1867. onPress={() =>
  1868. this.setState({
  1869. index: 5
  1870. })
  1871. }
  1872. style={schedule.singlelWrapperAction}
  1873. >
  1874. <Day style={schedule.dayInactive} index="6" number="31" />
  1875. </TouchableOpacity>
  1876. <TouchableOpacity
  1877. onPress={() =>
  1878. this.setState({
  1879. index: 6
  1880. })
  1881. }
  1882. style={schedule.singlelWrapperAction}
  1883. >
  1884. <Day style={schedule.dayActive} index="7" number="01" />
  1885. </TouchableOpacity>
  1886. </View>
  1887.  
  1888. <View style={schedule.weekView}>
  1889. <TouchableOpacity
  1890. onPress={() =>
  1891. this.setState({
  1892. index: 0
  1893. })
  1894. }
  1895. style={schedule.singlelWrapperAction}
  1896. >
  1897. <Day style={schedule.dayActive} index="1" number="02" />
  1898. </TouchableOpacity>
  1899. <TouchableOpacity
  1900. onPress={() =>
  1901. this.setState({
  1902. index: 1
  1903. })
  1904. }
  1905. style={schedule.singlelWrapperAction}
  1906. >
  1907. <Day style={schedule.dayActive} index="2" number="03" />
  1908. </TouchableOpacity>
  1909. <TouchableOpacity
  1910. onPress={() =>
  1911. this.setState({
  1912. index: 2
  1913. })
  1914. }
  1915. style={schedule.singlelWrapperAction}
  1916. >
  1917. <Day style={schedule.dayActive} index="3" number="04" />
  1918. </TouchableOpacity>
  1919. <TouchableOpacity
  1920. onPress={() =>
  1921. this.setState({
  1922. index: 3
  1923. })
  1924. }
  1925. style={schedule.singlelWrapperAction}
  1926. >
  1927. <Day style={schedule.dayActive} index="4" number="05" />
  1928. </TouchableOpacity>
  1929. <TouchableOpacity
  1930. onPress={() =>
  1931. this.setState({
  1932. index: 4
  1933. })
  1934. }
  1935. style={schedule.singlelWrapperAction}
  1936. >
  1937. <Day style={schedule.dayActive} index="5" number="06" />
  1938. </TouchableOpacity>
  1939. <TouchableOpacity
  1940. onPress={() =>
  1941. this.setState({
  1942. index: 5
  1943. })
  1944. }
  1945. style={schedule.singlelWrapperAction}
  1946. >
  1947. <Day style={schedule.dayActive} index="6" number="07" />
  1948. </TouchableOpacity>
  1949. <TouchableOpacity
  1950. onPress={() =>
  1951. this.setState({
  1952. index: 6
  1953. })
  1954. }
  1955. style={schedule.singlelWrapperAction}
  1956. >
  1957. <Day style={schedule.dayActive} index="7" number="08" />
  1958. </TouchableOpacity>
  1959. </View>
  1960.  
  1961. <View style={schedule.weekView}>
  1962. <TouchableOpacity
  1963. onPress={() =>
  1964. this.setState({
  1965. index: 0
  1966. })
  1967. }
  1968. style={schedule.singlelWrapperAction}
  1969. >
  1970. <Day style={schedule.dayActive} index="1" number="09" />
  1971. </TouchableOpacity>
  1972. <TouchableOpacity
  1973. onPress={() =>
  1974. this.setState({
  1975. index: 1
  1976. })
  1977. }
  1978. style={schedule.singlelWrapperAction}
  1979. >
  1980. <Day style={schedule.dayActive} index="2" number="10" />
  1981. </TouchableOpacity>
  1982. <TouchableOpacity
  1983. onPress={() =>
  1984. this.setState({
  1985. index: 2
  1986. })
  1987. }
  1988. style={schedule.singlelWrapperAction}
  1989. >
  1990. <Day style={schedule.dayActive} index="3" number="11" />
  1991. </TouchableOpacity>
  1992. <TouchableOpacity
  1993. onPress={() =>
  1994. this.setState({
  1995. index: 3
  1996. })
  1997. }
  1998. style={schedule.singlelWrapperAction}
  1999. >
  2000. <Day style={schedule.dayActive} index="4" number="12" />
  2001. </TouchableOpacity>
  2002. <TouchableOpacity
  2003. onPress={() =>
  2004. this.setState({
  2005. index: 4
  2006. })
  2007. }
  2008. style={schedule.singlelWrapperAction}
  2009. >
  2010. <Day style={schedule.dayActive} index="5" number="13" />
  2011. </TouchableOpacity>
  2012. <TouchableOpacity
  2013. onPress={() =>
  2014. this.setState({
  2015. index: 5
  2016. })
  2017. }
  2018. style={schedule.singlelWrapperAction}
  2019. >
  2020. <Day style={schedule.dayActive} index="6" number="14" />
  2021. </TouchableOpacity>
  2022. <TouchableOpacity
  2023. onPress={() =>
  2024. this.setState({
  2025. index: 6
  2026. })
  2027. }
  2028. style={schedule.singlelWrapperAction}
  2029. >
  2030. <Day style={schedule.dayActive} index="7" number="15" />
  2031. </TouchableOpacity>
  2032. </View>
  2033.  
  2034. <View style={schedule.weekView}>
  2035. <TouchableOpacity
  2036. onPress={() =>
  2037. this.setState({
  2038. index: 0
  2039. })
  2040. }
  2041. style={schedule.singlelWrapperAction}
  2042. >
  2043. <Day style={schedule.dayActive} index="1" number="16" />
  2044. </TouchableOpacity>
  2045. <TouchableOpacity
  2046. onPress={() =>
  2047. this.setState({
  2048. index: 1
  2049. })
  2050. }
  2051. style={schedule.singlelWrapperAction}
  2052. >
  2053. <Day style={schedule.dayActive} index="2" number="17" />
  2054. </TouchableOpacity>
  2055. <TouchableOpacity
  2056. onPress={() =>
  2057. this.setState({
  2058. index: 2
  2059. })
  2060. }
  2061. style={schedule.singlelWrapperAction}
  2062. >
  2063. <Day style={schedule.dayActive} index="3" number="18" />
  2064. </TouchableOpacity>
  2065. <TouchableOpacity
  2066. onPress={() =>
  2067. this.setState({
  2068. index: 3
  2069. })
  2070. }
  2071. style={schedule.singlelWrapperAction}
  2072. >
  2073. <Day style={schedule.dayActive} index="4" number="19" />
  2074. </TouchableOpacity>
  2075. <TouchableOpacity
  2076. onPress={() =>
  2077. this.setState({
  2078. index: 4
  2079. })
  2080. }
  2081. style={schedule.singlelWrapperAction}
  2082. >
  2083. <Day style={schedule.dayActive} index="5" number="20" />
  2084. </TouchableOpacity>
  2085. <TouchableOpacity
  2086. onPress={() =>
  2087. this.setState({
  2088. index: 5
  2089. })
  2090. }
  2091. style={schedule.singlelWrapperAction}
  2092. >
  2093. <Day style={schedule.dayActive} index="6" number="21" />
  2094. </TouchableOpacity>
  2095. <TouchableOpacity
  2096. onPress={() =>
  2097. this.setState({
  2098. index: 6
  2099. })
  2100. }
  2101. style={schedule.singlelWrapperAction}
  2102. >
  2103. <Day style={schedule.dayActive} index="7" number="22" />
  2104. </TouchableOpacity>
  2105. </View>
  2106.  
  2107. <View style={schedule.weekView}>
  2108. <TouchableOpacity
  2109. onPress={() =>
  2110. this.setState({
  2111. index: 0
  2112. })
  2113. }
  2114. style={schedule.singlelWrapperAction}
  2115. >
  2116. <Day style={schedule.dayActive} index="1" number="23" />
  2117. </TouchableOpacity>
  2118. <TouchableOpacity
  2119. onPress={() =>
  2120. this.setState({
  2121. index: 1
  2122. })
  2123. }
  2124. style={schedule.singlelWrapperAction}
  2125. >
  2126. <Day style={schedule.dayActive} index="2" number="24" />
  2127. </TouchableOpacity>
  2128. <TouchableOpacity
  2129. onPress={() =>
  2130. this.setState({
  2131. index: 2
  2132. })
  2133. }
  2134. style={schedule.singlelWrapperAction}
  2135. >
  2136. <Day style={schedule.dayActive} index="3" number="25" />
  2137. </TouchableOpacity>
  2138. <TouchableOpacity
  2139. onPress={() =>
  2140. this.setState({
  2141. index: 3
  2142. })
  2143. }
  2144. style={schedule.singlelWrapperAction}
  2145. >
  2146. <Day style={schedule.dayActive} index="4" number="26" />
  2147. </TouchableOpacity>
  2148. <TouchableOpacity
  2149. onPress={() =>
  2150. this.setState({
  2151. index: 4
  2152. })
  2153. }
  2154. style={schedule.singlelWrapperAction}
  2155. >
  2156. <Day style={schedule.dayActive} index="5" number="27" />
  2157. </TouchableOpacity>
  2158. <TouchableOpacity
  2159. onPress={() =>
  2160. this.setState({
  2161. index: 5
  2162. })
  2163. }
  2164. style={schedule.singlelWrapperAction}
  2165. >
  2166. <Day style={schedule.dayActive} index="6" number="28" />
  2167. </TouchableOpacity>
  2168. <TouchableOpacity
  2169. onPress={() =>
  2170. this.setState({
  2171. index: 6
  2172. })
  2173. }
  2174. style={schedule.singlelWrapperAction}
  2175. >
  2176. <Day style={schedule.dayActive} index="7" number="29" />
  2177. </TouchableOpacity>
  2178. </View>
  2179.  
  2180. <View style={schedule.weekView}>
  2181. <TouchableOpacity
  2182. onPress={() =>
  2183. this.setState({
  2184. index: 0
  2185. })
  2186. }
  2187. style={schedule.singlelWrapperAction}
  2188. >
  2189. <Day style={schedule.dayActive} index="1" number="30" />
  2190. </TouchableOpacity>
  2191. <TouchableOpacity
  2192. onPress={() =>
  2193. this.setState({
  2194. index: 1
  2195. })
  2196. }
  2197. style={schedule.singlelWrapperAction}
  2198. >
  2199. <Day style={schedule.dayInactive} index="2" number="01" />
  2200. </TouchableOpacity>
  2201. <TouchableOpacity
  2202. onPress={() =>
  2203. this.setState({
  2204. index: 2
  2205. })
  2206. }
  2207. style={schedule.singlelWrapperAction}
  2208. >
  2209. <Day style={schedule.dayInactive} index="3" number="02" />
  2210. </TouchableOpacity>
  2211. <TouchableOpacity
  2212. onPress={() =>
  2213. this.setState({
  2214. index: 3
  2215. })
  2216. }
  2217. style={schedule.singlelWrapperAction}
  2218. >
  2219. <Day style={schedule.dayInactive} index="4" number="03" />
  2220. </TouchableOpacity>
  2221. <TouchableOpacity
  2222. onPress={() =>
  2223. this.setState({
  2224. index: 4
  2225. })
  2226. }
  2227. style={schedule.singlelWrapperAction}
  2228. >
  2229. <Day style={schedule.dayInactive} index="5" number="04" />
  2230. </TouchableOpacity>
  2231. <TouchableOpacity
  2232. onPress={() =>
  2233. this.setState({
  2234. index: 5
  2235. })
  2236. }
  2237. style={schedule.singlelWrapperAction}
  2238. >
  2239. <Day style={schedule.dayInactive} index="6" number="05" />
  2240. </TouchableOpacity>
  2241. <TouchableOpacity
  2242. onPress={() =>
  2243. this.setState({
  2244. index: 6
  2245. })
  2246. }
  2247. style={schedule.singlelWrapperAction}
  2248. >
  2249. <Day style={schedule.dayInactive} index="7" number="06" />
  2250. </TouchableOpacity>
  2251. </View>
  2252. </ImageBackground>
  2253.  
  2254. <View style={schedule.listWrapper}>
  2255. {scheduleArrayDay.map((prop, key) => {
  2256. return (
  2257. <View style={schedule.listSingle} key={key}>
  2258. <Text style={schedule.listSingleTime}>
  2259. {prop.training_time}
  2260. </Text>
  2261. <View style={schedule.listSingleDec}>
  2262. <Text style={schedule.listSingleDecRound} />
  2263. <Text style={schedule.listSingleDecLine} />
  2264. <Text style={schedule.listSingleDecLine} />
  2265. <Text style={schedule.listSingleDecLine} />
  2266. </View>
  2267. <Text style={schedule.listSingleTitle}>
  2268. {prop.training_title}
  2269. </Text>
  2270. <View style={schedule.listSinglePlaceWrapper}>
  2271. <Text style={schedule.listSinglePlaceLabel}>Location:</Text>
  2272. <Text style={schedule.listSinglePlace}>
  2273. {prop.training_place}
  2274. </Text>
  2275. </View>
  2276. </View>
  2277. );
  2278. })}
  2279. </View>
  2280. </ScrollView>
  2281. );
  2282. }
  2283. }
  2284.  
  2285. class ClientsScreen extends React.Component {
  2286. static navigationOptions = {
  2287. title: "ClientsPage"
  2288. };
  2289.  
  2290. constructor(props) {
  2291. super(props);
  2292. this.state = {
  2293. isLoading: true
  2294. };
  2295. }
  2296.  
  2297. async componentWillMount() {
  2298. let clientsArray = await AsyncStorage.getItem("@User:signedClients");
  2299.  
  2300. this.setState({
  2301. isLoading: false,
  2302. clientsArray: JSON.parse(clientsArray)
  2303. });
  2304. }
  2305.  
  2306. render() {
  2307. if (this.state.isLoading) {
  2308. return <LoadingScreen />;
  2309. }
  2310. let clientsArray = this.state.clientsArray;
  2311. return (
  2312. <ScrollView style={clients.fullScreenContainer}>
  2313. <StatusBar
  2314. backgroundColor="transparent"
  2315. barStyle="light-content"
  2316. translucent
  2317. />
  2318.  
  2319. <View style={clients.header}>
  2320. <Text style={clients.clientsTitle}>Clients List</Text>
  2321. </View>
  2322.  
  2323. {clientsArray.map((prop, key) => {
  2324. return (
  2325. <View style={clients.listWrapper} key={key}>
  2326. <View style={clients.singlelWrapper}>
  2327. <TouchableOpacity
  2328. onPress={() => {
  2329. const { navigate } = this.props.navigation;
  2330. navigate("ManagerChat", {
  2331. clientToken: prop.user_token,
  2332. clientAvatar: prop.avatar,
  2333. clientDisplayName: prop.display_name
  2334. });
  2335. }}
  2336. style={clients.singlelWrapperAction}
  2337. >
  2338. <Image
  2339. source={{ uri: prop.avatar }}
  2340. style={clients.singleAvatar}
  2341. />
  2342. <View style={clients.singleContacts}>
  2343. <Text style={clients.singleName}>
  2344. {prop.user_firstname} {prop.user_lastname}
  2345. </Text>
  2346. <Text style={clients.singlelPhone}>{prop.nickname}</Text>
  2347. </View>
  2348. </TouchableOpacity>
  2349. </View>
  2350. </View>
  2351. );
  2352. })}
  2353. </ScrollView>
  2354. );
  2355. }
  2356. }
  2357.  
  2358. class TrainersScreen extends React.Component {
  2359. static navigationOptions = {
  2360. title: "TrainersPage"
  2361. };
  2362.  
  2363. constructor(props) {
  2364. super(props);
  2365. this.state = {
  2366. isLoading: true
  2367. };
  2368. }
  2369.  
  2370. async componentWillMount() {
  2371. let trainersArray = await AsyncStorage.getItem("@User:signedTrainer");
  2372.  
  2373. this.setState({
  2374. isLoading: false,
  2375. trainersArray: JSON.parse(trainersArray)
  2376. });
  2377. }
  2378.  
  2379. render() {
  2380. if (this.state.isLoading) {
  2381. return <LoadingScreen />;
  2382. }
  2383. let trainersArray = this.state.trainersArray;
  2384.  
  2385. return (
  2386. <ScrollView style={trainers.fullScreenContainer}>
  2387. <StatusBar
  2388. backgroundColor="transparent"
  2389. barStyle="light-content"
  2390. translucent
  2391. />
  2392.  
  2393. <View style={trainers.header}>
  2394. <Text style={trainers.trainersTitle}>Personal Trainers</Text>
  2395. </View>
  2396.  
  2397. {trainersArray.map((prop, key) => {
  2398. return (
  2399. <View style={trainers.listWrapper} key={key}>
  2400. <View style={trainers.singlelWrapper}>
  2401. <TouchableOpacity
  2402. onPress={() => {
  2403. const { navigate } = this.props.navigation;
  2404. navigate("ManagerChat", {
  2405. clientToken: prop.user_token,
  2406. clientAvatar: prop.avatar,
  2407. clientDisplayName: prop.display_name
  2408. });
  2409. }}
  2410. style={trainers.singlelWrapperAction}
  2411. >
  2412. <Image
  2413. source={{ uri: prop.avatar }}
  2414. style={trainers.singleAvatar}
  2415. />
  2416. <View style={trainers.singleContacts}>
  2417. <Text style={trainers.singleName}>
  2418. {prop.user_firstname} {prop.user_lastname}
  2419. </Text>
  2420. <Text style={trainers.singlelPhone}>{prop.nickname}</Text>
  2421. </View>
  2422. </TouchableOpacity>
  2423. </View>
  2424. </View>
  2425. );
  2426. })}
  2427. </ScrollView>
  2428. );
  2429. }
  2430. }
  2431.  
  2432. class ManagerScreen extends React.Component {
  2433. static navigationOptions = {
  2434. title: "ManagerPage"
  2435. };
  2436.  
  2437. constructor(props) {
  2438. super(props);
  2439. this.state = {
  2440. isLoading: true
  2441. };
  2442. }
  2443.  
  2444. async componentWillMount() {
  2445. let signedManager = await AsyncStorage.getItem("@User:signedManager");
  2446.  
  2447. this.setState({
  2448. isLoading: false,
  2449. userManager: JSON.parse(signedManager)
  2450. });
  2451. }
  2452.  
  2453. render() {
  2454. if (this.state.isLoading) {
  2455. return <LoadingScreen />;
  2456. }
  2457.  
  2458. return (
  2459. <ScrollView style={manager.fullScreenContainer}>
  2460. <StatusBar
  2461. backgroundColor="transparent"
  2462. barStyle="light-content"
  2463. translucent
  2464. />
  2465.  
  2466. <View style={manager.managerHeader}>
  2467. <ImageBackground
  2468. source={{ uri: this.state.userManager.avatar }}
  2469. style={manager.managerImage}
  2470. >
  2471. <Text style={manager.managerTitle}>
  2472. {this.state.userManager.display_name}
  2473. </Text>
  2474.  
  2475. <Text style={manager.managerTitleDivider} />
  2476.  
  2477. <Text style={manager.managerSubTitle}></Text>
  2478.  
  2479. <Text style={manager.swiperTriangle} />
  2480. </ImageBackground>
  2481. </View>
  2482.  
  2483. <Text style={manager.managerSubTitle}>Sales Manager</Text>
  2484.  
  2485. <View style={manager.contactsWrapper}>
  2486. <TouchableOpacity
  2487. style={manager.contactItem}
  2488. onPress={() =>
  2489. Communications.phonecall(this.state.userManager.nickname, true)
  2490. }
  2491. >
  2492. <Image
  2493. source={require("./images/mobile_phone.png")}
  2494. style={manager.contactIcon}
  2495. />
  2496. <Text style={manager.contactText}>
  2497. {this.state.userManager.nickname}
  2498. </Text>
  2499. </TouchableOpacity>
  2500.  
  2501. <TouchableOpacity
  2502. style={manager.contactItem}
  2503. onPress={() =>
  2504. Communications.email(
  2505. [this.state.userManager.user_email],
  2506. null,
  2507. null,
  2508. null,
  2509. null
  2510. )
  2511. }
  2512. >
  2513. <Image
  2514. source={require("./images/mail.png")}
  2515. style={manager.contactIcon}
  2516. />
  2517. <Text style={manager.contactText}>
  2518. {this.state.userManager.user_email}
  2519. </Text>
  2520. </TouchableOpacity>
  2521.  
  2522. <TouchableOpacity
  2523. style={manager.contactItem}
  2524. onPress={() => Communications.phonecall("022 01 10 21", true)}
  2525. >
  2526. <Image
  2527. source={require("./images/local_phone.png")}
  2528. style={manager.contactIcon}
  2529. />
  2530. <Text style={manager.contactText}>022 01 10 21</Text>
  2531. </TouchableOpacity>
  2532.  
  2533. <View style={styles.halfScreenContainer}>
  2534. <TouchableOpacity
  2535. onPress={() => {
  2536. const { navigate } = this.props.navigation;
  2537. navigate("Chat", {
  2538. chatToken: this.state.userManager.user_token
  2539. });
  2540. }}
  2541. style={styles.halfWidthButton}
  2542. >
  2543. <Text style={[styles.fullWidthButtonLabel]}>Chat</Text>
  2544. </TouchableOpacity>
  2545.  
  2546. <TouchableOpacity
  2547. onPress={() =>
  2548. Communications.phonecall(this.state.userManager.nickname, true)
  2549. }
  2550. style={styles.halfWidthButtonBlue}
  2551. >
  2552. <Text style={styles.fullWidthButtonLabel}>Call Manager</Text>
  2553. </TouchableOpacity>
  2554. </View>
  2555. </View>
  2556. </ScrollView>
  2557. );
  2558. }
  2559. }
  2560.  
  2561. class ProfileScreen extends React.Component {
  2562. static navigationOptions = {
  2563. title: "ProfilePage"
  2564. };
  2565.  
  2566. constructor(props) {
  2567. super(props);
  2568. this.state = {
  2569. isLoading: true
  2570. };
  2571. }
  2572.  
  2573. async componentWillMount() {
  2574. let isLoggedIn = await AsyncStorage.getItem("@User:isLoggedIn");
  2575. let firstName = await AsyncStorage.getItem("@User:firstName");
  2576. let lastName = await AsyncStorage.getItem("@User:lastName");
  2577. let userSex = await AsyncStorage.getItem("@User:userSex");
  2578. let userAvatar = await AsyncStorage.getItem("@User:userAvatar");
  2579. let mobilePhone = await AsyncStorage.getItem("@User:mobilePhone");
  2580. let clubCardType = await AsyncStorage.getItem("@User:clubCardType");
  2581. let birthdayDate = await AsyncStorage.getItem("@User:birthdayDate");
  2582. let email = await AsyncStorage.getItem("@User:email");
  2583.  
  2584. if (isLoggedIn) {
  2585. this.setState({
  2586. isLoggedIn: isLoggedIn,
  2587. lastName: lastName,
  2588. firstName: firstName,
  2589. userSex: JSON.parse(userSex),
  2590. userAvatar: JSON.parse(userAvatar),
  2591. mobilePhone: JSON.parse(mobilePhone),
  2592. clubCardType: JSON.parse(clubCardType),
  2593. birthdayDate: JSON.parse(birthdayDate),
  2594. email: JSON.parse(email),
  2595. isLoading: true,
  2596. editUserLabelEdit: '',
  2597. editInputMode: '',
  2598. });
  2599. }
  2600. this.setState({
  2601. isLoggedIn: isLoggedIn,
  2602. isLoading: false
  2603. });
  2604. }
  2605.  
  2606. render() {
  2607. if (this.state.isLoading) {
  2608. return <LoadingScreen />;
  2609. }
  2610.  
  2611. return (
  2612. <View style={styles.fullScreenContainer}>
  2613. <StatusBar
  2614. backgroundColor="transparent"
  2615. barStyle="light-content"
  2616. translucent
  2617. />
  2618.  
  2619. <ImageBackground
  2620. source={require("./images/header_profile.jpg")}
  2621. style={profile.headerBackground}
  2622. >
  2623. <Image
  2624. source={{ uri: this.state.userAvatar }}
  2625. style={profile.profileAvatar}
  2626. />
  2627. </ImageBackground>
  2628.  
  2629. <ScrollView style={profile.ProfileWrapper}>
  2630. <View style={profile.infoboxUser}>
  2631. <Text style={[profile.infoboxUserLabel]}>Name</Text>
  2632. <Text style={[profile.infoboxUserValue]}>
  2633. {this.state.firstName} {this.state.lastName}
  2634. </Text>
  2635.  
  2636. </View>
  2637.  
  2638. <View style={profile.infoboxUser}>
  2639. <Text style={[profile.infoboxUserLabel]}>Email</Text>
  2640. <Text style={[profile.infoboxUserValue, this.state.editUserValueEdit]}>{this.state.email}</Text>
  2641.  
  2642. <TextInput
  2643. value={this.state.email}
  2644. style={[profile.infoboxUserInput, this.state.editInputMode]}
  2645. underlineColorAndroid="transparent"
  2646. placeholder="Type something nice"
  2647. onChangeText={text => this.setState({ email: text })}
  2648. />
  2649. </View>
  2650.  
  2651. <View style={profile.infoboxUser}>
  2652. <Text style={[profile.infoboxUserLabel]}>Phone number</Text>
  2653. <Text style={[profile.infoboxUserValue, this.state.editUserValueEdit]}>
  2654. {this.state.mobilePhone}
  2655. </Text>
  2656. <TextInput
  2657. value={this.state.mobilePhone}
  2658. style={[profile.infoboxUserInput, this.state.editInputMode]}
  2659. underlineColorAndroid="transparent"
  2660. placeholder="Type something nice"
  2661. onChangeText={text => this.setState({ mobilePhone: text })}
  2662. />
  2663. </View>
  2664.  
  2665. <View style={profile.infoboxUser}>
  2666. <Text style={[profile.infoboxUserLabel]}>Sex</Text>
  2667. <Text style={[profile.infoboxUserValue]}>{this.state.userSex}</Text>
  2668. </View>
  2669.  
  2670. <View style={profile.infoboxUser}>
  2671. <Text style={[profile.infoboxUserLabel]}>Club Card</Text>
  2672. <Text style={[profile.infoboxUserValue]}>
  2673. {this.state.clubCardType}
  2674. </Text>
  2675. </View>
  2676.  
  2677. <View style={profile.infoboxUser}>
  2678. <Text style={[profile.infoboxUserLabel]}>Your birthday</Text>
  2679. <Text style={[profile.infoboxUserValue]}>
  2680. {this.state.birthdayDate}
  2681. </Text>
  2682. </View>
  2683.  
  2684. <TouchableOpacity
  2685. onPress={async () => {
  2686. try {
  2687. await AsyncStorage.removeItem("@User:isLoggedIn");
  2688. await AsyncStorage.removeItem("@User:userID");
  2689. await AsyncStorage.removeItem("@User:userRole");
  2690. // BackAndroid.exitApp();
  2691.  
  2692. const { navigate } = this.props.navigation;
  2693. navigate("Middle");
  2694. } catch (error) {
  2695. // Error saving data
  2696. const { navigate } = this.props.navigation;
  2697. navigate("Middle");
  2698. }
  2699. }}
  2700. style={profile.logoutWrapper}
  2701. >
  2702. <Text style={profile.logoutLabel}>Log Out</Text>
  2703. </TouchableOpacity>
  2704.  
  2705. <TouchableOpacity
  2706. onPress={async () => {
  2707. this.setState({
  2708. editUserValueEdit: profile.infoboxUserValueEdit,
  2709. editInputMode: profile.infoboxUserInputEdit,
  2710. });
  2711. }}
  2712. style={profile.logoutWrapper}
  2713. >
  2714. <Text style={profile.logoutLabel}>Edit</Text>
  2715. </TouchableOpacity>
  2716. </ScrollView>
  2717. </View>
  2718. );
  2719. }
  2720. }
  2721.  
  2722. /*
  2723. * Navigation array ( Start )
  2724. */
  2725. const NiagaraApp = StackNavigator({
  2726. Home: {
  2727. screen: HomeScreen,
  2728. headerMode: "none",
  2729. headerLeft: null,
  2730. header: null,
  2731. navigationOptions: {
  2732. header: null,
  2733. headerLeft: null
  2734. }
  2735. },
  2736. Web: {
  2737. screen: WebScreen,
  2738. headerMode: "none",
  2739. headerLeft: null,
  2740. header: null,
  2741. navigationOptions: {
  2742. header: null,
  2743. headerLeft: null
  2744. }
  2745. },
  2746. Login: {
  2747. screen: LoginScreen,
  2748. headerMode: "none",
  2749. headerLeft: null,
  2750. header: null,
  2751. navigationOptions: {
  2752. header: null,
  2753. headerLeft: null
  2754. }
  2755. },
  2756. OffersArchive: {
  2757. screen: OffersArchiveScreen,
  2758. headerLeft: null,
  2759. headerMode: "none",
  2760. header: null,
  2761. navigationOptions: {
  2762. header: null,
  2763. headerLeft: null
  2764. }
  2765. },
  2766. Offers: {
  2767. screen: OffersScreen,
  2768. headerLeft: null,
  2769. headerMode: "none",
  2770. header: null,
  2771. navigationOptions: {
  2772. header: null,
  2773. headerLeft: null
  2774. }
  2775. },
  2776. TrainingsArchive: {
  2777. screen: TrainingsArchiveScreen,
  2778. headerLeft: null,
  2779. headerMode: "none",
  2780. header: null,
  2781. navigationOptions: {
  2782. header: null,
  2783. headerLeft: null
  2784. }
  2785. },
  2786. Trainings: {
  2787. screen: TrainingsScreen,
  2788. headerLeft: null,
  2789. headerMode: "none",
  2790. header: null,
  2791. navigationOptions: {
  2792. header: null,
  2793. headerLeft: null
  2794. }
  2795. },
  2796. Schedule: {
  2797. screen: ScheduleScreen,
  2798. headerLeft: null,
  2799. headerMode: "none",
  2800. header: null,
  2801. navigationOptions: {
  2802. header: null,
  2803. headerLeft: null
  2804. }
  2805. },
  2806. Manager: {
  2807. screen: ManagerScreen,
  2808. headerLeft: null,
  2809. headerMode: "none",
  2810. header: null,
  2811. navigationOptions: {
  2812. header: null,
  2813. headerLeft: null
  2814. }
  2815. },
  2816. Clients: {
  2817. screen: ClientsScreen,
  2818. headerLeft: null,
  2819. headerMode: "none",
  2820. header: null,
  2821. navigationOptions: {
  2822. header: null,
  2823. headerLeft: null
  2824. }
  2825. },
  2826. Trainers: {
  2827. screen: TrainersScreen,
  2828. headerLeft: null,
  2829. headerMode: "none",
  2830. header: null,
  2831. navigationOptions: {
  2832. header: null,
  2833. headerLeft: null
  2834. }
  2835. },
  2836. Profile: {
  2837. screen: ProfileScreen,
  2838. headerLeft: null,
  2839. headerMode: "none",
  2840. header: null,
  2841. navigationOptions: {
  2842. header: null,
  2843. headerLeft: null
  2844. }
  2845. },
  2846. Chat: {
  2847. screen: ChatScreen,
  2848. headerLeft: null,
  2849. headerMode: "none",
  2850. header: null,
  2851. navigationOptions: {
  2852. header: null,
  2853. headerLeft: null
  2854. }
  2855. },
  2856. Virtual: {
  2857. screen: VirtualScreen,
  2858. headerLeft: null,
  2859. headerMode: "none",
  2860. header: null,
  2861. navigationOptions: {
  2862. header: null,
  2863. headerLeft: null
  2864. }
  2865. },
  2866. Faq: {
  2867. screen: FaqScreen,
  2868. headerLeft: null,
  2869. headerMode: "none",
  2870. header: null,
  2871. navigationOptions: {
  2872. header: null,
  2873. headerLeft: null
  2874. }
  2875. },
  2876. ManagerChat: {
  2877. screen: ManagerChatScreen,
  2878. headerLeft: null,
  2879. headerMode: "none",
  2880. header: null,
  2881. navigationOptions: {
  2882. header: null,
  2883. headerLeft: null
  2884. }
  2885. },
  2886. Middle: {
  2887. screen: MiddleScreen,
  2888. headerLeft: null,
  2889. headerMode: "none",
  2890. header: null,
  2891. navigationOptions: {
  2892. header: null,
  2893. headerLeft: null
  2894. }
  2895. }
  2896. });
  2897. // Navigation array ( End )
  2898.  
  2899. export default NiagaraApp;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement