Monday, April 30, 2018

Python code to extract Title, Author, and Dewey from KOHA Database


sudo apt-get install python-bs4
sudo apt-get install python-mysqldb


Extract MARC data and insert it into new table

1) create the next table

DROP TABLE IF EXISTS `newmarcrecords`;
CREATE TABLE `NewMarcRecords` (
    `BibID` VARCHAR(30) NOT NULL ,
    `Leader` VARCHAR(30)  NULL ,
    `Title` VARCHAR(500) NOT NULL ,
    `Auther` VARCHAR(500)  NULL ,
    `Publisher` VARCHAR(500)  NULL ,
   
    `PublishYear` VARCHAR(500)  NULL ,
    `PublishLocation` VARCHAR(500)  NULL ,
    `Subject` VARCHAR(500)  NULL ,
    `Classification` VARCHAR(500)  NULL ,

    `RecordSource` VARCHAR(500)  NULL ,
    `Pages` VARCHAR(500)  NULL ,
    `URL` VARCHAR(500)  NULL ,
    `CoverURL` VARCHAR(500)  NULL ,
    `Price` VARCHAR(30) NULL ,
    `RecordStatus` VARCHAR(1) NULL ,
     PRIMARY KEY (`BibID`)) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ENGINE = InnoDB;


2) run the next Python code

# -*- coding: utf-8 -*-
#!/usr/bin/python

"""
DROP TABLE IF EXISTS `newmarcrecords`;
CREATE TABLE `NewMarcRecords` (
    `BibID` VARCHAR(30) NOT NULL ,
    `Leader` VARCHAR(30)  NULL ,
    `Title` VARCHAR(500) NOT NULL ,
    `Auther` VARCHAR(500)  NULL ,
    `Publisher` VARCHAR(500)  NULL ,
    `PublishYear` VARCHAR(500)  NULL ,
    `PublishLocation` VARCHAR(500)  NULL ,
    `Subject` VARCHAR(500)  NULL ,
    `Classification` VARCHAR(500)  NULL ,
    `RecordSource` VARCHAR(500)  NULL ,
    `Pages` VARCHAR(500)  NULL ,
    `URL` VARCHAR(500)  NULL ,
    `CoverURL` VARCHAR(500)  NULL ,
    `Price` VARCHAR(30) NULL ,
    `RecordStatus` VARCHAR(1) NULL ,
     PRIMARY KEY (`BibID`)) DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci ENGINE = InnoDB;
"""

import MySQLdb
from bs4 import BeautifulSoup

def GetValue( Tag,Feild ):
    check=y.find(tag=Tag)
    if check is not None:
        check = check.find(code=Feild)
        if check is not None:
            return check.get_text()
    return '---'



db = MySQLdb.connect(host="localhost",    # your host, usually localhost
                     user="root",         # your username
                     passwd="admin123",   # your password
                     db="koha" ,          # name of the data base
                     charset='utf8')         

# you must create a Cursor object. It will let
#  you execute all the queries you need
cur = db.cursor()

# Use all the SQL you like
cur.execute("SELECT biblionumber,metadata FROM `biblio_metadata` where CAST(biblionumber AS CHAR) not in (select BibID from NewMarcRecords)")

# print all the first cell of all the rows
for row in cur.fetchall():
    biblionumber= row[0]
    xmlMarc = row[1]
    y=BeautifulSoup(xmlMarc,"html5lib")
    Leader=y.record.leader.get_text()
    title=GetValue( "245","a")
    author=GetValue( "100","a")
    Publisher=GetValue( "260","a")
    PublishYear=GetValue( "260","c")
    PublishLocation=GetValue( "260","a")
    Subject=GetValue( "650","a")
    Classification=GetValue( "082","a")
    RecordSource=GetValue( "956","s")
    Pages=GetValue( "300","a")
    URL=GetValue( "856","u")
    CoverURL=GetValue( "956","u")
    Price=GetValue( "956","p")
    RecordStatus='0'

    try:
        cur.execute("""
                    INSERT INTO `newmarcrecords`  (`BibID`, `Leader`, `Title`, `Auther`, `Publisher`, `PublishYear`, `PublishLocation`
                    , `Subject`, `Classification`, `RecordSource`, `Pages`, `URL`, `CoverURL`, `Price`, `RecordStatus`)
                    VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
                    """
                    ,(biblionumber,Leader,title,author,Publisher,PublishYear,PublishLocation
                    ,Subject,Classification,RecordSource,Pages,URL,CoverURL,Price,RecordStatus))
        db.commit()
        print "success"
    except ValueError as e:
        db.rollback()
        print "Fail!"
        print e.strerror


    print title
    print "========================="

