Friday 31 January 2020

commodity price app

app starts, loading data

click on menu icon on top left

drawer opens, select energy

drawer closes, energy commodities are displayed





reference:
https://markets.businessinsider.com/commodities/feeder-cattle-price
https://github.com/GeekyAnts/NativeBase/issues/1466

commodity unit
https://markets.businessinsider.com/commodities

http://chuanshuoge2.blogspot.com/2020/01/web-scraping-commodity-price.html
http://chuanshuoge2.blogspot.com/2020/01/nativebase-future-trade.html

How to share Expo project?

The fastest way to share your managed Expo project is to publish it. You can do this by clicking 'Publish' in Expo Dev Tools or running expo publish in your project. This gives your app a URL; you can share this URL with anybody who has the Expo client for Android and they can open your app immediately. Read more about publishing on Expo. To share with iOS users, you can use Apple TestFlight or sign up for the Priority Plan in order to share your app with teammates through the Expo client.

When you're ready, you can create a standalone app (.ipa and .apk) for submission to Apple and Google's app stores. Expo will build the binary for you when you run one command; see Building Standalone Apps. Apple charges $99/year to publish your app in the App Store and Google charges a $25 one-time fee for the Play Store.

reference:
https://docs.expo.io/versions/latest/introduction/faq/

Thursday 30 January 2020

JSSoup web scraping commodity price


extract data from first row of livestocks table

data extracted by JSSoup

//app.js

import React, { Component } from 'react';
import JSSoup from 'jssoup'
import axios from 'axios'
import { Image } from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
import DrawerContent from './Drawer'
import CommodityListItem from './CommodityListItem'
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker, DeckSwiper, View, Fab,
  Badge, Form, Item, Input, Label, Picker, Textarea,
  Switch, Radio, Spinner, Tab, Tabs, TabHeading,
  ScrollableTab, H1, H2, H3, Drawer,
} from 'native-base';

import { createIconSetFromIcoMoon } from '@expo/vector-icons';
import icon_json from './assets/selection.json'

const icon_ttf = require("./assets/icomoon.ttf");
const CustomIcon = createIconSetFromIcoMoon(icon_json, '', icon_ttf);

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      category: 1,
      feeder_cattle: null
    };
  }

  componentDidMount() {

    axios({
      method: 'get',
      url: 'https://quotes.ino.com/exchanges/category.html?c=livestock',
    })
      .then(response => {
        //get source code from website
        const soup = new JSSoup(response.data)
        //find all rows with classname odd
        const tr = soup.findAll('tr', 'odd')
        //find all columns in the first row
        const td = tr[0].findAll('td')
        //extract column values and store them in a list
        let s = []
        td.forEach(element => {
          s.push(element.string.toString())
        });
        this.setState({ feeder_cattle: s })
        alert(this.state.feeder_cattle)
      })
      .catch(function (error) {
        alert(error);
      });
  }


  closeDrawer = () => {
    this.drawer._root.close()
  };

  openDrawer = () => {
    this.drawer._root.open()
  };

  changeCategory = (c) => {
    this.setState({ category: c })
  }

  render() {
    const { feeder_cattle } = this.state

    return (

      <Drawer ref={(ref) => { this.drawer = ref; }}
        content={
          <DrawerContent
            changeCategory={(c) => this.changeCategory(c)}
            closeDrawer={() => this.closeDrawer()}>
          </DrawerContent>
        }
        onClose={() => this.closeDrawer()} >

        <Container style={{ backgroundColor: '#1C2833' }}>
          <Header>
            <Left>
              <Button transparent onPress={() => this.openDrawer()}>
                <Icon name='menu' />
              </Button>
            </Left>
            <Body style={{ alignItems: 'center' }}>
              <Title>
                {
                  this.state.category === 1 ? 'Energy' :
                    this.state.category === 2 ? 'Metals' :
                      this.state.category === 3 ? 'Grains' :
                        this.state.category === 4 ? 'Softs' :
                          this.state.category === 5 ? 'Livestock' :
                            'drawer'
                }
              </Title>
            </Body>
            <Right></Right>
          </Header>

          <Content>

            <CommodityListItem
              iconName='feeder_cattle'
              title='Feeder Cattle'
              current={feeder_cattle ? feeder_cattle[5] : ''}
              dif={feeder_cattle ? feeder_cattle[6] : ''}
              percentDif={feeder_cattle ? feeder_cattle[7] : ''}
              open={feeder_cattle ? feeder_cattle[2] : ''}
              high={feeder_cattle ? feeder_cattle[3] : ''}
              low={feeder_cattle ? feeder_cattle[4] : ''}
              time={feeder_cattle ? feeder_cattle[8] + ' ' + feeder_cattle[1] : ''}
            ></CommodityListItem>
          </Content>
        </Container>
      </Drawer>
    );
  }
}

