Wednesday, December 12, 2018

ວິທີເຮັດ pull to refresh

step 1: import ສ່ວນທີ່ຕ້ອງການຈະໃຊ້
import { RefreshControl } from "react-native";
step 2: ສ້າງຄ່າ state ເພື່ອຮອງຮັບການປ່ຽນແປງ
this.state = {refreshing: false}
step 3: ເພີ່ມ refresh control ເຂົ້າໄປໃນ View ທີ່ຕ້ອງການ
refreshControl={
<RefreshControl
refreshing={this.state.refreshing}
onRefresh={() => this.onRefresh()}
/>
}
step 4: ສ້າງ function ທີ່ຕ້ອງການ
  async onRefresh() {
    this.setState({ refreshing: true });
      {
           ຣີໂຫລດ ແລະ this.setState({ refreshing: false});
      }
  }

Saturday, December 1, 2018

ສ້າງແອັບງ່າຍໆ ແອັບນັບເລກ ດ້ວຍ React native


 ຕົວຢ່າງ Code ຂອງແອັບ ນັບເລກ ແບບ Basic ທີ່ສຸດ:

/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow
*/

code ຂອງ file App.js

import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, TouchableOpacity } from 'react-native';

export default class App extends Component {
constructor(props) {
super(props);
this.state = {
number: 0
}
}
render() {
return (
<View style={styles.container}>
<Text>Number Counter</Text>
<Text style={{ fontSize: 100, fontWeight: 'bold', color: 'red' }}>{this.state.number}</Text>
<View style={{ flexDirection: 'row' }}>
<TouchableOpacity
onPress={() => this.coutUp()}
style={{
alignContent: 'center',
justifyContent: 'center',
backgroundColor: 'green',
paddingTop: 10,
paddingBottom: 10,
paddingLeft: 30,
paddingRight: 30,
borderRadius: 5,
width: 100
}}>
<Text style={{ alignSelf: 'center', color: 'white' }}>up</Text>
</TouchableOpacity>
<TouchableOpacity
onPress={() => this.coutDown()}
style={{
alignContent: 'center',
justifyContent: 'center',
backgroundColor: 'red',
paddingTop: 10,
paddingBottom: 10,
paddingLeft: 30,
paddingRight: 30,
borderRadius: 5,
width: 100
}}>
<Text style={{ alignSelf: 'center', color: 'white' }}>down</Text>
</TouchableOpacity>
</View>
</View >
);
}
coutUp() {
this.setState({ number: this.state.number + 1 });
}
coutDown() {
if (this.state.number > 0) {
this.setState({ number: this.state.number - 1 });
}

}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});

ສົນໃຈຮຽນ ຕິດຕໍ່ SCDev

Wanmai Policy 1. ຂໍ້ກຳນົດທາງດ້ານຂໍ້ມູນຜູ້ໃຊ້ * ຂໍ້ມູນທີ່ພວກເຮົາເກັບໄວ້: - ເມື່ອຜູ້ໃຊ້ລົງທະບຽນເພື່ອເຂົ້າໃຊ້ງານລະບົບພວກເຮົາໄດ້ເກັບຂໍ້ມູນຂອງຜູ້...