db.close()


Python to mysql

sudo apt-get install python-mysqldb


#!/usr/bin/python
import MySQLdb

db = MySQLdb.connect(host="localhost",    # your host, usually localhost
                     user="john",         # your username
                     passwd="megajonhy",  # your password
                     db="jonhydb")        # name of the data base

# you must create a Cursor object. It will let
#  you execute all the queries you need
cur = db.cursor()

# Use all the SQL you like
cur.execute("SELECT * FROM YOUR_TABLE_NAME")

# print all the first cell of all the rows
for row in cur.fetchall():
    print row[0]

db.close()

Use python to parse XML

Installing Beautiful Soup 

$ apt-get install python-bs4 (for Python 2)

$ apt-get install python3-bs4 (for Python 3)

OR

sudo apt-get install python-setuptools python-dev build-essential
sudo easy_install pip
sudo pip install --upgrade virtualenv

pip install beautifulsoup4

Example 1

from bs4 import BeautifulSoup

x="""<foo>
   <bar>
      <type foobar="1"/>
      <type foobar="2"/>
   </bar>
</foo>"""

y=BeautifulSoup(x)

>>> y.foo.bar.type["foobar"]
u'1'

>>> y.foo.bar.findAll("type")
[<type foobar="1"></type>, <type foobar="2"></type>]

>>> y.foo.bar.findAll("type")[0]["foobar"]
u'1'
>>> y.foo.bar.findAll("type")[1]["foobar"]
u'2'

Example 2





from bs4 import BeautifulSoup

x="""<marc:record>
    <marc:leader>00001cabaa2200000 a 4500</marc:leader>
    <marc:datafield tag="035" ind1=" " ind2=" ">
      <marc:subfield code="a">(kwc)7350</marc:subfield>
    </marc:datafield>
    <marc:datafield tag="050" ind1=" " ind2="4">
      <marc:subfield code="a">BL</marc:subfield>
    </marc:datafield>
    <marc:datafield tag="082" ind1=" " ind2=" ">
      <marc:subfield code="a">200</marc:subfield>
      <marc:subfield code="a">220</marc:subfield>
      <marc:subfield code="a">274</marc:subfield>
      <marc:subfield code="a">298</marc:subfield>
    </marc:datafield>
    <marc:datafield tag="100" ind1="1" ind2=" ">
      <marc:subfield code="a">الزحيلي، وهبة،</marc:subfield>
    </marc:datafield>
    <marc:datafield tag="245" ind1="2" ind2="0">
      <marc:subfield code="a">الجزاء و العقوبة في الإسلام /</marc:subfield>
      <marc:subfield code="c">وهبة الزحيلي.</marc:subfield>
    </marc:datafield>
  </marc:record>"""
y=BeautifulSoup(x,"html5lib")
title=y.find(tag="245").find(code="a").get_text()
author=y.find(tag="100").find(code="a").get_text()
Dewey=y.find(tag="082").find(code="a").get_text()
Dewey1=y.find(tag="082").find_all(code="a", limit=1)[0].get_text()
print title
print author
print Dewey
print Dewey1



For more information please visit 
https://www.crummy.com/software/BeautifulSoup/bs4/doc/


Sunday, April 29, 2018

What is React Native?


What is React Native?
- React Native libraries were announced by Facebook in 2015, providing the React architecture to native iOS, Android and Universal Windows Platform applications
- Framework for build mobile apps
- Build cross platform apps
- React native apps are not hybrid apps
- React native not run inside a webView
- Faster than Cordova/PhoneGap/ Ionic
- Open Source
- Develop using java script
- Application has the same look & feel of the same native apps.


