diff --git a/app/mobile/src/access/login/Login.jsx b/app/mobile/src/access/login/Login.jsx index 6ffd5733..8e2fe543 100644 --- a/app/mobile/src/access/login/Login.jsx +++ b/app/mobile/src/access/login/Login.jsx @@ -1,19 +1,61 @@ -import Ionicons from '@expo/vector-icons/Ionicons'; -import { Text } from 'react-native'; -import { Wrapper, Container, Control, Title, Spacer, Header } from './Login.styled'; +import { Text, TextInput, View, TouchableOpacity } from 'react-native'; +import { styles } from './Login.styled'; +import Ionicons from '@expo/vector-icons/AntDesign'; +import { useLogin } from './useLogin.hook'; export function Login() { + + const { state, actions } = useLogin(); + return ( - - - - - - Databag - -
Login
-
-
-
+ + + + + + + + Databag + + Login + + + + + + + + + + + + + + + { state.enabled && ( + + Login + + )} + { !state.enabled && ( + + Login + + )} + { state.createable && ( + + Create Account + + )} + { !state.createable && ( + + Create Account + + )} + + + ); } diff --git a/app/mobile/src/access/login/Login.styled.js b/app/mobile/src/access/login/Login.styled.js new file mode 100644 index 00000000..89be9d95 --- /dev/null +++ b/app/mobile/src/access/login/Login.styled.js @@ -0,0 +1,113 @@ +import { StyleSheet } from 'react-native'; +import { Colors } from 'constants/Colors'; + +export const styles = StyleSheet.create({ + wrapper: { + width: '100%', + height: '100%', + }, + config: { + paddingTop: 8, + }, + icon: { + padding: 8, + }, + space: { + width: 32, + }, + container: { + flexDirection: 'column', + backgroundColor: Colors.formBackground, + borderRadius: 4, + width: '100%', + height: '100%', + display: 'flex', + paddingLeft: 16, + paddingRight: 16, + }, + control: { + display: 'flex', + flexDirection: 'row', + justifyContent: 'flex-end', + color: Colors.grey, + }, + title: { + width: '100%', + textAlign: 'center', + fontSize: 24, + color: Colors.grey, + }, + spacemid: { + flexGrow: 1, + flexDirection: 'column', + textAlign: 'center', + alignItems: 'center', + justifyContent: 'center', + width: '100%', + }, + spacetop: { + flexGrow: 1, + flexDirection: 'column', + textAlign: 'center', + alignItems: 'center', + justifyContent: 'flex-start', + width: '100%', + }, + header: { + fontSize: 32, + color: Colors.text, + }, + inputwrapper: { + display: 'flex', + flexDirection: 'row', + width: '100%', + borderRadius: 4, + borderColor: Colors.divider, + borderWidth: 1, + marginBottom: 16, + alignItems: 'center', + }, + inputfield: { + flex: 1, + textAlign: 'center', + padding: 8, + }, + login: { + marginTop: 16, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + width: 128, + height: 28, + backgroundColor: Colors.primary, + borderRadius: 4, + }, + logintext: { + color: Colors.formFocus, + }, + nologin: { + marginTop: 16, + display: 'flex', + alignItems: 'center', + justifyContent: 'center', + width: 128, + height: 28, + borderRadius: 4, + borderColor: Colors.divider, + borderWidth: 1, + }, + nologintext: { + color: Colors.disabled, + }, + create: { + marginTop: 16, + }, + createtext: { + fontColor: 'yellow', + }, + nocreatetext: { + color: Colors.disabled, + }, + +}) + diff --git a/app/mobile/src/access/login/Login.styled.jsx b/app/mobile/src/access/login/Login.styled.jsx deleted file mode 100644 index eae80a1f..00000000 --- a/app/mobile/src/access/login/Login.styled.jsx +++ /dev/null @@ -1,44 +0,0 @@ -import styled from 'styled-components/native'; -import { Colors } from 'constants/Colors'; - -export const Wrapper = styled.View` - width: 100%; - height: 100%; -` - -export const Container = styled.View` - background-color: ${Colors.formBackground}; - border-radius: 4px; - width: 100%; - height: 100%; - display: flex; - flex-direction: column; -` - -export const Control = styled.View` - display: flex; - flex-direction: row; - justify-content: flex-end; - color: ${Colors.grey}; -` - -export const Title = styled.Text` - width: 100%; - text-align: center; - fontSize: 24px; - color: ${Colors.grey}; -` - -export const Spacer = styled.View` - flex-grow: 1; - text-align: center; - align-items: center; - justify-content: center; - width: 100%; -` - -export const Header = styled.Text` - font-size: 32px; - color: ${Colors.text}; -` - diff --git a/app/mobile/src/access/login/useLogin.hook.js b/app/mobile/src/access/login/useLogin.hook.js new file mode 100644 index 00000000..48b4ff16 --- /dev/null +++ b/app/mobile/src/access/login/useLogin.hook.js @@ -0,0 +1,43 @@ +import { useState, useEffect } from 'react'; +import { useWindowDimensions } from 'react-native'; +import { useNavigate } from 'react-router-dom'; + +export function useLogin() { + + const navigate = useNavigate(); + + const [state, setState] = useState({ + createable: false, + enabled: false, + login: null, + password: null, + }); + + const updateState = (value) => { + setState((s) => ({ ...s, ...value })); + } + + useEffect(() => { + if (state.password && state.login && !state.enabled) { + updateState({ enabled: true }); + } + if ((!state.password || !state.login) && state.enabled) { + updateState({ enabled: false }); + } + }, [state.login, state.password]); + + const actions = { + config: () => { + navigate('/admin'); + }, + setLogin: (login) => { + updateState({ login }); + }, + setPassword: (password) => { + updateState({ password }); + }, + }; + + return { state, actions }; +} + diff --git a/app/mobile/src/constants/Colors.js b/app/mobile/src/constants/Colors.js index dab2017f..98935776 100644 --- a/app/mobile/src/constants/Colors.js +++ b/app/mobile/src/constants/Colors.js @@ -11,6 +11,7 @@ export const Colors = { encircle: '#cccccc', alert: '#ff8888', enabled: '#444444', + lightgrey: '#bbbbbb', disabled: '#aaaaaa', text: '#444444', link: '#0077CC',