-------------------------------
CommodityListItem.js

import React, { Component } from 'react';
import {
    Container, Header, Title, Content, Footer,
    FooterTab, Button, Left, Right, Body, Icon, Text,
    Accordion, Card, CardItem, Thumbnail, ListItem,
    CheckBox, DatePicker, DeckSwiper, View, Fab,
    Badge, Form, Item, Input, Label, Picker, Textarea,
    Switch, Radio, Spinner, Tab, Tabs, TabHeading,
    ScrollableTab, H1, H2, H3, Drawer,
} from 'native-base';

import { createIconSetFromIcoMoon } from '@expo/vector-icons';
import icon_json from './assets/selection.json'

const icon_ttf = require("./assets/icomoon.ttf");
const CustomIcon = createIconSetFromIcoMoon(icon_json, '', icon_ttf);

export default class CommodityListItem extends Component {
    constructor(props) {
        super(props);
        this.state = {
        };
    }

    render() {
        return (
            <ListItem icon noBorder style={{ height: 100 }}>
                <Left><CustomIcon name={this.props.iconName} size={50} color="white"></CustomIcon></Left>
                <Body>
                    <Text style={{ color: 'gold' }}>{this.props.title}</Text>
                    <Text style={{ color: 'white' }}>{this.props.current}{' '}
                        {
                            this.props.dif.includes('-') ?
                                <CustomIcon name='down' size={15} color="red"></CustomIcon> :
                                <CustomIcon name='up' size={15} color="green"></CustomIcon>
                        }
                        {
                            this.props.dif.includes('-') ?
                                <Text style={{ color: 'red' }}>{this.props.dif} ({this.props.percentDif.replace('-', '')})</Text> :
                                <Text style={{ color: 'green' }}>{this.props.dif.replace('+', '')} ({this.props.percentDif.replace('+', '')})</Text>
                        }
                    </Text>
                    <Text note numberOfLines={2} style={{ color: 'white' }}>Open: {this.props.open}{'\n'}
                        High: {this.props.high} Low: {this.props.low}
                    </Text>
                </Body>
                <Right style={{ paddingTop: 50 }}>
                    <Text note style={{ color: 'white' }}>cent/pound{"\n"}{this.props.time}</Text>
                </Right>
            </ListItem>
        )
    }
}

------------------------------
//Drawer.js

import React, { Component } from 'react';
import {
    Container, Header, Title, Content, Footer,
    FooterTab, Button, Left, Right, Body, Icon, Text,
    Accordion, Card, CardItem, Thumbnail, ListItem,
    CheckBox, DatePicker, DeckSwiper, View, Fab,
    Badge, Form, Item, Input, Label, Picker, Textarea,
    Switch, Radio, Spinner, Tab, Tabs, TabHeading,
    ScrollableTab, H1, H2, H3, Drawer,
} from 'native-base';

import { createIconSetFromIcoMoon } from '@expo/vector-icons';
import icon_json from './assets/selection.json'

const icon_ttf = require("./assets/icomoon.ttf");
const CustomIcon = createIconSetFromIcoMoon(icon_json, '', icon_ttf);

export default class DrawerContent extends Component {
    constructor(props) {
        super(props);
        this.state = {
        };
    }