How to start?

Download and install Node JS (~ 12 MB)   
https://nodejs.org/en/
Download React Libraries [Shell command]
npm install -g react-native-cli
Download Yarn [Optinal],  npm install –g yarn
(increase create new project performance by cache packages)
https://yarnpkg.com/en/

Development IDE (Visual Studio Code) (~34 MB)
https://code.visualstudio.com/

React extension tools to the IDE
https://marketplace.visualstudio.com/items?itemName=vsmobile.vscode-react-native

Install Genymotion simulator 
http://dl.genymotion.com/releases/genymotion-2.9.0/genymotion-2.9.0.exe


Start First project

Create new project with name “myProject1” in the current active directory [Shell Commands]

react-native   init   myProject1
cd   myProject1
react-native   start                    to compile

React-native run-android        to run on device
React-native run-ios

React-native log-android        to get console.log

React-native-cli VS react-native init

React Native is distributed as two npm packages
react-native-cli a lightweight package that should be installed globally
npm install -g react-native-cli
react-native contains the actual React Native framework code and is installed locally into your project when you run
react-native init



Develop react-native applications without install anything on your machine ?

Visit https://snack.expo.io/
Download the Expo app on your mobile
Scan the QR code through Expo application
You are ready now!



Develop on machine, Test on mobile

Download Expo mobile application https://expo.io/

Create new React native application using the next shell commands
 npm i -g create-react-native-app
 create-react-native-app myProject2
 cd myProject2
 npm start            (to run in simulator: npm run android)

you will get QR code, scan it with Expo mobile app and you will be ready!
For more information visit: https://github.com/react-community/create-react-native-app



Best UI Kit for React Native

We need Nativebase for better GUI
open VS IDE then Ctrl+P and type
ext install nativebase-snippets

To add Nativebase to the current project
npm install native-base --save
react-native link



React Navigation  is easy-to-use navigation solution

to Install the react-navigation package in your React Native project.

yarn add react-navigation
# or with npm
# npm install --save react-navigation




Starting file 
After create new project, you will find "App.js" file which is the start file with sample code




Best React Native Resources 









Learn React Native for mobile development

React Native Example 



React native application contains 3-pages
Usage of React Navigation as a navigation tool.
Using NativeBase as the UI library to design our pages.

3-pages application contains buttons on each page that takes us to the other page onPress.


to download the full code for this project 
https://github.com/GeekyAnts/native-base-react-navigation-stack-navigator

Installation

  1. Create React Native App: Use CRNA tool to create an App like this 
$ npm install -g create-react-native-app
$ create-react-native-app my-app
$ cd my-app/
$ npm start
  1. Installing Libraries 
    With a React Native project SetUp, We can now install all required Libraries as follows. 
    a. React Navigation 
npm install --save react-navigation
b. NativeBase 
npm install native-base --save
c. Configure dependencies 
react-native link
By the end of Installation, your package.json file should look something like this.
StackNavigation PackageJson

Lets Play

With our basic project setup we can now start building our App.
Make a folder at the project root by the name of src.
Inside this folder we make 3 folders:
  • ChatScreen
  • HomeScreen
  • ProfileScreen

HomeScreen

This is going to be the first landing screen of out App. We are going to implement the navigation logic here.
For our purpose here, we have used DrawerNavigator for navigation through the entire app.
Further screens will have nested navigators in them.
Go ahead and add the following file in your project. 
Code HomeScreen/HomeScreen.js 
import React from "react";
import { StatusBar } from "react-native";
import { Container, Header, Title, Left, Icon, Right, Button, Body, Content,Text, Card, CardItem } from "native-base";
export default class HomeScreen extends React.Component {
  render() {
    return (
      <Container>
        <Header>
          <Left>
            <Button
              transparent
              onPress={() => this.props.navigation.navigate("DrawerOpen")}>
              <Icon name="menu" />
            </Button>
          </Left>
          <Body>
            <Title>HomeScreen</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <Card>
            <CardItem>
              <Body>
                <Text>Chat App to talk some awesome people!</Text>
              </Body>
            </CardItem>
          </Card>
          <Button full rounded dark
            style={{ marginTop: 10 }}
            onPress={() => this.props.navigation.navigate("Chat")}>
            <Text>Chat With People</Text>
          </Button>
          <Button full rounded primary
            style={{ marginTop: 10 }}
            onPress={() => this.props.navigation.navigate("Profile")}>
            <Text>Goto Profiles</Text>
          </Button>
        </Content>
      </Container>
    );
  }
}

