RegisterScreen.jsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import * as WebBrowser from 'expo-web-browser';
  2. import * as React from 'react';
  3. import { StyleSheet, View } from 'react-native';
  4. import { WingBlank, InputItem } from '@ant-design/react-native';
  5. import { Caption, Paragraph } from 'react-native-paper';
  6. import { Div } from 'react-native-magnus';
  7. import useModel from 'flooks';
  8. import { useCreation } from '@umijs/hooks';
  9. import user from '../../flooks/User';
  10. import Header from '../../components/Header';
  11. import Button from '../../components/Button';
  12. export default function RegisterScreen() {
  13. const [phone, setphone] = React.useState();
  14. const [password, setPassword] = React.useState();
  15. const { loginByRegister } = useModel(user, []);
  16. const canSubmit = useCreation(() => {
  17. if (password && phone) {
  18. return true;
  19. } else {
  20. return false;
  21. }
  22. }, [phone, password]);
  23. return (
  24. <Div flex={1} bg="white">
  25. <Header title="用户注册" />
  26. <View style={styles.list}>
  27. <WingBlank>
  28. <View>
  29. <InputItem
  30. clear
  31. type="phone"
  32. value={phone}
  33. onChange={setphone}
  34. placeholder="输入手机号"
  35. style={{ fontSize: 14 }}
  36. >
  37. <Paragraph>手机号</Paragraph>
  38. </InputItem>
  39. <InputItem
  40. clear
  41. type="password"
  42. value={password}
  43. onChange={setPassword}
  44. placeholder="输入密码"
  45. style={{ fontSize: 14 }}
  46. >
  47. <Paragraph>密码</Paragraph>
  48. </InputItem>
  49. <View style={[styles.btn]}>
  50. <Button
  51. disabled={!canSubmit}
  52. size="normal"
  53. style={styles.btn}
  54. onPress={() => loginByRegister(phone, password)}
  55. block
  56. >
  57. 确定
  58. </Button>
  59. </View>
  60. </View>
  61. </WingBlank>
  62. </View>
  63. </Div>
  64. );
  65. }
  66. const styles = StyleSheet.create({
  67. list: {
  68. backgroundColor: '#fff',
  69. borderWidth: 0,
  70. flex: 1,
  71. paddingTop: 20,
  72. },
  73. btn: {
  74. marginTop: 40,
  75. },
  76. });