    render() {
        return (
            <Container style={{ backgroundColor: '#1C2833' }}>
                <Header>
                    <Body>
                        <Title>Commodity Price</Title>
                    </Body>
                    <Right>
                        <Button transparent onPress={() => this.props.closeDrawer()}>
                            <Icon name='arrow-back' />
                        </Button>
                    </Right>
                </Header>
                <Content>
                    <ListItem icon noBorder onPress={() => { this.props.changeCategory(1); this.props.closeDrawer() }}>
                        <Left>
                            <Icon type='FontAwesome5' name="fire" style={{ color: 'white' }} />
                        </Left>
                        <Body>
                            <Text style={{ color: 'white' }}>Energy</Text>
                        </Body>
                    </ListItem>
                    <ListItem icon noBorder onPress={() => { this.props.changeCategory(2); this.props.closeDrawer() }}>
                        <Left>
                            <CustomIcon name='gold' size={24} color="white"></CustomIcon>
                        </Left>
                        <Body>
                            <Text style={{ color: 'white' }}>Metals</Text>
                        </Body>
                    </ListItem>
                    <ListItem icon noBorder onPress={() => { this.props.changeCategory(3); this.props.closeDrawer() }}>
                        <Left>
                            <CustomIcon name='grain' size={24} color="white"></CustomIcon>
                        </Left>
                        <Body>
                            <Text style={{ color: 'white' }}>Grains</Text>
                        </Body>
                    </ListItem>
                    <ListItem icon noBorder onPress={() => { this.props.changeCategory(4); this.props.closeDrawer() }}>
                        <Left>
                            <CustomIcon name='coffee' size={24} color="white"></CustomIcon>
                        </Left>
                        <Body>
                            <Text style={{ color: 'white' }}>Softs</Text>
                        </Body>
                    </ListItem>
                    <ListItem icon noBorder onPress={() => { this.props.changeCategory(5); this.props.closeDrawer() }}>
                        <Left>
                            <CustomIcon name='live_cattle' size={24} color="white"></CustomIcon>
                        </Left>
                        <Body>
                            <Text style={{ color: 'white' }}>Livestock</Text>
                        </Body>
                    </ListItem>
                </Content>
            </Container>
        )
    }
}

-------------------------------------
//https://quotes.ino.com/exchanges/category.html?c=livestock souce code
...
<div class="table-responsive">
<table border="0" cellspacing="0" cellpadding="0" class="table table-condensed">
        <colgroup span="2" />
        <col />
        <col />
        <col />
        <col />
        <col />
        <col />
        <col />
<tr><th scope="col">Market</th><th scope="col">Contract</th><th class="rt" scope="col">Open</th><th class="rt" scope="col">High</th><th class="rt" scope="col">Low</th><th class="rt" scope="col">Last</th><th class="rt" scope="col">Change</th><th class="rt" scope="col">Pct</th><th class="rt" scope="col">Time</th></tr><tr><th colspan="5" scope="colgroup"><a href="contracts.html?r=CME_GF">FEEDER CATTLE (CME:GF)</a></th>
 <td class="rt util-links">
   <a href="https://club.ino.com/trend/?v=future&s=CME_GF&mktcode=INOFutures" target="signal" class="btn-entry-signal btn btn-sm btn-primary">Entry Signal</a></td>
 <td class="rt util-links" colspan="3">