Explained
  • Here we have simply added some buttons, each to openDrawer or navigate to other components.
  • The navigation object is available as a prop to us as we declare this component inside a DrawerNavigator in index.js. 
Code HomeScreen/index.js 
import React, { Component } from "react";
import HomeScreen from "./HomeScreen.js";
import MainScreenNavigator from "../ChatScreen/index.js";
import Profile from "../ProfileScreen/index.js";
import SideBar from "../SideBar/SideBar.js";
import { DrawerNavigator } from "react-navigation";
const HomeScreenRouter = DrawerNavigator(
  {
    Home: { screen: HomeScreen },
    Chat: { screen: MainScreenNavigator },
    Profile: { screen: Profile }
  },
  {
    contentComponent: props => <SideBar {...props} />
  }
);
export default HomeScreenRouter;

Explained
  • Here we have simply imported all the screens we will be needing. We will be building these screens in the comming sections. These screens in fact are router components which themselves have multiple screens.
  • We pass the screens to the DrawerNavigator as shown above.
  • Note how we have used a custom NativeBase components using customComponent prop and we pass our custom drawer component.

SideBar

This is going to be our custom drawer component where we put buttons to navigate to different screens available.
Navigation object is available as this.props.navigation since we passed the props in the HomeScreen component. 
Code SideBar/SideBar.js 
import React from "react";
import { AppRegistry, Image, StatusBar } from "react-native";
import { Container, Content, Text, List, ListItem } from "native-base";
const routes = ["Home", "Chat", "Profile"];
export default class SideBar extends React.Component {
  render() {
    return (
      <Container>
        <Content>
          <Image
            source={{
              uri: "https://github.com/GeekyAnts/NativeBase-KitchenSink/raw/react-navigation/img/drawer-cover.png"
            }}
            style={{
              height: 120,
              alignSelf: "stretch",
              justifyContent: "center",
              alignItems: "center"
            }}>
            <Image
              square
              style={{ height: 80, width: 70 }}
              source={{
                uri: "https://github.com/GeekyAnts/NativeBase-KitchenSink/raw/react-navigation/img/logo.png"
              }}
            />
          </Image>
          <List
            dataArray={routes}
            renderRow={data => {
              return (
                <ListItem
                  button
                  onPress={() => this.props.navigation.navigate(data)}>
                  <Text>{data}</Text>
                </ListItem>
              );
            }}
          />
        </Content>
      </Container>
    );
  }
}

ChatScreen

This screen comprises of TabNavigator component. We are going to have three screens here to chat to three different people.
We will also create our own custom component for Tabs. Its done as follows.
Code ChatScreen/index.js 
import React, { Component } from "react";
import LucyChat from "./LucyChat.js";
import JadeChat from "./JadeChat.js";
import NineChat from "./NineChat.js";
import { TabNavigator } from "react-navigation";
import { Button, Text, Icon, Footer, FooterTab } from "native-base";
export default (MainScreenNavigator = TabNavigator(
  {
    LucyChat: { screen: LucyChat },
    JadeChat: { screen: JadeChat },
    NineChat: { screen: NineChat }
  },
  {
    tabBarPosition: "bottom",
    tabBarComponent: props => {
      return (
        <Footer>
          <FooterTab>
            <Button
              vertical
              active={props.navigationState.index === 0}
              onPress={() => props.navigation.navigate("LucyChat")}>
              <Icon name="bowtie" />
              <Text>Lucy</Text>
            </Button>
            <Button
              vertical
              active={props.navigationState.index === 1}
              onPress={() => props.navigation.navigate("JadeChat")}>
              <Icon name="briefcase" />
              <Text>Nine</Text>
            </Button>
            <Button
              vertical
              active={props.navigationState.index === 2}
              onPress={() => props.navigation.navigate("NineChat")}>
              <Icon name="headset" />
              <Text>Jade</Text>
            </Button>
          </FooterTab>
        </Footer>
      );
    }
  }
));

