From ec613141d8ad35e83c3053248dfd4008db0979b1 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 7 Sep 2022 14:21:45 -0700 Subject: [PATCH] adding login screen --- app/mobile/App.js | 13 +++--- app/mobile/access/Access.jsx | 4 -- app/mobile/root/Root.jsx | 3 -- app/mobile/src/access/Access.jsx | 44 +++++++++++++++++++ app/mobile/src/access/Access.styled.js | 32 ++++++++++++++ app/mobile/src/access/create/Create.jsx | 4 ++ app/mobile/src/access/login/Login.jsx | 12 +++++ app/mobile/src/access/login/Login.styled.jsx | 14 ++++++ app/mobile/src/access/useAccess.hook.js | 29 ++++++++++++ app/mobile/{ => src}/admin/Admin.jsx | 0 app/mobile/{ => src}/api/addAccount.js | 0 app/mobile/{ => src}/api/addAccountAccess.js | 0 app/mobile/{ => src}/api/addAccountCreate.js | 0 app/mobile/{ => src}/api/addCard.js | 0 app/mobile/{ => src}/api/addChannel.js | 0 app/mobile/{ => src}/api/addChannelTopic.js | 0 .../{ => src}/api/addContactChannelTopic.js | 0 app/mobile/{ => src}/api/clearChannelCard.js | 0 app/mobile/{ => src}/api/createAccount.js | 0 app/mobile/{ => src}/api/fetchUtil.js | 0 .../{ => src}/api/getAccountImageUrl.js | 0 app/mobile/{ => src}/api/getAccountStatus.js | 0 app/mobile/{ => src}/api/getAvailable.js | 0 .../{ => src}/api/getCardCloseMessage.js | 0 app/mobile/{ => src}/api/getCardDetail.js | 0 app/mobile/{ => src}/api/getCardImageUrl.js | 0 .../{ => src}/api/getCardOpenMessage.js | 0 app/mobile/{ => src}/api/getCardProfile.js | 0 app/mobile/{ => src}/api/getCards.js | 0 app/mobile/{ => src}/api/getChannelDetail.js | 0 app/mobile/{ => src}/api/getChannelSummary.js | 0 app/mobile/{ => src}/api/getChannelTopic.js | 0 .../{ => src}/api/getChannelTopicAssetUrl.js | 0 app/mobile/{ => src}/api/getChannelTopics.js | 0 app/mobile/{ => src}/api/getChannels.js | 0 .../{ => src}/api/getContactChannelDetail.js | 0 .../{ => src}/api/getContactChannelSummary.js | 0 .../{ => src}/api/getContactChannelTopic.js | 0 .../api/getContactChannelTopicAssetUrl.js | 0 .../{ => src}/api/getContactChannelTopics.js | 0 .../{ => src}/api/getContactChannels.js | 0 app/mobile/{ => src}/api/getContactProfile.js | 0 app/mobile/{ => src}/api/getGroups.js | 0 app/mobile/{ => src}/api/getListing.js | 0 .../{ => src}/api/getListingImageUrl.js | 0 app/mobile/{ => src}/api/getListingMessage.js | 0 app/mobile/{ => src}/api/getNodeAccounts.js | 0 app/mobile/{ => src}/api/getNodeConfig.js | 0 app/mobile/{ => src}/api/getNodeStatus.js | 0 app/mobile/{ => src}/api/getProfile.js | 0 .../{ => src}/api/getProfileImageUrl.js | 0 app/mobile/{ => src}/api/getUsername.js | 0 app/mobile/{ => src}/api/package.json | 0 app/mobile/{ => src}/api/removeAccount.js | 0 app/mobile/{ => src}/api/removeCard.js | 0 app/mobile/{ => src}/api/removeChannel.js | 0 .../{ => src}/api/removeChannelTopic.js | 0 .../{ => src}/api/removeContactChannel.js | 0 .../api/removeContactChannelTopic.js | 0 app/mobile/{ => src}/api/setAccountAccess.js | 0 app/mobile/{ => src}/api/setAccountLogin.js | 0 .../{ => src}/api/setAccountSearchable.js | 0 app/mobile/{ => src}/api/setAccountStatus.js | 0 .../{ => src}/api/setCardCloseMessage.js | 0 .../{ => src}/api/setCardOpenMessage.js | 0 app/mobile/{ => src}/api/setCardProfile.js | 0 app/mobile/{ => src}/api/setCardStatus.js | 0 app/mobile/{ => src}/api/setChannelCard.js | 0 app/mobile/{ => src}/api/setChannelSubject.js | 0 .../{ => src}/api/setChannelTopicAsset.js | 0 .../{ => src}/api/setChannelTopicSubject.js | 0 .../api/setContactChannelTopicAsset.js | 0 .../api/setContactChannelTopicSubject.js | 0 app/mobile/{ => src}/api/setLogin.js | 0 app/mobile/{ => src}/api/setNodeConfig.js | 0 app/mobile/{ => src}/api/setNodeStatus.js | 0 app/mobile/{ => src}/api/setProfileData.js | 0 app/mobile/{ => src}/api/setProfileImage.js | 0 app/mobile/src/constants/Colors.js | 37 ++++++++++++++++ app/mobile/src/constants/package.json | 3 ++ app/mobile/{ => src}/context/AppContext.js | 0 app/mobile/{ => src}/context/package.json | 0 .../{ => src}/context/useAppContext.hook.js | 42 +++++++++--------- app/mobile/src/package.json | 3 ++ app/mobile/src/root/Root.jsx | 7 +++ app/mobile/src/root/Root.styled.js | 8 ++++ app/mobile/src/root/useRoot.hook.js | 30 +++++++++++++ app/mobile/{ => src}/session/Session.jsx | 0 88 files changed, 251 insertions(+), 34 deletions(-) delete mode 100644 app/mobile/access/Access.jsx delete mode 100644 app/mobile/root/Root.jsx create mode 100644 app/mobile/src/access/Access.jsx create mode 100644 app/mobile/src/access/Access.styled.js create mode 100644 app/mobile/src/access/create/Create.jsx create mode 100644 app/mobile/src/access/login/Login.jsx create mode 100644 app/mobile/src/access/login/Login.styled.jsx create mode 100644 app/mobile/src/access/useAccess.hook.js rename app/mobile/{ => src}/admin/Admin.jsx (100%) rename app/mobile/{ => src}/api/addAccount.js (100%) rename app/mobile/{ => src}/api/addAccountAccess.js (100%) rename app/mobile/{ => src}/api/addAccountCreate.js (100%) rename app/mobile/{ => src}/api/addCard.js (100%) rename app/mobile/{ => src}/api/addChannel.js (100%) rename app/mobile/{ => src}/api/addChannelTopic.js (100%) rename app/mobile/{ => src}/api/addContactChannelTopic.js (100%) rename app/mobile/{ => src}/api/clearChannelCard.js (100%) rename app/mobile/{ => src}/api/createAccount.js (100%) rename app/mobile/{ => src}/api/fetchUtil.js (100%) rename app/mobile/{ => src}/api/getAccountImageUrl.js (100%) rename app/mobile/{ => src}/api/getAccountStatus.js (100%) rename app/mobile/{ => src}/api/getAvailable.js (100%) rename app/mobile/{ => src}/api/getCardCloseMessage.js (100%) rename app/mobile/{ => src}/api/getCardDetail.js (100%) rename app/mobile/{ => src}/api/getCardImageUrl.js (100%) rename app/mobile/{ => src}/api/getCardOpenMessage.js (100%) rename app/mobile/{ => src}/api/getCardProfile.js (100%) rename app/mobile/{ => src}/api/getCards.js (100%) rename app/mobile/{ => src}/api/getChannelDetail.js (100%) rename app/mobile/{ => src}/api/getChannelSummary.js (100%) rename app/mobile/{ => src}/api/getChannelTopic.js (100%) rename app/mobile/{ => src}/api/getChannelTopicAssetUrl.js (100%) rename app/mobile/{ => src}/api/getChannelTopics.js (100%) rename app/mobile/{ => src}/api/getChannels.js (100%) rename app/mobile/{ => src}/api/getContactChannelDetail.js (100%) rename app/mobile/{ => src}/api/getContactChannelSummary.js (100%) rename app/mobile/{ => src}/api/getContactChannelTopic.js (100%) rename app/mobile/{ => src}/api/getContactChannelTopicAssetUrl.js (100%) rename app/mobile/{ => src}/api/getContactChannelTopics.js (100%) rename app/mobile/{ => src}/api/getContactChannels.js (100%) rename app/mobile/{ => src}/api/getContactProfile.js (100%) rename app/mobile/{ => src}/api/getGroups.js (100%) rename app/mobile/{ => src}/api/getListing.js (100%) rename app/mobile/{ => src}/api/getListingImageUrl.js (100%) rename app/mobile/{ => src}/api/getListingMessage.js (100%) rename app/mobile/{ => src}/api/getNodeAccounts.js (100%) rename app/mobile/{ => src}/api/getNodeConfig.js (100%) rename app/mobile/{ => src}/api/getNodeStatus.js (100%) rename app/mobile/{ => src}/api/getProfile.js (100%) rename app/mobile/{ => src}/api/getProfileImageUrl.js (100%) rename app/mobile/{ => src}/api/getUsername.js (100%) rename app/mobile/{ => src}/api/package.json (100%) rename app/mobile/{ => src}/api/removeAccount.js (100%) rename app/mobile/{ => src}/api/removeCard.js (100%) rename app/mobile/{ => src}/api/removeChannel.js (100%) rename app/mobile/{ => src}/api/removeChannelTopic.js (100%) rename app/mobile/{ => src}/api/removeContactChannel.js (100%) rename app/mobile/{ => src}/api/removeContactChannelTopic.js (100%) rename app/mobile/{ => src}/api/setAccountAccess.js (100%) rename app/mobile/{ => src}/api/setAccountLogin.js (100%) rename app/mobile/{ => src}/api/setAccountSearchable.js (100%) rename app/mobile/{ => src}/api/setAccountStatus.js (100%) rename app/mobile/{ => src}/api/setCardCloseMessage.js (100%) rename app/mobile/{ => src}/api/setCardOpenMessage.js (100%) rename app/mobile/{ => src}/api/setCardProfile.js (100%) rename app/mobile/{ => src}/api/setCardStatus.js (100%) rename app/mobile/{ => src}/api/setChannelCard.js (100%) rename app/mobile/{ => src}/api/setChannelSubject.js (100%) rename app/mobile/{ => src}/api/setChannelTopicAsset.js (100%) rename app/mobile/{ => src}/api/setChannelTopicSubject.js (100%) rename app/mobile/{ => src}/api/setContactChannelTopicAsset.js (100%) rename app/mobile/{ => src}/api/setContactChannelTopicSubject.js (100%) rename app/mobile/{ => src}/api/setLogin.js (100%) rename app/mobile/{ => src}/api/setNodeConfig.js (100%) rename app/mobile/{ => src}/api/setNodeStatus.js (100%) rename app/mobile/{ => src}/api/setProfileData.js (100%) rename app/mobile/{ => src}/api/setProfileImage.js (100%) create mode 100644 app/mobile/src/constants/Colors.js create mode 100644 app/mobile/src/constants/package.json rename app/mobile/{ => src}/context/AppContext.js (100%) rename app/mobile/{ => src}/context/package.json (100%) rename app/mobile/{ => src}/context/useAppContext.hook.js (73%) create mode 100644 app/mobile/src/package.json create mode 100644 app/mobile/src/root/Root.jsx create mode 100644 app/mobile/src/root/Root.styled.js create mode 100644 app/mobile/src/root/useRoot.hook.js rename app/mobile/{ => src}/session/Session.jsx (100%) diff --git a/app/mobile/App.js b/app/mobile/App.js index 265043a1..255464fc 100644 --- a/app/mobile/App.js +++ b/app/mobile/App.js @@ -1,15 +1,14 @@ -import { StatusBar } from 'expo-status-bar'; import React from 'react'; -import { StyleSheet, Text, View } from 'react-native'; -import { AppContextProvider } from 'context/AppContext'; import { NativeRouter } from "react-router-native"; import { Routes, Route } from 'react-router-dom'; -import { Root } from './root/Root'; -import { Access } from './access/Access'; -import { Session } from './session/Session'; -import { Admin } from './admin/Admin'; +import { Root } from 'src/root/Root'; +import { Access } from 'src/access/Access'; +import { Session } from 'src/session/Session'; +import { Admin } from 'src/admin/Admin'; +import { AppContextProvider } from 'context/AppContext'; export default function App() { + return ( diff --git a/app/mobile/access/Access.jsx b/app/mobile/access/Access.jsx deleted file mode 100644 index 2576757f..00000000 --- a/app/mobile/access/Access.jsx +++ /dev/null @@ -1,4 +0,0 @@ -export function Access({ mode }) { - return <> -} - diff --git a/app/mobile/root/Root.jsx b/app/mobile/root/Root.jsx deleted file mode 100644 index 649017a7..00000000 --- a/app/mobile/root/Root.jsx +++ /dev/null @@ -1,3 +0,0 @@ -export function Root() { - return <> -} diff --git a/app/mobile/src/access/Access.jsx b/app/mobile/src/access/Access.jsx new file mode 100644 index 00000000..4d854d3a --- /dev/null +++ b/app/mobile/src/access/Access.jsx @@ -0,0 +1,44 @@ +import { SafeAreaView, View } from 'react-native'; +import { Wrapper, Container, PaddedPane, Pane, Splash } from './Access.styled'; +import { useAccess } from './useAccess.hook'; +import { Login } from './login/Login'; +import { Create } from './create/Create'; +import logo from 'images/login.png'; + +export function Access({ mode }) { + + const { state, actions } = useAccess(); + + return ( + + + { state.split === true && ( + + + + + + { mode === 'login' && ( + + )} + { mode === 'create' && ( + + )} + + + )} + { state.split === false && ( + + { mode === 'login' && ( + + )} + { mode === 'create' && ( + + )} + + )} + + + ); +} + diff --git a/app/mobile/src/access/Access.styled.js b/app/mobile/src/access/Access.styled.js new file mode 100644 index 00000000..ec0f6732 --- /dev/null +++ b/app/mobile/src/access/Access.styled.js @@ -0,0 +1,32 @@ +import styled from 'styled-components/native'; +import { Colors } from 'constants/Colors'; + +export const Wrapper = styled.View` + background-color: ${Colors.background}; + width: 100%; + height: 100%; +` + +export const Container = styled.View` + padding: 16px; + display: flex; + flex-direction: row; +` + +export const Splash = styled.Image` + flex: 1; + width: null; + height: null; + resize-mode: contain; +` + +export const Pane = styled.View` + width: 50%; + height: 100%; +` + +export const PaddedPane = styled.View` + width: 50%; + height: 100%; + padding-right: 16px; +` diff --git a/app/mobile/src/access/create/Create.jsx b/app/mobile/src/access/create/Create.jsx new file mode 100644 index 00000000..a5d90d18 --- /dev/null +++ b/app/mobile/src/access/create/Create.jsx @@ -0,0 +1,4 @@ +export function Create() { + return <> +} + diff --git a/app/mobile/src/access/login/Login.jsx b/app/mobile/src/access/login/Login.jsx new file mode 100644 index 00000000..040d6edd --- /dev/null +++ b/app/mobile/src/access/login/Login.jsx @@ -0,0 +1,12 @@ +import { Wrapper, Container } from './Login.styled'; +import { Text } from 'react-native'; + +export function Login() { + return ( + + + LOGIN + + + ); +} diff --git a/app/mobile/src/access/login/Login.styled.jsx b/app/mobile/src/access/login/Login.styled.jsx new file mode 100644 index 00000000..e487efb8 --- /dev/null +++ b/app/mobile/src/access/login/Login.styled.jsx @@ -0,0 +1,14 @@ +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%; +` diff --git a/app/mobile/src/access/useAccess.hook.js b/app/mobile/src/access/useAccess.hook.js new file mode 100644 index 00000000..35c93e65 --- /dev/null +++ b/app/mobile/src/access/useAccess.hook.js @@ -0,0 +1,29 @@ +import { useState, useEffect } from 'react'; +import { useWindowDimensions } from 'react-native'; + +export function useAccess() { + + const [state, setState] = useState({ + split: null, + }); + const dimensions = useWindowDimensions(); + + const updateState = (value) => { + setState((s) => ({ ...s, ...value })); + } + + useEffect(() => { + if (dimensions.width > 650) { + updateState({ split: true }); + } + else { + updateState({ split: false }); + } + }, [dimensions]); + + const actions = { + }; + + return { state, actions }; +} + diff --git a/app/mobile/admin/Admin.jsx b/app/mobile/src/admin/Admin.jsx similarity index 100% rename from app/mobile/admin/Admin.jsx rename to app/mobile/src/admin/Admin.jsx diff --git a/app/mobile/api/addAccount.js b/app/mobile/src/api/addAccount.js similarity index 100% rename from app/mobile/api/addAccount.js rename to app/mobile/src/api/addAccount.js diff --git a/app/mobile/api/addAccountAccess.js b/app/mobile/src/api/addAccountAccess.js similarity index 100% rename from app/mobile/api/addAccountAccess.js rename to app/mobile/src/api/addAccountAccess.js diff --git a/app/mobile/api/addAccountCreate.js b/app/mobile/src/api/addAccountCreate.js similarity index 100% rename from app/mobile/api/addAccountCreate.js rename to app/mobile/src/api/addAccountCreate.js diff --git a/app/mobile/api/addCard.js b/app/mobile/src/api/addCard.js similarity index 100% rename from app/mobile/api/addCard.js rename to app/mobile/src/api/addCard.js diff --git a/app/mobile/api/addChannel.js b/app/mobile/src/api/addChannel.js similarity index 100% rename from app/mobile/api/addChannel.js rename to app/mobile/src/api/addChannel.js diff --git a/app/mobile/api/addChannelTopic.js b/app/mobile/src/api/addChannelTopic.js similarity index 100% rename from app/mobile/api/addChannelTopic.js rename to app/mobile/src/api/addChannelTopic.js diff --git a/app/mobile/api/addContactChannelTopic.js b/app/mobile/src/api/addContactChannelTopic.js similarity index 100% rename from app/mobile/api/addContactChannelTopic.js rename to app/mobile/src/api/addContactChannelTopic.js diff --git a/app/mobile/api/clearChannelCard.js b/app/mobile/src/api/clearChannelCard.js similarity index 100% rename from app/mobile/api/clearChannelCard.js rename to app/mobile/src/api/clearChannelCard.js diff --git a/app/mobile/api/createAccount.js b/app/mobile/src/api/createAccount.js similarity index 100% rename from app/mobile/api/createAccount.js rename to app/mobile/src/api/createAccount.js diff --git a/app/mobile/api/fetchUtil.js b/app/mobile/src/api/fetchUtil.js similarity index 100% rename from app/mobile/api/fetchUtil.js rename to app/mobile/src/api/fetchUtil.js diff --git a/app/mobile/api/getAccountImageUrl.js b/app/mobile/src/api/getAccountImageUrl.js similarity index 100% rename from app/mobile/api/getAccountImageUrl.js rename to app/mobile/src/api/getAccountImageUrl.js diff --git a/app/mobile/api/getAccountStatus.js b/app/mobile/src/api/getAccountStatus.js similarity index 100% rename from app/mobile/api/getAccountStatus.js rename to app/mobile/src/api/getAccountStatus.js diff --git a/app/mobile/api/getAvailable.js b/app/mobile/src/api/getAvailable.js similarity index 100% rename from app/mobile/api/getAvailable.js rename to app/mobile/src/api/getAvailable.js diff --git a/app/mobile/api/getCardCloseMessage.js b/app/mobile/src/api/getCardCloseMessage.js similarity index 100% rename from app/mobile/api/getCardCloseMessage.js rename to app/mobile/src/api/getCardCloseMessage.js diff --git a/app/mobile/api/getCardDetail.js b/app/mobile/src/api/getCardDetail.js similarity index 100% rename from app/mobile/api/getCardDetail.js rename to app/mobile/src/api/getCardDetail.js diff --git a/app/mobile/api/getCardImageUrl.js b/app/mobile/src/api/getCardImageUrl.js similarity index 100% rename from app/mobile/api/getCardImageUrl.js rename to app/mobile/src/api/getCardImageUrl.js diff --git a/app/mobile/api/getCardOpenMessage.js b/app/mobile/src/api/getCardOpenMessage.js similarity index 100% rename from app/mobile/api/getCardOpenMessage.js rename to app/mobile/src/api/getCardOpenMessage.js diff --git a/app/mobile/api/getCardProfile.js b/app/mobile/src/api/getCardProfile.js similarity index 100% rename from app/mobile/api/getCardProfile.js rename to app/mobile/src/api/getCardProfile.js diff --git a/app/mobile/api/getCards.js b/app/mobile/src/api/getCards.js similarity index 100% rename from app/mobile/api/getCards.js rename to app/mobile/src/api/getCards.js diff --git a/app/mobile/api/getChannelDetail.js b/app/mobile/src/api/getChannelDetail.js similarity index 100% rename from app/mobile/api/getChannelDetail.js rename to app/mobile/src/api/getChannelDetail.js diff --git a/app/mobile/api/getChannelSummary.js b/app/mobile/src/api/getChannelSummary.js similarity index 100% rename from app/mobile/api/getChannelSummary.js rename to app/mobile/src/api/getChannelSummary.js diff --git a/app/mobile/api/getChannelTopic.js b/app/mobile/src/api/getChannelTopic.js similarity index 100% rename from app/mobile/api/getChannelTopic.js rename to app/mobile/src/api/getChannelTopic.js diff --git a/app/mobile/api/getChannelTopicAssetUrl.js b/app/mobile/src/api/getChannelTopicAssetUrl.js similarity index 100% rename from app/mobile/api/getChannelTopicAssetUrl.js rename to app/mobile/src/api/getChannelTopicAssetUrl.js diff --git a/app/mobile/api/getChannelTopics.js b/app/mobile/src/api/getChannelTopics.js similarity index 100% rename from app/mobile/api/getChannelTopics.js rename to app/mobile/src/api/getChannelTopics.js diff --git a/app/mobile/api/getChannels.js b/app/mobile/src/api/getChannels.js similarity index 100% rename from app/mobile/api/getChannels.js rename to app/mobile/src/api/getChannels.js diff --git a/app/mobile/api/getContactChannelDetail.js b/app/mobile/src/api/getContactChannelDetail.js similarity index 100% rename from app/mobile/api/getContactChannelDetail.js rename to app/mobile/src/api/getContactChannelDetail.js diff --git a/app/mobile/api/getContactChannelSummary.js b/app/mobile/src/api/getContactChannelSummary.js similarity index 100% rename from app/mobile/api/getContactChannelSummary.js rename to app/mobile/src/api/getContactChannelSummary.js diff --git a/app/mobile/api/getContactChannelTopic.js b/app/mobile/src/api/getContactChannelTopic.js similarity index 100% rename from app/mobile/api/getContactChannelTopic.js rename to app/mobile/src/api/getContactChannelTopic.js diff --git a/app/mobile/api/getContactChannelTopicAssetUrl.js b/app/mobile/src/api/getContactChannelTopicAssetUrl.js similarity index 100% rename from app/mobile/api/getContactChannelTopicAssetUrl.js rename to app/mobile/src/api/getContactChannelTopicAssetUrl.js diff --git a/app/mobile/api/getContactChannelTopics.js b/app/mobile/src/api/getContactChannelTopics.js similarity index 100% rename from app/mobile/api/getContactChannelTopics.js rename to app/mobile/src/api/getContactChannelTopics.js diff --git a/app/mobile/api/getContactChannels.js b/app/mobile/src/api/getContactChannels.js similarity index 100% rename from app/mobile/api/getContactChannels.js rename to app/mobile/src/api/getContactChannels.js diff --git a/app/mobile/api/getContactProfile.js b/app/mobile/src/api/getContactProfile.js similarity index 100% rename from app/mobile/api/getContactProfile.js rename to app/mobile/src/api/getContactProfile.js diff --git a/app/mobile/api/getGroups.js b/app/mobile/src/api/getGroups.js similarity index 100% rename from app/mobile/api/getGroups.js rename to app/mobile/src/api/getGroups.js diff --git a/app/mobile/api/getListing.js b/app/mobile/src/api/getListing.js similarity index 100% rename from app/mobile/api/getListing.js rename to app/mobile/src/api/getListing.js diff --git a/app/mobile/api/getListingImageUrl.js b/app/mobile/src/api/getListingImageUrl.js similarity index 100% rename from app/mobile/api/getListingImageUrl.js rename to app/mobile/src/api/getListingImageUrl.js diff --git a/app/mobile/api/getListingMessage.js b/app/mobile/src/api/getListingMessage.js similarity index 100% rename from app/mobile/api/getListingMessage.js rename to app/mobile/src/api/getListingMessage.js diff --git a/app/mobile/api/getNodeAccounts.js b/app/mobile/src/api/getNodeAccounts.js similarity index 100% rename from app/mobile/api/getNodeAccounts.js rename to app/mobile/src/api/getNodeAccounts.js diff --git a/app/mobile/api/getNodeConfig.js b/app/mobile/src/api/getNodeConfig.js similarity index 100% rename from app/mobile/api/getNodeConfig.js rename to app/mobile/src/api/getNodeConfig.js diff --git a/app/mobile/api/getNodeStatus.js b/app/mobile/src/api/getNodeStatus.js similarity index 100% rename from app/mobile/api/getNodeStatus.js rename to app/mobile/src/api/getNodeStatus.js diff --git a/app/mobile/api/getProfile.js b/app/mobile/src/api/getProfile.js similarity index 100% rename from app/mobile/api/getProfile.js rename to app/mobile/src/api/getProfile.js diff --git a/app/mobile/api/getProfileImageUrl.js b/app/mobile/src/api/getProfileImageUrl.js similarity index 100% rename from app/mobile/api/getProfileImageUrl.js rename to app/mobile/src/api/getProfileImageUrl.js diff --git a/app/mobile/api/getUsername.js b/app/mobile/src/api/getUsername.js similarity index 100% rename from app/mobile/api/getUsername.js rename to app/mobile/src/api/getUsername.js diff --git a/app/mobile/api/package.json b/app/mobile/src/api/package.json similarity index 100% rename from app/mobile/api/package.json rename to app/mobile/src/api/package.json diff --git a/app/mobile/api/removeAccount.js b/app/mobile/src/api/removeAccount.js similarity index 100% rename from app/mobile/api/removeAccount.js rename to app/mobile/src/api/removeAccount.js diff --git a/app/mobile/api/removeCard.js b/app/mobile/src/api/removeCard.js similarity index 100% rename from app/mobile/api/removeCard.js rename to app/mobile/src/api/removeCard.js diff --git a/app/mobile/api/removeChannel.js b/app/mobile/src/api/removeChannel.js similarity index 100% rename from app/mobile/api/removeChannel.js rename to app/mobile/src/api/removeChannel.js diff --git a/app/mobile/api/removeChannelTopic.js b/app/mobile/src/api/removeChannelTopic.js similarity index 100% rename from app/mobile/api/removeChannelTopic.js rename to app/mobile/src/api/removeChannelTopic.js diff --git a/app/mobile/api/removeContactChannel.js b/app/mobile/src/api/removeContactChannel.js similarity index 100% rename from app/mobile/api/removeContactChannel.js rename to app/mobile/src/api/removeContactChannel.js diff --git a/app/mobile/api/removeContactChannelTopic.js b/app/mobile/src/api/removeContactChannelTopic.js similarity index 100% rename from app/mobile/api/removeContactChannelTopic.js rename to app/mobile/src/api/removeContactChannelTopic.js diff --git a/app/mobile/api/setAccountAccess.js b/app/mobile/src/api/setAccountAccess.js similarity index 100% rename from app/mobile/api/setAccountAccess.js rename to app/mobile/src/api/setAccountAccess.js diff --git a/app/mobile/api/setAccountLogin.js b/app/mobile/src/api/setAccountLogin.js similarity index 100% rename from app/mobile/api/setAccountLogin.js rename to app/mobile/src/api/setAccountLogin.js diff --git a/app/mobile/api/setAccountSearchable.js b/app/mobile/src/api/setAccountSearchable.js similarity index 100% rename from app/mobile/api/setAccountSearchable.js rename to app/mobile/src/api/setAccountSearchable.js diff --git a/app/mobile/api/setAccountStatus.js b/app/mobile/src/api/setAccountStatus.js similarity index 100% rename from app/mobile/api/setAccountStatus.js rename to app/mobile/src/api/setAccountStatus.js diff --git a/app/mobile/api/setCardCloseMessage.js b/app/mobile/src/api/setCardCloseMessage.js similarity index 100% rename from app/mobile/api/setCardCloseMessage.js rename to app/mobile/src/api/setCardCloseMessage.js diff --git a/app/mobile/api/setCardOpenMessage.js b/app/mobile/src/api/setCardOpenMessage.js similarity index 100% rename from app/mobile/api/setCardOpenMessage.js rename to app/mobile/src/api/setCardOpenMessage.js diff --git a/app/mobile/api/setCardProfile.js b/app/mobile/src/api/setCardProfile.js similarity index 100% rename from app/mobile/api/setCardProfile.js rename to app/mobile/src/api/setCardProfile.js diff --git a/app/mobile/api/setCardStatus.js b/app/mobile/src/api/setCardStatus.js similarity index 100% rename from app/mobile/api/setCardStatus.js rename to app/mobile/src/api/setCardStatus.js diff --git a/app/mobile/api/setChannelCard.js b/app/mobile/src/api/setChannelCard.js similarity index 100% rename from app/mobile/api/setChannelCard.js rename to app/mobile/src/api/setChannelCard.js diff --git a/app/mobile/api/setChannelSubject.js b/app/mobile/src/api/setChannelSubject.js similarity index 100% rename from app/mobile/api/setChannelSubject.js rename to app/mobile/src/api/setChannelSubject.js diff --git a/app/mobile/api/setChannelTopicAsset.js b/app/mobile/src/api/setChannelTopicAsset.js similarity index 100% rename from app/mobile/api/setChannelTopicAsset.js rename to app/mobile/src/api/setChannelTopicAsset.js diff --git a/app/mobile/api/setChannelTopicSubject.js b/app/mobile/src/api/setChannelTopicSubject.js similarity index 100% rename from app/mobile/api/setChannelTopicSubject.js rename to app/mobile/src/api/setChannelTopicSubject.js diff --git a/app/mobile/api/setContactChannelTopicAsset.js b/app/mobile/src/api/setContactChannelTopicAsset.js similarity index 100% rename from app/mobile/api/setContactChannelTopicAsset.js rename to app/mobile/src/api/setContactChannelTopicAsset.js diff --git a/app/mobile/api/setContactChannelTopicSubject.js b/app/mobile/src/api/setContactChannelTopicSubject.js similarity index 100% rename from app/mobile/api/setContactChannelTopicSubject.js rename to app/mobile/src/api/setContactChannelTopicSubject.js diff --git a/app/mobile/api/setLogin.js b/app/mobile/src/api/setLogin.js similarity index 100% rename from app/mobile/api/setLogin.js rename to app/mobile/src/api/setLogin.js diff --git a/app/mobile/api/setNodeConfig.js b/app/mobile/src/api/setNodeConfig.js similarity index 100% rename from app/mobile/api/setNodeConfig.js rename to app/mobile/src/api/setNodeConfig.js diff --git a/app/mobile/api/setNodeStatus.js b/app/mobile/src/api/setNodeStatus.js similarity index 100% rename from app/mobile/api/setNodeStatus.js rename to app/mobile/src/api/setNodeStatus.js diff --git a/app/mobile/api/setProfileData.js b/app/mobile/src/api/setProfileData.js similarity index 100% rename from app/mobile/api/setProfileData.js rename to app/mobile/src/api/setProfileData.js diff --git a/app/mobile/api/setProfileImage.js b/app/mobile/src/api/setProfileImage.js similarity index 100% rename from app/mobile/api/setProfileImage.js rename to app/mobile/src/api/setProfileImage.js diff --git a/app/mobile/src/constants/Colors.js b/app/mobile/src/constants/Colors.js new file mode 100644 index 00000000..dab2017f --- /dev/null +++ b/app/mobile/src/constants/Colors.js @@ -0,0 +1,37 @@ +export const Colors = { + background: '#8fbea7', + primary: '#448866', + formBackground: '#f2f2f2', + formFocus: '#f8f8f8', + formHover: '#efefef', + grey: '#888888', + white: '#ffffff', + divider: '#dddddd', + mask: '#dddddd', + encircle: '#cccccc', + alert: '#ff8888', + enabled: '#444444', + disabled: '#aaaaaa', + text: '#444444', + link: '#0077CC', + + itemDivider: '#eeeeee', + + connected: '#44cc44', + connecting: '#dd88ff', + requested: '#4488ff', + pending: '#22aaaa', + confirmed: '#aaaaaa', + error: '#ff4444', + + profileForm: '#e8e8e8', + profileDivider: '#aaaaaa', + statsForm: '#ededed', + statsDivider: '#afafaf', + channel: '#f2f2f2', + card: '#eeeeee', + + selectHover: '#fafafa', +}; + +export default Colors; diff --git a/app/mobile/src/constants/package.json b/app/mobile/src/constants/package.json new file mode 100644 index 00000000..8744fcdc --- /dev/null +++ b/app/mobile/src/constants/package.json @@ -0,0 +1,3 @@ +{ + "name": "constants" +} diff --git a/app/mobile/context/AppContext.js b/app/mobile/src/context/AppContext.js similarity index 100% rename from app/mobile/context/AppContext.js rename to app/mobile/src/context/AppContext.js diff --git a/app/mobile/context/package.json b/app/mobile/src/context/package.json similarity index 100% rename from app/mobile/context/package.json rename to app/mobile/src/context/package.json diff --git a/app/mobile/context/useAppContext.hook.js b/app/mobile/src/context/useAppContext.hook.js similarity index 73% rename from app/mobile/context/useAppContext.hook.js rename to app/mobile/src/context/useAppContext.hook.js index 83a26c44..03deaba0 100644 --- a/app/mobile/context/useAppContext.hook.js +++ b/app/mobile/src/context/useAppContext.hook.js @@ -6,7 +6,12 @@ import { addAccount } from 'api/addAccount'; import { getUsername } from 'api/getUsername'; export function useAppContext() { - const [state, setState] = useState({}); + const [state, setState] = useState({ + session: null, + disconnected: null, + server: null, + token: null, + }); const [appRevision, setAppRevision] = useState(); const delay = useRef(2); @@ -19,7 +24,6 @@ export function useAppContext() { const resetData = () => { revision.current = null; - setState({}); } const actions = { @@ -38,33 +42,30 @@ export function useAppContext() { } const appCreate = async (username, password, token) => { - await addAccount(username, password, token); - let access = await setLogin(username, password) - setWebsocket(access.appToken) - return access.created; + const acc = username.split('@'); + await addAccount(acc[0], acc[1], password, token); + let access = await setLogin(acc[0], acc[1], password) + setWebsocket(acc[1], access.appToken) + updateState({ session: true, token: access.appToken, server: acc[1] }); + // store } const appLogin = async (username, password) => { - let access = await setLogin(username, password) - setWebsocket(access.appToken) - return access.created; + let access = await setLogin(acc[0], acc[1], password) + setWebsocket(acc[1], access.appToken) + updateState({ session: true, token: access.appToken, server: acc[1] }); + // store } const appLogout = () => { - clearWebsocket() + clearWebsocket(); + updateState({ session: false, }); + // store } - const setWebsocket = (token) => { + const setWebsocket = (server, token) => { - let protocol; - if (window.location.protocol === 'http:') { - protocol = 'ws://'; - } - else { - protocol = 'wss://'; - } - - ws.current = new WebSocket(protocol + window.location.host + "/status"); + ws.current = new WebSocket(`wss://${server}/status`); ws.current.onmessage = (ev) => { try { let rev = JSON.parse(ev.data); @@ -107,6 +108,7 @@ export function useAppContext() { } useEffect(() => { + updateState({ session: false }); // pull store set websocket }, []); diff --git a/app/mobile/src/package.json b/app/mobile/src/package.json new file mode 100644 index 00000000..0e71c241 --- /dev/null +++ b/app/mobile/src/package.json @@ -0,0 +1,3 @@ +{ + "name": "src" +} diff --git a/app/mobile/src/root/Root.jsx b/app/mobile/src/root/Root.jsx new file mode 100644 index 00000000..feb16ed2 --- /dev/null +++ b/app/mobile/src/root/Root.jsx @@ -0,0 +1,7 @@ +import { RootWrapper } from './Root.styled'; +import { useRoot } from './useRoot.hook'; + +export function Root() { + const root = useRoot(); + return +} diff --git a/app/mobile/src/root/Root.styled.js b/app/mobile/src/root/Root.styled.js new file mode 100644 index 00000000..f6661e92 --- /dev/null +++ b/app/mobile/src/root/Root.styled.js @@ -0,0 +1,8 @@ +import styled from 'styled-components/native'; +import { Colors } from 'constants/Colors'; + +export const RootWrapper = styled.View` + background-color: ${Colors.background}; + width: 100%; + height: 100%; +` diff --git a/app/mobile/src/root/useRoot.hook.js b/app/mobile/src/root/useRoot.hook.js new file mode 100644 index 00000000..7b33061a --- /dev/null +++ b/app/mobile/src/root/useRoot.hook.js @@ -0,0 +1,30 @@ +import { useContext, useState, useEffect } from 'react'; +import { AppContext } from 'context/AppContext'; +import { useNavigate } from 'react-router-dom' + +export function useRoot() { + + const [state, setState] = useState({}); + const app = useContext(AppContext); + const navigate = useNavigate(); + + const updateState = (value) => { + setState((s) => ({ ...s, ...value })); + } + + useEffect(() => { + + if (app.state.session === true) { + navigate('/session'); + } + if (app.state.session === false) { + navigate('/login'); + } + }, [app]); + + const actions = { + }; + + return { state, actions }; +} + diff --git a/app/mobile/session/Session.jsx b/app/mobile/src/session/Session.jsx similarity index 100% rename from app/mobile/session/Session.jsx rename to app/mobile/src/session/Session.jsx