<a href="contracts.html?r=CME_GF">View all months</a> | <a href="http://club.ino.com/members/download/data.html?s=CME_GF">Download data</a> | <a href="http://club.ino.com/members/search/?c=CME_GF&amp;mode=analysis">Analyze Chart</a></td></tr>
<tr class="odd"><td><a href="https://quotes.ino.com/charting/?s=CME_GF.F20">GF.F20</a></td><td><a href="https://quotes.ino.com/charting/?s=CME_GF.F20">Jan 2020</a></td><td class="rt">142.300</td><td class="rt">142.525</td><td class="rt">142.250</td><td class="rt">142.425</td><td class="rt up">+0.175</td><td class="rt up">+0.12%</td><td class="rt">17:28</td></tr><tr><td><a href="https://quotes.ino.com/charting/?s=CME_GF.H20">GF.H20</a></td><td><a href="https://quotes.ino.com/charting/?s=CME_GF.H20">Mar 2020</a></td><td class="rt">135.650</td><td class="rt">137.775</td><td class="rt">135.450</td><td class="rt">136.925</td><td class="rt up">+1.700</td><td class="rt up">+1.17%</td><td class="rt">12:00</td></tr><tr class="odd"><td><a href="https://quotes.ino.com/charting/?s=CME_GF.J20">GF.J20</a></td><td><a href="https://quotes.ino.com/charting/?s=CME_GF.J20">Apr 2020</a></td><td class="rt">137.200</td><td class="rt">139.475</td><td class="rt">137.075</td><td class="rt">138.625</td><td class="rt up">+1.725</td><td class="rt up">+1.16%</td><td class="rt">12:00</td></tr><tr><th colspan="9" align=center></th></tr>
<tr><th colspan="5" scope="colgroup"><a href="contracts.html?r=CME_HE">LEAN HOGS (CME:HE)</a></th>
 <td class="rt util-links">
   <a href="https://club.ino.com/trend/?v=future&s=CME_HE&mktcode=INOFutures" target="signal" class="btn-entry-signal btn btn-sm btn-primary">Entry Signal</a></td>
 <td class="rt util-links" colspan="3">
<a href="contracts.html?r=CME_HE">View all months</a> | <a href="http://club.ino.com/members/download/data.html?s=CME_HE">Download data</a> | <a href="http://club.ino.com/members/search/?c=CME_HE&amp;mode=analysis">Analyze Chart</a></td></tr>
<tr class="odd"><td><a href="https://quotes.ino.com/charting/?s=CME_HE.G20">HE.G20</a></td><td><a href="https://quotes.ino.com/charting/?s=CME_HE.G20">Feb 2020</a></td><td class="rt">60.50</td><td class="rt">60.50</td><td class="rt">57.35</td><td class="rt">58.85</td><td class="rt down">-2.45</td><td class="rt down">-3.72%</td><td class="rt">12:00</td></tr><tr>...

reference:
https://quotes.ino.com/

jssoup
https://www.npmjs.com/package/jssoup

JSSoup uses tautologistics/node-htmlparser as HTML dom parser, and creates a series of BeautifulSoup like API on top of it. JSSoup supports both node and react-native.

https://stackoverflow.com/questions/53770358/cannot-find-a-tag-with-jssoup-even-though-the-tag-exists-in-node-js
https://github.com/chishui/JSSoup/blob/94af47ba9209f4ed9c4b372c3f5cbbebfa679653/lib/jssoup.js#L153

https://stackoverflow.com/questions/41194866/how-to-set-state-of-response-from-axios-in-react
https://chuanshuoge2.blogspot.com/2020/01/nativebase-future-trade.html

NativeBase commodity price


import React, { Component } from 'react';
import { Image } from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker, DeckSwiper, View, Fab,
  Badge, Form, Item, Input, Label, Picker, Textarea,
  Switch, Radio, Spinner, Tab, Tabs, TabHeading,
  ScrollableTab, H1, H2, H3, Drawer,
} from 'native-base';

import { createIconSetFromIcoMoon } from '@expo/vector-icons';
import icon_json from './assets/selection.json'