Explained 
  • We have simply imported three screens to work as Tabs as shown above.
  • We pass these screens to TabNavigator component.
  • Notice how we pass our Tab component through tabBarComponent prop.
  • Navigation is available as props. 

Sample screen

Code ChatScreen/LucyChat.js 
import React from "react";
import { AppRegistry, View, StatusBar } from "react-native";
import { Container, Body, Content, Header, Left, Right, Icon, Title, Input, Item, Label, Button, Text } from "native-base";
import HomeScreen from "../HomeScreen";
export default class LucyChat extends React.Component {
  render() {
    const { navigate } = this.props.navigation;
    return (
      <Container>
        <Header>
          <Left>
            <Button
              transparent
              onPress={() => this.props.navigation.navigate("DrawerOpen")}>
              <Icon name="menu" />
            </Button>
          </Left>
          <Body>
            <Title>Lucy Chat</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <Item floatingLabel style={{ marginTop: 20 }}>
            <Label>Lucy Chat</Label>
            <Input />
          </Item>
          <Button rounded danger
            style={{ marginTop: 20, alignSelf: "center" }}
            onPress={() => navigate("Profile")}>
            <Text>Goto Lucy Profile</Text>
          </Button>
        </Content>
      </Container>
    );
  }
}

Profile

This screen includes example for StackNavigation.
Code ProfileScreen/index.js 
import React, { Component } from "react";
import Profile from "./Profile.js";
import EditScreenOne from "./EditScreenOne.js";
import EditScreenTwo from "./EditScreenTwo.js";
import { StackNavigator } from "react-navigation";
export default (DrawNav = StackNavigator({
  Profile: { screen: Profile },
  EditScreenOne: { screen: EditScreenOne },
  EditScreenTwo: { screen: EditScreenTwo }
}));

Code ProfileScreen/Profile.js 
import React from "react";
import { AppRegistry, Alert } from "react-native";
import { Container, Header, Left, Body, Title, Card, CardItem, Content, Right, Icon, Button, Text } from "native-base";
import { StackNavigator } from "react-navigation";
import EditScreenOne from "./EditScreenOne.js";
import EditScreenTwo from "./EditScreenTwo.js";
export default class Profile extends React.Component {
  componentDidMount() {
    Alert.alert("No Users Found", "Oops, Looks like you are not signed in");
  }
  render() {
    return (
      <Container>
        <Content padder>
          <Card>
            <CardItem>
              <Icon active name="paper-plane" />
              <Text>Show User profiles here</Text>
              <Right>
                <Icon name="close" />
              </Right>
            </CardItem>
          </Card>
          <Button full rounded primary
            style={{ marginTop: 10 }}
            onPress={() => this.props.navigation.navigate("EditScreenOne")}>
            <Text>Goto EditScreen One</Text>
          </Button>
        </Content>
      </Container>
    );
  }
}
Profile.navigationOptions = ({ navigation }) => ({
  header: (
    <Header>
      <Left>
        <Button transparent onPress={() => navigation.navigate("DrawerOpen")}>
          <Icon name="menu" />
        </Button>
      </Left>
      <Body>
        <Title>Profile</Title>
      </Body>
      <Right />
    </Header>
  )
});

Explained 
  • We have Navigation as a StackNavigation prop here. In the UI, we have different buttons to navigate to screens on stack. Notice how we imported screens above.
  • Notice how we passed the DrawerNavigator prop inside our Profile screen header above.
