· 8 years ago · Mar 15, 2018, 11:28 AM
1import React, { Component } from 'react';
2import { Container, Header, Title, Content, Footer, FooterTab, Button, Left, Right,
3Body, Icon, Text } from 'native-base';
4import Expo, { Font } from 'expo';
5import TodoList from './TodoList';
6import AddTaskButton from './AddTaskButton';
7import DeleteTasksButton from './DeleteTasksButton';
8import { StatusBar, Alert } from 'react-native';
9import Database from './database';
10export default class MainScreen extends Component {
11 static navigationOptions = { title: 'Welcome', header: null };
12
13 constructor(props) {
14 super(props);
15 this.state = { loading: true };
16 }
17
18 async componentWillMount() {
19 await Expo.Font.loadAsync({
20 'Roboto': require('native-base/Fonts/Roboto.ttf'),
21 'Roboto_medium': require('native-base/Fonts/Roboto_medium.ttf'),
22 });
23
24 this.setState({ loading: false });
25 }
26
27 componentDidMount(){
28 Database.getConnection().transaction(tx => {
29 tx.executeSql(
30 'CREATE TABLE IF NOT EXISTS task ( id INTEGER PRIMARY KEY AUTOINCREMENT, text TEXT NOT NULL DEFAULT "No Text" );'
31 );
32 })
33 }
34
35
36 render(){
37 if(this.state.loading){
38 return <Expo.AppLoading />;
39 }
40 return (
41 <Container>
42 <StatusBar hidden={true}/>
43 <Header>
44 <Right>
45 <AddTaskButton />
46 <DeleteTasksButton />
47 </Right>
48 </Header>
49 <Content>
50 <TodoList />
51 </Content>
52 </Container>
53 )
54 }
55}