const icon_ttf = require("./assets/icomoon.ttf");
const CustomIcon = createIconSetFromIcoMoon(icon_json, '', icon_ttf);

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      category: 1
    };
  }

  closeDrawer = () => {
    this.drawer._root.close()
  };

  openDrawer = () => {
    this.drawer._root.open()
  };

  render() {
    return (

      <Drawer ref={(ref) => { this.drawer = ref; }}
        content={
          <Container style={{ backgroundColor: '#1C2833' }}>
            <Header>
              <Body>
                <Title>Commodity Price</Title>
              </Body>
              <Right>
                <Button transparent onPress={() => this.closeDrawer()}>
                  <Icon name='arrow-back' />
                </Button>
              </Right>
            </Header>
            <Content>
              <ListItem icon noBorder onPress={() => { this.setState({ category: 1 }); this.closeDrawer() }}>
                <Left>
                  <Icon type='FontAwesome5' name="fire" style={{ color: 'white' }} />
                </Left>
                <Body>
                  <Text style={{ color: 'white' }}>Energy</Text>
                </Body>
              </ListItem>
              <ListItem icon noBorder onPress={() => { this.setState({ category: 2 }); this.closeDrawer() }}>
                <Left>
                  <CustomIcon name='gold' size={24} color="white"></CustomIcon>
                </Left>
                <Body>
                  <Text style={{ color: 'white' }}>Metals</Text>
                </Body>
              </ListItem>
              <ListItem icon noBorder onPress={() => { this.setState({ category: 3 }); this.closeDrawer() }}>
                <Left>
                  <CustomIcon name='grain' size={24} color="white"></CustomIcon>
                </Left>
                <Body>
                  <Text style={{ color: 'white' }}>Grains</Text>
                </Body>
              </ListItem>
              <ListItem icon noBorder onPress={() => { this.setState({ category: 4 }); this.closeDrawer() }}>
                <Left>
                  <CustomIcon name='coffee' size={24} color="white"></CustomIcon>
                </Left>
                <Body>
                  <Text style={{ color: 'white' }}>Softs</Text>
                </Body>
              </ListItem>
              <ListItem icon noBorder onPress={() => { this.setState({ category: 5 }); this.closeDrawer() }}>
                <Left>
                  <CustomIcon name='live_cattle' size={24} color="white"></CustomIcon>
                </Left>
                <Body>
                  <Text style={{ color: 'white' }}>Livestock</Text>
                </Body>
              </ListItem>
            </Content>
          </Container>
        }
        onClose={() => this.closeDrawer()} >

        <Container style={{ backgroundColor: '#1C2833' }}>
          <Header>
            <Left>
              <Button transparent onPress={() => this.openDrawer()}>
                <Icon name='menu' />
              </Button>
            </Left>
            <Body style={{ alignItems: 'center' }}>
              <Title>
                {
                  this.state.category === 1 ? 'Energy' :
                    this.state.category === 2 ? 'Metals' :
                      this.state.category === 3 ? 'Grains' :
                        this.state.category === 4 ? 'Softs' :
                          this.state.category === 5 ? 'Livestock' :
                            'drawer'
                }
              </Title>
            </Body>
            <Right></Right>
          </Header>

          <Content>
            <ListItem icon noBorder style={{ height: 100 }}>
              <Left><CustomIcon name='live_cattle' size={50} color="white"></CustomIcon></Left>
              <Body>
                <Text style={{ color: 'gold' }}>Live Cattle</Text>
                <Text style={{ color: 'white' }}>135.30{' '}
                  <CustomIcon name='down' size={15} color="red"></CustomIcon>
                  <Text style={{ color: 'red' }}>7.08 (4.97%)</Text>
                </Text>
                <Text note numberOfLines={1} style={{ color: 'white' }}>Open: 142.38 Close: 135.30</Text>
              </Body>
              <Right style={{ paddingTop: 50 }}>
                <Text note style={{ color: 'white' }}>cent/pound{"\n"}Jan 29, 9:55AM</Text>
              </Right>
            </ListItem>
            <ListItem icon noBorder style={{ height: 100 }}>
              <Left><CustomIcon name='feeder_cattle' size={50} color="white"></CustomIcon></Left>
              <Body>
                <Text style={{ color: 'gold' }}>Feeder Cattle</Text>
                <Text style={{ color: 'white' }}>142.82{' '}
                  <CustomIcon name='up' size={15} color="green"></CustomIcon>
                  <Text style={{ color: 'green' }}>1.38 (0.97%)</Text>
                </Text>
                <Text note numberOfLines={1} style={{ color: 'white' }}>Open: 144.08 Close: 141.45</Text>
              </Body>
              <Right style={{ paddingTop: 50 }}>
                <Text note style={{ color: 'white' }}>cent/pound{"\n"}Jan 29, 9:55AM</Text>
              </Right>
            </ListItem>
            <ListItem icon noBorder style={{ height: 100 }}>
              <Left><CustomIcon name='hog' size={50} color="white"></CustomIcon></Left>
              <Body>
                <Text style={{ color: 'gold' }}>Lean Hog</Text>
                <Text style={{ color: 'white' }}>64.30{' '}
                  <CustomIcon name='down' size={15} color="red"></CustomIcon>
                  <Text style={{ color: 'red' }}>4.52 (6.57%)</Text>
                </Text>
                <Text note numberOfLines={1} style={{ color: 'white' }}>Open: 66.50 Close: 68.82</Text>
              </Body>
              <Right style={{ paddingTop: 50 }}>
                <Text note style={{ color: 'white' }}>cent/pound{"\n"}Jan 29, 12:04PM</Text>
              </Right>
            </ListItem>
          </Content>
        </Container>
      </Drawer>
    );
  }
}

