Hello. This will be the first part in creating our mobile application.
We will do a mobile application using react native and expo. We will not create a great news application. For this we will use php via rest api.
In our application, we will display articles that will be in phpmyadmin.
What is expo?
Expo, is a set of tools, libraries and services that allow you to create your own applications for iOS and Android using JavaScript. It sounds promising. Simply put, Expo helps you view projects while you are still developing them. The Expo CLI creates a development URL (similar to a local host on the Internet) that can then be opened in the Expo client to preview the application.
Expo Installation
Before installing expo, make sure you install npm.
npm install expo-cli โglobal
Install expo on iphone
Install expo on android
Expo gives you options. You can preview your application through the Expo client application on your mobile device or using the iOS / Android simulator on your computer. When creating the application, I used expo on android.
Creating an expo application
epxo init
After installing Expo, the Expo CLI interface opens and allows you to select the project name and template. We will choose a blank page.
cd newsApp expo start โtunnel
After that, expo will launch the local development server, open a new window for viewing the server and provide you with a QR code to open your project on your mobile device. Or you can register in the mobile application and expo cli, and it will automatically show the current developments in the mobile application.
To enter expo on your computer use this command:
expo login
Install react-navigation
So that we can switch from one screen to another, we need to download react-nativation:
yarn add react-nativation
Development start
Now let's start our development.
The first thing we will do is open App.js (our main file).
Layout
To make our application look attractive, we will add a couple of elements and add styles to them.
First, add the header:
render() { return ( <SafeAreaView style={styles.MainContainer}> <ScrollView > <Text style={styles.textTitle}>:</Text> </ScrollView> </SafeAreaView> ); } const styles = StyleSheet.create({ textTitle :{fontSize:22,fontFamily: 'Roboto-M',fontWeight:'700', padding:10}, });
Now let's add a block with the output of articles and style it.
import * as React from 'react'; import { View, Text, SafeAreaView, StyleSheet, Image, Dimensions, ScrollView } from 'react-native'; import Icon from 'react-native-vector-icons/Ionicons' export default class App extends React.Component { constructor(props) { super(props); this.state = { isLoading: true, fontLoaded: false } } async componentDidMount() { return fetch('http://rapprogtrain.com/server-side/test.php') .then((response) => response.json()) .then((responseJson) => { this.setState({ isLoading: false, dataSource: responseJson }, function() {
At this our lesson ends.
In the next lesson, we will output the mysql data.
If you are interested in how it works, go and download this application, there will be a tab with news - a
mobile application
My website is
http://rapprogtrain.com
I
vk and
twitter