yosadade

login.js

Jun 16th, 2020
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. import React, {useEffect} from 'react';
  2. import {StyleSheet, View, Image, Text} from 'react-native';
  3. import {Header, Gap, Button, StatusBar, Input} from '../../components';
  4. import {colors, fonts} from '../../utils';
  5. import {ILLoginAtas, ILLogoTanpaRiba} from '../../assets';
  6. import {TouchableOpacity} from 'react-native-gesture-handler';
  7.  
  8. const Login = ({navigation}) => {
  9. useEffect(() => {
  10. getDataLogin();
  11. });
  12. const getDataLogin = () => {
  13. fetch('http://api.tanpariba.co.id:8000/v4.0/account/login', {
  14. method: 'POST',
  15. headers: {
  16. Authorization:
  17. 'Basic dXNtYW5ydWJpYW50b3JvcW9kcnFvZHJiZWV3b293YToyNjM3NmVkeXV3OWUwcmkzNDl1ZA==',
  18. 'Content-Type': 'application/json',
  19. },
  20. 'body form-data': JSON.stringify({
  21. user: 'ngadimin',
  22. pass: 'h4oejsgmQ#6ChYBtDb',
  23. }),
  24. })
  25. .then(response => response.json())
  26. .then(json => {
  27. console.log(json.data);
  28. })
  29. .catch(err => {
  30. console.log(err);
  31. });
  32. };
  33. return (
  34. <View style={styles.page}>
  35. <RenderStatusBar />
  36. <RenderHeaderSection navigation={navigation} />
  37. <RenderContentSection navigation={navigation} />
  38. </View>
  39. );
  40. };
  41.  
  42. const RenderStatusBar = () => {
  43. return <StatusBar type="secondary" />;
  44. };
  45.  
  46. const RenderHeaderSection = ({navigation}) => {
  47. return (
  48. <>
  49. <View style={styles.topOrnament}>
  50. <Image source={ILLoginAtas} style={styles.image} />
  51. </View>
  52. <Header
  53. icon="back-light"
  54. onPress={() => navigation.goBack()}
  55. title="Daftar Sekarang"
  56. />
  57. <View style={styles.wrapperTitle}>
  58. <Text style={styles.title}>Masuk Akun</Text>
  59. </View>
  60. </>
  61. );
  62. };
  63.  
  64. const RenderContentSection = ({navigation}) => {
  65. return (
  66. <View style={styles.content}>
  67. <Gap height={80} />
  68. <View style={styles.wrapperLogo}>
  69. <Image source={ILLogoTanpaRiba} style={styles.logo} />
  70. </View>
  71. <Gap height={20} />
  72. <Input label="Username / Email" />
  73. <Input label="Password" />
  74. <Gap height={40} />
  75. <Button
  76. title="MASUK"
  77. type="secondary"
  78. onPress={() => navigation.navigate('MainApp')}
  79. />
  80. <Gap height={10} />
  81. <TouchableOpacity>
  82. <Text style={styles.ask}>Lupa Password</Text>
  83. </TouchableOpacity>
  84. </View>
  85. );
  86. };
  87.  
  88. export default Login;
  89.  
  90. const styles = StyleSheet.create({
  91. page: {
  92. flex: 1,
  93. backgroundColor: colors.primary,
  94. },
  95. topOrnament: {
  96. position: 'absolute',
  97. bottom: 500,
  98. },
  99. image: {
  100. width: 450,
  101. height: 300,
  102. },
  103. content: {
  104. padding: 40,
  105. paddingTop: 0,
  106. },
  107. wrapperLogo: {
  108. alignItems: 'center',
  109. },
  110. logo: {
  111. height: 100,
  112. width: 270,
  113. },
  114. ask: {
  115. fontSize: 20,
  116. fontFamily: fonts.primary[600],
  117. color: colors.text.tertiary,
  118. textAlign: 'center',
  119. },
  120. wrapperTitle: {
  121. paddingHorizontal: 40,
  122. width: 200,
  123. },
  124. title: {
  125. fontSize: 30,
  126. fontFamily: fonts.primary[900],
  127. color: colors.primary,
  128. },
  129. });
Add Comment
Please, Sign In to add comment