reference:
http://chuanshuoge2.blogspot.com/2020/01/nativebase-drawer.html

Wednesday 29 January 2020

python read write large file by chunks, test video, pdf files

b.mp4 assembled from chunks

b.pdf assembled from chunks


import pickle
import glob
import os.path

def read_in_chunks(file_object, chunk_size=1024*1024):

    while True:
        data = file_object.read(chunk_size)
        if not data:
            break
        yield data


def store_chunks():
    with open('a.mp4', 'rb') as file:

        for i, piece in enumerate(read_in_chunks(file)):

            chunkName = str(i) + '.pickle'
            with open(os.path.join('pickled_chunks',  chunkName), 'wb') as chunk:
                pickle.dump(piece, chunk)


#store_chunks()

def assemble_chunks():
    chunks = glob.glob(os.path.join('pickled_chunks', '*.pickle'))

    with open('b.mp4', 'wb') as file:
        for i in range(len(chunks)):
            chunkName = str(i) + '.pickle'

            with open(os.path.join('pickled_chunks',  chunkName), 'rb') as pickled_chunk:
                file_chunk = pickle.load(pickled_chunk)
                file.write(file_chunk)


assemble_chunks()

reference:
http://chuanshuoge2.blogspot.com/2020/01/python-read-write-large-file-by-chunks.html

“冠状病毒”是什么

Tuesday 28 January 2020

python read write large file by chunks

When uploading files from pc to server or downloading from server to pc, loading large file directly into pc memory may exceed memory capacity, alternative is to break large file into small chunks. Each time load a chunk into memory, store the chunk on server, clear the memory and load next chunk. To retrieve file from server, each time load a chunk from server to memory and concatenate to the file on local pc. When all chunks are assembled, complete file is on disk.    
read a.txt, breaks it into 30 1kb chunks, pickle them,
 and store in ordered names in picked_chunks folder
load pickled chunks, read them by file name order, 
and write to b.txt one by one

30 * 1kb chunks = 30kb
a.txt

b.txt
unrecognized symbols from a.txt is replaced with ?

import pickle
import glob
import os.path

def read_in_chunks(file_object, chunk_size=1024):

    while True:
        data = file_object.read(chunk_size)
        if not data:
            break
        yield data


def store_chunks():
    with open('a.txt', 'r', errors='replace') as file:

        for i, piece in enumerate(read_in_chunks(file)):

            chunkName = str(i) + '.pickle'
            with open(os.path.join('pickled_chunks',  chunkName), 'wb') as chunk:
                pickle.dump(piece, chunk)


#store_chunks()

def assemble_chunks():
    chunks = glob.glob(os.path.join('pickled_chunks', '*.pickle'))

    with open('b.txt', 'w', errors='replace') as file:
        for i in range(len(chunks)):
            chunkName = str(i) + '.pickle'

            with open(os.path.join('pickled_chunks',  chunkName), 'rb') as pickled_chunk:
                file_chunk = pickle.load(pickled_chunk)
                file.write(file_chunk)


