Tuesday, 21 January 2020

NativeBase DatePicker

import React, { Component } from 'react';
import { Image } from 'react-native';
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox, DatePicker,
} from 'native-base';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      chosenDate: new Date()
    };
  }

  setDate = (date) => {
    this.setState({ chosenDate: date })
  }

  render() {
    return (
      <Container>
        <Header>
          <Body>
            <Title>Date Picker</Title>
          </Body>
        </Header>
        <Content>
          <DatePicker
            defaultDate={new Date(2018, 4, 4)}
            minimumDate={new Date(2018, 1, 1)}
            maximumDate={new Date(2018, 12, 31)}
            locale={"en"}
            timeZoneOffsetInMinutes={undefined}
            modalTransparent={false}
            animationType={"fade"}
            androidMode={"default"}
            placeHolderText="Select date"
            textStyle={{ color: "green" }}
            placeHolderTextStyle={{ color: "#d3d3d3" }}
            onDateChange={(e) => this.setDate(e)}
            disabled={false}
          />
          <Text>
            Date: {this.state.chosenDate.toString().substr(4, 12)}
          </Text>
        </Content>
      </Container>
    );
  }
}

Monday, 20 January 2020

NativeBase CheckBox


import React, { Component } from 'react';
import { Image } from 'react-native';
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail, ListItem,
  CheckBox,
} from 'native-base';

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

  changeCheck = (name) => {
    this.setState(prevstate => {
      return { [name]: !prevstate[name] }
    })
  }

  render() {
    return (
      <Container>
        <Header>
          <Body>
            <Title>Card</Title>
          </Body>
        </Header>
        <Content>
          <ListItem>
            <CheckBox checked={this.state.check1} onPress={() => this.changeCheck('check1')} />
            <Body>
              <Text>Daily Stand Up</Text>
            </Body>
          </ListItem>
          <ListItem>
            <CheckBox checked={this.state.check2} onPress={() => this.changeCheck('check2')} />
            <Body>
              <Text>Discussion with Client</Text>
            </Body>
          </ListItem>
          <ListItem>
            <CheckBox checked={this.state.check3} color="green" onPress={() => this.changeCheck('check3')} />
            <Body>
              <Text>Finish list Screen</Text>
            </Body>
          </ListItem>
        </Content>
      </Container>
    );
  }
}

public mobile set data and APN on android phone

Settings > More... > Mobile Networks > Access Point Names > New APN setting (or a plus sign) *Some models might have a slightly different path 


reference:
https://productioncommunity.publicmobile.ca/t5/Phones-Hardware/How-do-I-setup-data-and-APN-on-my-Android-phone/m-p/87#M9
https://productioncommunity.publicmobile.ca/t5/Plans-Add-Ons/Data-not-working/m-p/18384#M1995

Sunday, 19 January 2020

NativeBase Card

import React from 'react';
import { Image } from 'react-native';
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion, Card, CardItem, Thumbnail
} from 'native-base';

export default function App() {
  return (
    <Container>
      <Header>
        <Body>
          <Title>Card</Title>
        </Body>
      </Header>
      <Content>
        <Card style={{ flex: 0 }}>
          <CardItem bordered>
            <Left>
              <Thumbnail source={require('./image/thumbnail.png')} />
              <Body>
                <Text>NativeBase</Text>
                <Text note>Jan 19, 2020</Text>
              </Body>
            </Left>
          </CardItem>
          <CardItem bordered>
            <Body style={{ alignItems: 'center' }}>
              <Image
                source={{ uri: 'https://c-5uwzmx78pmca90x24quo-a-uav-kwux2eisiuiqhmlx2evmb.g01.msn.com/g00/3_c-5eee.uav.kwu_/c-5UWZMXPMCA90x24pbbx78ax3ax2fx2fquo-a-uav-kwu.isiuiqhml.vmbx2fbmvivbx2fiux78x2fmvbqbgqlx2fIIQXMAU.quox3fpx3d527x26ex3d9901x26ux3d4x26yx3d48x26cx3dbx26wx3dnx26tx3dnx26q98k.uizsx3dquiom_$/$/$/$/$' }}
                style={{ height: 200, width: 200, flex: 1 }} />
              <Text>
                Card Showcase is further customization of Card Image. It uses several different items.
                Begins with the Card List component, which is similar to our List Avatar.
                Make use of Left, Body and Right components to align the content of your Card header.
                To mixup Image with other NativeBase components in a single CardItem, include the content within Body component.
                </Text>
            </Body>
          </CardItem>
          <CardItem>
            <Left>
              <Button transparent>
                <Icon active name="thumbs-up" />
                <Text>12 Likes</Text>
              </Button>
            </Left>
            <Body>
              <Button transparent>
                <Icon active name="chatbubbles" />
                <Text>4 Comments</Text>
              </Button>
            </Body>
            <Right>
              <Text>1h ago</Text>
            </Right>
          </CardItem>
        </Card>
      </Content>
    </Container>
  );
}

reference:
https://facebook.github.io/react-native/docs/image
https://facebook.github.io/react-native/docs/images
https://docs.nativebase.io/Components.html#card-image-headref

NativeBase Button


import React from 'react';
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion,
} from 'native-base';

export default function App() {
  return (
    <Container>
      <Header>
        <Body>
          <Title>Button</Title>
        </Body>
      </Header>
      <Content padder>
        <Button rounded dark style={{ width: 100, justifyContent: 'center' }}
          onPress={() => alert('button pressed')}
          onLongPress={() => alert('long press')}
        ><Text> Round </Text></Button>

        <Button bordered large danger style={{ width: 200, justifyContent: 'center' }}>
          <Text>boardered</Text>
        </Button>

        <Button small iconLeft success style={{ width: 100, justifyContent: 'center' }}>
          <Icon name='beer' />
          <Text>Pub</Text>
        </Button>

        <Button disabled style={{ width: 60, justifyContent: 'center' }}>
          <Icon name='cog' />
        </Button>
      </Content>
    </Container>
  );
}


NativeBase Accordion



import React from 'react';
import {
  Container, Header, Title, Content, Footer,
  FooterTab, Button, Left, Right, Body, Icon, Text,
  Accordion
} from 'native-base';

const dataArray = [
  { title: "First Element", content: "Lorem ipsum dolor sit amet" },
  { title: "Second Element", content: "Lorem ipsum dolor sit amet" },
  { title: "Third Element", content: "Lorem ipsum dolor sit amet" }
];

export default function App() {
  return (
    <Container>
      <Header>
        <Body>
          <Title>Accordion</Title>
        </Body>
      </Header>
      <Content padder>
        <Accordion dataArray={dataArray} icon="add" expandedIcon="remove"
          iconStyle={{ color: "green" }}
          expandedIconStyle={{ color: "red" }}
          headerStyle={{ backgroundColor: "#b7daf8" }}
          contentStyle={{ backgroundColor: "#ddecf8" }} />
      </Content>
    </Container>
  );
}