Code ProfileScreen/EditScreenOne.js
This screen is a simple part of StackNavigation, we have a header with a back button as shown below. 
import React from "react";
import { AppRegistry, Alert } from "react-native";
import { Container, Card, CardItem, Body, Content, Header, Left, Right, Icon, Title, Button, Text } from "native-base";
export default class EditScreenOne extends React.Component {
  static navigationOptions = ({ navigation }) => ({
    header: (
      <Header>
        <Left>
          <Button transparent onPress={() => navigation.goBack()}>
            <Icon name="arrow-back" />
          </Button>
        </Left>
        <Body>
          <Title>EditScreenOne</Title>
        </Body>
        <Right />
      </Header>
    )
  });
  render() {
    return (
      <Container>
        <Content padder>
          <Card>
            <CardItem>
              <Icon active name="paper-plane" />
              <Text>Edit Screen 1</Text>
              <Right>
                <Icon name="close" />
              </Right>
            </CardItem>
          </Card>
          <Button full rounded primary
            style={{ marginTop: 10 }}
            onPress={() => this.props.navigation.navigate("EditScreenTwo")}>
            <Text>Goto EditScreenTwo</Text>
          </Button>
        </Content>
      </Container>
    );
  }
}

Finishing up

Lastly we import our routes component from HomeScreen to our App.js file as shown.
Note how we have loaded fonts for NativeBase since we have used expo here. 
Code App.js
import React, { Component } from "react";
import Expo from "expo";
import HomeScreen from "./src/HomeScreen/index.js";
export default class AwesomeApp extends Component {
  constructor() {
    super();
    this.state = {
      isReady: false
    };
  }
  async componentWillMount() {
    await Expo.Font.loadAsync({
      Roboto: require("native-base/Fonts/Roboto.ttf"),
      Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
      Ionicons: require("native-base/Fonts/Ionicons.ttf")
    });
    this.setState({ isReady: true });
  }
  render() {
    if (!this.state.isReady) {
      return <Expo.AppLoading />;
    }
    return <HomeScreen />;
  }
}

All has been taken care of now. Build and run.








Here is the full code in one page (App.js)

import React, { Component } from "react";
import { Container, Header, Title, Left, Icon, Right, Button, Body, Content,Text, Card, CardItem } from "native-base"; 
import {   List, ListItem } from "native-base"; 
import {   Input, Item, Label } from "native-base"; 
import {  Image } from "react-native";
import {  Alert } from "react-native";
import { StackNavigator } from "react-navigation"; 


//#region SideBar
const routes = ["Home", "Chat", "Profile"];
class SideBar extends React.Component {
  render() {
    return (
      <Container>
        <Content>
          <Image
            source={{
              uri: "http://placehold.it/600/771796"
            }}
            style={{
              height: 10,
              alignSelf: "stretch",
              justifyContent: "center",
              alignItems: "center"
            }} />
        
            <Image
              square
              style={{ height: 80, width: 70 }}
              source={{
                uri: "http://www.reactnativeexpress.com/logo.png"
              }}
            />
          
          <List
            dataArray={routes}
            renderRow={data => {
              return (
                <ListItem
                  button
                  onPress={() => this.props.navigation.navigate(data)}>
                  <Text>{data}</Text>
                </ListItem>
              );
            }}
          />
        </Content>
      </Container>
    );
  }
}
//#endregion

//==============================================

//#region LucyChat JadeChat NineChat

class LucyChat extends React.Component {
  render() {
    const { navigate } = this.props.navigation;
    return (
      <Container>
        <Header>
          <Left>
            <Button
              transparent
              onPress={() => this.props.navigation.navigate("DrawerOpen")}>
              <Icon name="menu" />
            </Button>
          </Left>
          <Body>
            <Title>Lucy Chat</Title>
          </Body>
          <Right />
        </Header>
        <Content padder>
          <Item floatingLabel style={{ marginTop: 20 }}>
            <Label>Lucy Chat</Label>
            <Input />
          </Item>
          <Button rounded danger
            style={{ marginTop: 20, alignSelf: "center" }}
            onPress={() => navigate("Profile")}>
            <Text>Goto Lucy Profile</Text>
          </Button>
        </Content>
      </Container>
    );
  }
}