assemble_chunks()

reference:
http://chuanshuoge2.blogspot.com/2020/01/python-yield.html

glob
https://www.geeksforgeeks.org/how-to-use-glob-function-to-find-files-recursively-in-python/

Sunday 26 January 2020

在房车里上班的硅谷软件工程师

NativeBase Drawer reference, custom Icons


reference:
https://stackoverflow.com/questions/42855674/implement-drawer-from-native-base-in-react-native-app
https://github.com/GeekyAnts/NativeBase/issues/1199
https://chuanshuoge2.blogspot.com/2020/01/nativebase-list.html
https://oblador.github.io/react-native-vector-icons/

custom Icon
https://docs.expo.io/versions/latest/guides/icons/
https://docs.expo.io/versions/latest/guides/using-custom-fonts/#using-custom-fonts

download svg icon, rename it to gold.svg

import gold.svg, click generate font

extract generated zip file


copy selection.json, icomoon.ttf to project folder assets

//create custom icon with ttf and json file, try it out 
import React, { Component } from 'react';
import { Image } from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker, DeckSwiper, View, Fab,
  Badge, Form, Item, Input, Label, Picker, Textarea,
  Switch, Radio, Spinner, Tab, Tabs, TabHeading,
  ScrollableTab, H1, H2, H3, Drawer,
} from 'native-base';

import { createIconSetFromIcoMoon } from '@expo/vector-icons';
import gold_json from './assets/gold.json'

const gold_ttf = require("./assets/gold.ttf");
const GoldIcon = createIconSetFromIcoMoon(gold_json, '', gold_ttf);

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      category: 1
    };
  }

  closeDrawer = () => {
    this.drawer._root.close()
  };

  openDrawer = () => {
    this.drawer._root.open()
  };

  render() {
    return (

      <Drawer ref={(ref) => { this.drawer = ref; }}
        content={
          <Container style={{ backgroundColor: '#1C2833' }}>
            <Header>
              <Body>
                <Title>Commodity Price</Title>
              </Body>
              <Right>
                <Button transparent onPress={() => this.closeDrawer()}>
                  <Icon name='arrow-back' />
                </Button>
              </Right>
            </Header>
            <Content>
              <ListItem icon noBorder onPress={() => { this.setState({ category: 1 }) }}>
                <Left>
                  <Icon type='FontAwesome5' name="fire" style={{ color: 'white' }} />
                </Left>
                <Body>
                  <Text style={{ color: 'white' }}>Energy</Text>
                </Body>
              </ListItem>
              <ListItem icon noBorder onPress={() => { this.setState({ category: 2 }) }}>
                <Left>
                  <GoldIcon name='gold' size={24} color="white"></GoldIcon>
                </Left>
                <Body>
                  <Text style={{ color: 'white' }}>Metals</Text>
                </Body>
              </ListItem>
            </Content>
          </Container>
        }
        onClose={() => this.closeDrawer()} >

        <Container>
          <Header>
            <Left>
              <Button transparent onPress={() => this.openDrawer()}>
                <Icon name='menu' />
              </Button>
            </Left>
            <Body style={{ alignItems: 'center' }}>
              <Title>Drawer</Title>
            </Body>
            <Right></Right>
          </Header>

          <Content>
            <H1>Header One</H1>
            <H2>Header Two</H2>
            <H3>Header Three</H3>
            <Text>Default</Text>
          </Content>
        </Container>
      </Drawer>
    );
  }
}

custom icon is displayed

NativeBase Typography

import React, { Component } from 'react';
import { Image } from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker, DeckSwiper, View, Fab,
  Badge, Form, Item, Input, Label, Picker, Textarea,
  Switch, Radio, Spinner, Tab, Tabs, TabHeading,
  ScrollableTab, H1, H2, H3,
} from 'native-base';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {

    };
  }

  render() {
    return (
      <Container>
        <Header>
          <Body style={{ flex: 1, alignItems: 'center' }}>
            <Title>Typography</Title>
          </Body>
        </Header>

        <Content>
          <H1>Header One</H1>
          <H2>Header Two</H2>
          <H3>Header Three</H3>
          <Text>Default</Text>
        </Content>
      </Container>
    );
  }
}

