1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
'use strict' import React, { Component } from 'react' ; import { AppRegistry, StyleSheet, Text, View, TextInput } from 'react-native' ; let Dimensions = require( 'Dimensions' ); let totalWidth = Dimensions.get( 'window' ).width; let leftStartPoint = totalWidth * 0.1; let componetWidth = totalWidth * 0.8; let Register = React.createClass({ getInitialState: function (){ return { inputedNum : '' , inputedPW: '' , }, updatePW: function (newText){ this .setState({inputedPW : newText}); }, render: function () { return ( <View style={styles.container}> <TextInput style = {styles.numberInputStyle} placeholder = { '請輸入手機號' } onChangeText = {(aa) => this .setState({inputedNum :aa})}/> <Text style={styles.textPromptStyle}> 您輸入的手機號:{ this .state.inputedNum} </Text> <TextInput style={styles.passwordInputStyle} placeholder = { '請輸入密碼' } password = { true } onChangeText = {(newText) => this .updatePW(newText)}/> <Text style={styles.bigTextPrompt} onPress = { this .userRegister}> 注 冊 </Text> </View>); }, userRegister: function (){ this .props.navigator.replace({ telephoneNumber : this .state.inputedNum, name: 'registerResult' , }); } }); const styles = StyleSheet.create({ container: { flex: 1, flexDirection: 'column' , justifyContent: 'center' , backgroundColor: '#F5FCFF' , }, numberInputStyle:{ top:20, left:leftStartPoint, width:componetWidth, backgroundColor: 'gray' , fontSize:20 }, textPromptStyle:{ top:30, left:leftStartPoint, width:componetWidth, fontSize:20 }, passwordInputStyle:{ top:50, left:leftStartPoint, width:componetWidth, backgroundColor: 'gray' , fontSize:20 }, bigTextPrompt:{ top:70, left:leftStartPoint, width:componetWidth, backgroundColor: 'gray' , color: 'white' , textAlign: 'center' , fontSize:60 } }); module.exports = Register; |