class JadeChat extends React.Component {
    render() {
      const { navigate } = this.props.navigation;
      return (
        <Container>
          <Header>
            <Left>
              <Button
                transparent
                onPress={() => this.props.navigation.navigate("DrawerOpen")}>
                <Icon name="menu" />
              </Button>
            </Left>
            <Body>
              <Title>Jade Chat</Title>
            </Body>
            <Right />
          </Header>
          <Content padder>
            <Item floatingLabel style={{ marginTop: 20 }}>
              <Label>Jade Chat</Label>
              <Input />
            </Item>
            <Button rounded danger
              style={{ marginTop: 20, alignSelf: "center" }}
              onPress={() => navigate("Profile")}>
              <Text>Goto Jade Profile</Text>
            </Button>
          </Content>
        </Container>
      );
    }
  }

class NineChat extends React.Component {
    render() {
      const { navigate } = this.props.navigation;
      return (
        <Container>
          <Header>
            <Left>
              <Button
                transparent
                onPress={() => this.props.navigation.navigate("DrawerOpen")}>
                <Icon name="menu" />
              </Button>
            </Left>
            <Body>
              <Title>NineChat</Title>
            </Body>
            <Right />
          </Header>
          <Content padder>
            <Item floatingLabel style={{ marginTop: 20 }}>
              <Label>NineChat</Label>
              <Input />
            </Item>
            <Button rounded danger
              style={{ marginTop: 20, alignSelf: "center" }}
              onPress={() => navigate("Profile")}>
              <Text>Goto Nine Profile</Text>
            </Button>
          </Content>
        </Container>
      );
    }
  }
//#endregion

//==============================================

//#region MainScreenNavigator
import { TabNavigator } from "react-navigation";
import {  Footer, FooterTab } from "native-base";
const MainScreenNavigator = TabNavigator(
  {
    LucyChat: { screen: LucyChat },
    JadeChat: { screen: JadeChat },
    NineChat: { screen: NineChat }
  },
  {
    tabBarPosition: "bottom",
    tabBarComponent: props => {
      return (
        <Footer>
          <FooterTab>
            <Button
              vertical
              active={props.navigationState.index === 0}
              onPress={() => props.navigation.navigate("LucyChat")}>
              <Icon name="bowtie" />
              <Text>Lucy</Text>
            </Button>
            <Button
              vertical
              active={props.navigationState.index === 1}
              onPress={() => props.navigation.navigate("JadeChat")}>
              <Icon name="briefcase" />
              <Text>Nine</Text>
            </Button>
            <Button
              vertical
              active={props.navigationState.index === 2}
              onPress={() => props.navigation.navigate("NineChat")}>
              <Icon name="headset" />
              <Text>Jade</Text>
            </Button>
          </FooterTab>
        </Footer>
      );
    }
  }
);
//#endregion

//==============================================

//#region EditScreenOne EditScreenTwo
class EditScreenOne extends React.Component {
  static navigationOptions = ({ navigation }) => ({
    header: (
      <Header>
        <Left>
          <Button transparent onPress={() => navigation.goBack()}>
            <Icon name="arrow-back" />
          </Button>
        </Left>
        <Body>
          <Title>EditScreenOne</Title>
        </Body>
        <Right />
      </Header>
    )
  });
  render() {
    return (
      <Container>
        <Content padder>
          <Card>
            <CardItem>
              <Icon active name="paper-plane" />
              <Text>Edit Screen 1</Text>
              <Right>
                <Icon name="close" />
              </Right>
            </CardItem>
          </Card>
          <Button full rounded primary
            style={{ marginTop: 10 }}
            onPress={() => this.props.navigation.navigate("EditScreenTwo")}>
            <Text>Goto EditScreenTwo</Text>
          </Button>
        </Content>
      </Container>
    );
  }
}