武汉 Jan 26



Saturday 25 January 2020

NativeBase Tabs


scroll tabs

press a tab

import React, { Component } from 'react';
import { Image } from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker, DeckSwiper, View, Fab,
  Badge, Form, Item, Input, Label, Picker, Textarea,
  Switch, Radio, Spinner, Tab, Tabs, TabHeading,
  ScrollableTab,
} from 'native-base';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {

    };
  }

  render() {
    return (
      <Container>
        <Header hasTabs>
          <Body style={{ flex: 1, alignItems: 'center' }}>
            <Title>Tabs</Title>
          </Body>
        </Header>

        <Tabs renderTabBar={() => <ScrollableTab />}>
          <Tab heading={<TabHeading><Icon name="camera" /><Text>Camera</Text></TabHeading>}>
            <Content padder>
              <Text>tab1 content</Text>
            </Content>
          </Tab>
          <Tab heading={<TabHeading><Text>No Icon</Text></TabHeading>}>
            <Content padder>
              <Text>tab2 content</Text>
            </Content>
          </Tab>
          <Tab heading={<TabHeading><Icon name="apps" /></TabHeading>}>
            <Content padder>
              <Text>tab3 content</Text>
            </Content>
          </Tab>
          <Tab heading="Tab4">
            <Content padder>
              <Text>tab4 content</Text>
            </Content>
          </Tab>
          <Tab heading="Tab5">
            <Content padder>
              <Text>tab5 content</Text>
            </Content>
          </Tab>
          <Tab heading="Tab6">
            <Content padder>
              <Text>tab6 content</Text>
            </Content>
          </Tab>
          <Tab heading="Tab7">
            <Content padder>
              <Text>tab7 content</Text>
            </Content>
          </Tab>
        </Tabs>
      </Container>
    );
  }
}


NativeBase Spinner

import React, { Component } from 'react';
import { Image } from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker, DeckSwiper, View, Fab,
  Badge, Form, Item, Input, Label, Picker, Textarea,
  Switch, Radio, Spinner
} from 'native-base';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {

    };
  }

  render() {
    return (
      <Container>
        <Header>
          <Body>
            <Title>Spinner</Title>
          </Body>
        </Header>
        <Content>
          <Spinner />
          <Spinner color='red' />
          <Spinner color='green' />
          <Spinner color='blue' />
        </Content>
      </Container>
    );
  }
}

NativeBase Radio


import React, { Component } from 'react';
import { Image } from 'react-native';
import { TextInputMask } from 'react-native-masked-text'
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker, DeckSwiper, View, Fab,
  Badge, Form, Item, Input, Label, Picker, Textarea,
  Switch, Radio
} from 'native-base';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      radio1: false,
      radio2: true,
    };
  }

  render() {
    return (
      <Container>
        <Header>
          <Body>
            <Title>Radio</Title>
          </Body>
        </Header>
        <Content>
          <ListItem>
            <Left>
              <Text>Daily Stand Up</Text>
            </Left>
            <Right>
              <Radio selected={this.state.radio1}
                onPress={() => this.setState({ radio1: !this.state.radio1 })} />
            </Right>
          </ListItem>
          <ListItem>
            <Left>
              <Text>Discussion with Client</Text>
            </Left>
            <Right>
              <Radio selected={this.state.radio2}
                onPress={() => this.setState({ radio2: !this.state.radio2 })} />
            </Right>
          </ListItem>
        </Content>
      </Container>
    );
  }
}

Friday 24 January 2020

Buying a New Construction Home!


what kind of financial incentive do you offer for using your preferred  lender and title company?

what are the standard finishes?

what are your long term plans for community?

what are the HOA rules and regulations?

what warranty do you provide?

Can you connect me with past clients?