class EditScreenTwo extends React.Component {
    static navigationOptions = ({ navigation }) => ({
      header: (
        <Header>
          <Left>
            <Button transparent onPress={() => navigation.goBack()}>
              <Icon name="arrow-back" />
            </Button>
          </Left>
          <Body>
            <Title>EditScreenTwo</Title>
          </Body>
          <Right />
        </Header>
      )
    });
    render() {
      return (
        <Container>
          <Content padder>
            <Card>
              <CardItem>
                <Icon active name="paper-plane" />
                <Text>Edit Screen 2</Text>
                <Right>
                  <Icon name="close" />
                </Right>
              </CardItem>
            </Card>
            <Button full rounded primary
              style={{ marginTop: 10 }}
              onPress={() => this.props.navigation.navigate("EditScreenOne")}>
              <Text>Goto EditScreenOne</Text>
            </Button>
          </Content>
        </Container>
      );
    }
  }
//#endregion

//==============================================

//#region Profile
class Profile extends React.Component {
    componentDidMount() {
      Alert.alert("No Users Found", "Oops, Looks like you are not signed in");
    }
    render() {
      return (
        <Container>
          <Content padder>
            <Card>
              <CardItem>
                <Icon active name="paper-plane" />
                <Text>Show User profiles here</Text>
                <Right>
                  <Icon name="close" />
                </Right>
              </CardItem>
            </Card>
            <Button full rounded primary
              style={{ marginTop: 10 }}
              onPress={() => this.props.navigation.navigate("EditScreenOne")}>
              <Text>Goto EditScreen One</Text>
            </Button>
          </Content>
        </Container>
      );
    }
  }
  Profile.navigationOptions = ({ navigation }) => ({
    header: (
      <Header>
        <Left>
          <Button transparent onPress={() => navigation.navigate("DrawerOpen")}>
            <Icon name="menu" />
          </Button>
        </Left>
        <Body>
          <Title>Profile</Title>
        </Body>
        <Right />
      </Header>
    )
  });
  //#endregion
  
//==============================================

//#region DrawNav
const EditProfileNavigator = StackNavigator({
    Profile: { screen: Profile },
    EditScreenOne: { screen: EditScreenOne },
    EditScreenTwo: { screen: EditScreenTwo }
  });
  //#endregion
  
//==============================================

//#region HomeScreen
class HomeScreen extends React.Component {
    render() {
      return (
        <Container>
          <Header>
            <Left>
              <Button
                transparent
                onPress={() => this.props.navigation.navigate("DrawerOpen")}>
                <Icon name="menu" />
              </Button>
            </Left>
            <Body>
              <Title>HomeScreen</Title>
            </Body>
            <Right />
          </Header>
          <Content padder>
            <Card>
              <CardItem>
                <Body>
                  <Text>Chat App to talk some awesome people!</Text>
                </Body>
              </CardItem>
            </Card>
            <Button full rounded dark
              style={{ marginTop: 10 }}
              onPress={() => this.props.navigation.navigate("Chat")}>
              <Text>Chat With People</Text>
            </Button>
            <Button full rounded primary
              style={{ marginTop: 10 }}
              onPress={() => this.props.navigation.navigate("Profile")}>
              <Text>Goto Profiles</Text>
            </Button>
          </Content>
        </Container>
      );
    }
  }
  //#endregion

//==============================================

//#region HomeScreenRouter
import { DrawerNavigator } from "react-navigation";
const HomeScreenRouter = DrawerNavigator(
  {
    Home: { screen: HomeScreen },
    Chat: { screen: MainScreenNavigator },
    Profile: { screen: EditProfileNavigator }
  },
  {
    contentComponent: props => <SideBar {...props} />
  }
);
//#endregion
  
 //==============================================

 //#region Start Loading Page
import Expo from "expo";
export default class DrawerMultiTabsNativeBase extends Component {
  constructor() {
    super();
    this.state = {
      isReady: false
    };
  }
  async componentWillMount() {
    await Expo.Font.loadAsync({
      Roboto: require("native-base/Fonts/Roboto.ttf"),
      Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf"),
      Ionicons: require("native-base/Fonts/Ionicons.ttf")
    });
    this.setState({ isReady: true });
  }
  render() {
    if (!this.state.isReady) {
      return <Expo.AppLoading />;
    }
    return <HomeScreenRouter />;
  }
}
//#endregion

//==============================================