diff --git a/app/mobile/ios/Databag.xcodeproj/project.pbxproj b/app/mobile/ios/Databag.xcodeproj/project.pbxproj
index 1f9cbd7f..cf6ed316 100644
--- a/app/mobile/ios/Databag.xcodeproj/project.pbxproj
+++ b/app/mobile/ios/Databag.xcodeproj/project.pbxproj
@@ -314,7 +314,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CLANG_ENABLE_MODULES = YES;
- CURRENT_PROJECT_VERSION = 27;
+ CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 3P65PQ7SUR;
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
@@ -326,7 +326,7 @@
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
- MARKETING_VERSION = 1.2;
+ MARKETING_VERSION = 1.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
@@ -352,14 +352,14 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = YES;
CLANG_ENABLE_MODULES = YES;
- CURRENT_PROJECT_VERSION = 27;
+ CURRENT_PROJECT_VERSION = 30;
DEVELOPMENT_TEAM = 3P65PQ7SUR;
INFOPLIST_FILE = Databag/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Databag;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
- MARKETING_VERSION = 1.2;
+ MARKETING_VERSION = 1.3;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
diff --git a/app/mobile/ios/Databag/Info.plist b/app/mobile/ios/Databag/Info.plist
index 518ca566..a1ba0cd4 100644
--- a/app/mobile/ios/Databag/Info.plist
+++ b/app/mobile/ios/Databag/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
$(PRODUCT_BUNDLE_PACKAGE_TYPE)
CFBundleShortVersionString
- 1.2
+ 1.3
CFBundleSignature
????
CFBundleVersion
diff --git a/app/mobile/src/session/profile/Profile.jsx b/app/mobile/src/session/profile/Profile.jsx
index f4ba88f1..7ee75efa 100644
--- a/app/mobile/src/session/profile/Profile.jsx
+++ b/app/mobile/src/session/profile/Profile.jsx
@@ -2,14 +2,11 @@ import { useEffect, useContext } from 'react';
import { KeyboardAvoidingView, Modal, Alert, TextInput, ScrollView, View, Switch, TouchableOpacity, Text } from 'react-native';
import { styles } from './Profile.styled';
import { useProfile } from './useProfile.hook';
-import { Logo } from 'utils/Logo';
import Ionicons from '@expo/vector-icons/AntDesign';
import Colors from 'constants/Colors';
import ImagePicker from 'react-native-image-crop-picker'
import { SafeAreaView } from 'react-native-safe-area-context';
-import { BlockedTopics } from './blockedTopics/BlockedTopics';
-import { BlockedContacts } from './blockedContacts/BlockedContacts';
-import { BlockedMessages } from './blockedMessages/BlockedMessages';
+import { ProfileBody } from './profileBody/ProfileBody';
export function Profile({ navigation }) {
@@ -32,47 +29,6 @@ export function Profile({ navigation }) {
}
}, [navigation, state]);
- const setVisible = async (visible) => {
- try {
- await actions.setVisible(visible);
- }
- catch (err) {
- console.log(err);
- Alert.alert(
- 'Account Update Failed',
- 'Please try again.'
- );
- }
- }
-
- const saveDetails = async () => {
- try {
- await actions.saveDetails();
- actions.hideDetailEdit();
- }
- catch (err) {
- console.log(err);
- Alert.alert(
- 'Failed to Save Details',
- 'Please try again.'
- )
- }
- }
-
- const saveLogin = async () => {
- try {
- await actions.saveLogin();
- actions.hideLoginEdit();
- }
- catch (err) {
- console.log(err);
- Alert.alert(
- 'Failed to Change Login',
- 'Please try again.'
- )
- }
- }
-
const remove = async () => {
try {
await actions.remove();
@@ -101,108 +57,15 @@ export function Profile({ navigation }) {
);
}
- const onGallery = async () => {
- try {
- const full = await ImagePicker.openPicker({ mediaType: 'photo', width: 256, height: 256 });
- const crop = await ImagePicker.openCropper({ path: full.path, width: 256, height: 256, cropperCircleOverlay: true, includeBase64: true });
- await actions.setProfileImage(crop.data);
- }
- catch (err) {
- console.log(err);
- }
- }
-
- const onCamera = async () => {
- try {
- const full = await ImagePicker.openCamera({ mediaType: 'photo', width: 256, height: 256 });
- const crop = await ImagePicker.openCropper({ path: full.path, width: 256, height: 256, cropperCircleOverlay: true, includeBase64: true });
- await actions.setProfileImage(crop.data);
- }
- catch (err) {
- console.log(err);
- }
- }
-
- const enabled = (state.checked && state.available && state.editConfirm === state.editPassword && state.editPassword);
-
- const Body = () => {
- return (
-
-
-
-
-
-
-
- { state.disconnected > 3 && (
-
- Disconnected
-
- )}
- { !state.disconnected && (
-
- )}
-
-
- { state.name && (
- { state.name }
- )}
- { !state.name && (
- Name
- )}
-
-
-
-
-
-
- { state.location && (
- { state.location }
- )}
- { !state.location && (
- Location
- )}
-
-
-
-
-
- { state.description && (
- { state.description }
- )}
- { !state.description && (
- Description
- )}
-
-
-
- setVisible(!state.searchable)} activeOpacity={1}>
- Visible in Registry
-
-
-
-
- Change Login
-
-
- Manage Blocked Contacts
-
-
- Manage Blocked Topics
-
-
- Manage Blocked Messages
-
-
- );
- };
-
return (
-
+
{ state.tabbed && (
-
-
-
+ <>
+
+
+ Delete Your Account
+
+ >
)}
{ !state.tabbed && (
@@ -212,184 +75,12 @@ export function Profile({ navigation }) {
-
+
+
+ Delete Your Account
+
)}
-
-
-
- Blocked Contacts:
-
-
-
-
-
- Close
-
-
-
-
-
-
-
-
- Blocked Topics:
-
-
-
-
-
- Close
-
-
-
-
-
-
-
-
- Blocked Messages:
-
-
-
-
-
- Close
-
-
-
-
-
-
-
-
- Edit Details:
-
-
-
-
-
-
-
-
-
-
-
- Cancel
-
-
- Save
-
-
-
-
-
-
-
-
- Change Login:
-
-
- { state.checked && state.available && (
-
- )}
- { state.checked && !state.available && (
-
- )}
-
- { !state.showPassword && (
-
-
-
-
-
-
- )}
- { state.showPassword && (
-
-
-
-
-
-
- )}
- { !state.showConfirm && (
-
-
-
-
-
-
- )}
- { state.showConfirm && (
-
-
-
-
-
-
- )}
-
-
- Cancel
-
- { enabled && (
-
- Save
-
- )}
- { !enabled && (
-
- Save
-
- )}
-
-
-
-
-
)
}
diff --git a/app/mobile/src/session/profile/Profile.styled.js b/app/mobile/src/session/profile/Profile.styled.js
index 01b572dd..f08b2d2a 100644
--- a/app/mobile/src/session/profile/Profile.styled.js
+++ b/app/mobile/src/session/profile/Profile.styled.js
@@ -17,9 +17,6 @@ export const styles = StyleSheet.create({
wrapper: {
backgroundColor: Colors.formBackground,
},
- drawer: {
- paddingTop: 16,
- },
action: {
width: 64,
display: 'flex',
@@ -42,9 +39,6 @@ export const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
- body: {
- paddingTop: 16,
- },
header: {
display: 'flex',
flexDirection: 'row',
@@ -166,13 +160,19 @@ export const styles = StyleSheet.create({
borderRadius: 4,
padding: 8,
width: 72,
- display: 'flex',
- alignItems: 'center',
- justifyContent: 'center',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
},
removeText: {
color: Colors.white,
},
+ erase: {
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: '100%',
+ },
switch: {
false: Colors.grey,
true: Colors.background,
@@ -291,6 +291,9 @@ export const styles = StyleSheet.create({
paddingLeft: 8,
color: Colors.white,
},
+ eraseText: {
+ color: Colors.alert,
+ },
saveText: {
color: Colors.white,
},
diff --git a/app/mobile/src/session/profile/profileBody/ProfileBody.jsx b/app/mobile/src/session/profile/profileBody/ProfileBody.jsx
new file mode 100644
index 00000000..48739403
--- /dev/null
+++ b/app/mobile/src/session/profile/profileBody/ProfileBody.jsx
@@ -0,0 +1,319 @@
+import { useEffect, useContext } from 'react';
+import { KeyboardAvoidingView, Modal, Alert, TextInput, ScrollView, View, Switch, TouchableOpacity, Text } from 'react-native';
+import { styles } from './ProfileBody.styled';
+import { useProfileBody } from './useProfileBody.hook';
+import { Logo } from 'utils/Logo';
+import Ionicons from '@expo/vector-icons/AntDesign';
+import Colors from 'constants/Colors';
+import ImagePicker from 'react-native-image-crop-picker'
+import { SafeAreaView } from 'react-native-safe-area-context';
+import { BlockedTopics } from './blockedTopics/BlockedTopics';
+import { BlockedContacts } from './blockedContacts/BlockedContacts';
+import { BlockedMessages } from './blockedMessages/BlockedMessages';
+
+export function ProfileBody({ navigation }) {
+
+ const { state, actions } = useProfileBody();
+
+ const setVisible = async (visible) => {
+ try {
+ await actions.setVisible(visible);
+ }
+ catch (err) {
+ console.log(err);
+ Alert.alert(
+ 'Account Update Failed',
+ 'Please try again.'
+ );
+ }
+ }
+
+ const saveDetails = async () => {
+ try {
+ await actions.saveDetails();
+ actions.hideDetailEdit();
+ }
+ catch (err) {
+ console.log(err);
+ Alert.alert(
+ 'Failed to Save Details',
+ 'Please try again.'
+ )
+ }
+ }
+
+ const saveLogin = async () => {
+ try {
+ await actions.saveLogin();
+ actions.hideLoginEdit();
+ }
+ catch (err) {
+ console.log(err);
+ Alert.alert(
+ 'Failed to Change Login',
+ 'Please try again.'
+ )
+ }
+ }
+
+ const onGallery = async () => {
+ try {
+ const full = await ImagePicker.openPicker({ mediaType: 'photo', width: 256, height: 256 });
+ const crop = await ImagePicker.openCropper({ path: full.path, width: 256, height: 256, cropperCircleOverlay: true, includeBase64: true });
+ await actions.setProfileImage(crop.data);
+ }
+ catch (err) {
+ console.log(err);
+ }
+ }
+
+ const enabled = (state.checked && state.available && state.editConfirm === state.editPassword && state.editPassword);
+
+ return (
+
+
+
+
+
+
+
+ { state.disconnected > 3 && (
+
+ Disconnected
+
+ )}
+ { !state.disconnected && (
+
+ )}
+
+
+ { state.name && (
+ { state.name }
+ )}
+ { !state.name && (
+ Name
+ )}
+
+
+
+
+
+
+ { state.location && (
+ { state.location }
+ )}
+ { !state.location && (
+ Location
+ )}
+
+
+
+
+
+ { state.description && (
+ { state.description }
+ )}
+ { !state.description && (
+ Description
+ )}
+
+
+
+ setVisible(!state.searchable)} activeOpacity={1}>
+ Visible in Registry
+
+
+
+
+ Change Login
+
+
+ Manage Blocked Contacts
+
+
+ Manage Blocked Topics
+
+
+ Manage Blocked Messages
+
+
+
+
+
+ Blocked Contacts:
+
+
+
+
+
+ Close
+
+
+
+
+
+
+
+
+ Blocked Topics:
+
+
+
+
+
+ Close
+
+
+
+
+
+
+
+
+ Blocked Messages:
+
+
+
+
+
+ Close
+
+
+
+
+
+
+
+
+ Edit Details:
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+ Save
+
+
+
+
+
+
+
+
+ Change Login:
+
+
+ { state.checked && state.available && (
+
+ )}
+ { state.checked && !state.available && (
+
+ )}
+
+ { !state.showPassword && (
+
+
+
+
+
+
+ )}
+ { state.showPassword && (
+
+
+
+
+
+
+ )}
+ { !state.showConfirm && (
+
+
+
+
+
+
+ )}
+ { state.showConfirm && (
+
+
+
+
+
+
+ )}
+
+
+ Cancel
+
+ { enabled && (
+
+ Save
+
+ )}
+ { !enabled && (
+
+ Save
+
+ )}
+
+
+
+
+
+
+ );
+};
+
diff --git a/app/mobile/src/session/profile/profileBody/ProfileBody.styled.js b/app/mobile/src/session/profile/profileBody/ProfileBody.styled.js
new file mode 100644
index 00000000..2acb2478
--- /dev/null
+++ b/app/mobile/src/session/profile/profileBody/ProfileBody.styled.js
@@ -0,0 +1,301 @@
+import { StyleSheet } from 'react-native';
+import { Colors } from 'constants/Colors';
+
+export const styles = StyleSheet.create({
+ container: {
+ width: '100%',
+ display: 'flex',
+ flexDirection: 'column',
+ paddingBottom: 32,
+ alignItems: 'center',
+ justifyContent: 'center',
+ paddingTop: 32,
+ },
+ icon: {
+ paddingTop: 2,
+ },
+ wrapper: {
+ backgroundColor: Colors.formBackground,
+ },
+ drawer: {
+ paddingTop: 16,
+ },
+ action: {
+ width: 64,
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+ titleText: {
+ fontSize: 18,
+ overflow: 'hidden',
+ flexGrow: 1,
+ textAlign: 'center',
+ },
+ title: {
+ display: 'flex',
+ flexDirection: 'row',
+ flexGrow: 1,
+ flex: 1,
+ width: '100%',
+ textAlign: 'start',
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+ body: {
+ paddingTop: 16,
+ },
+ header: {
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'flex-end',
+ justifyContent: 'center',
+ },
+ headerText: {
+ paddingLeft: 16,
+ fontSize: 14,
+ paddingRight: 8,
+ color: Colors.text,
+ },
+ camera: {
+ position: 'absolute',
+ bottom: 0,
+ left: 0,
+ padding: 8,
+ backgroundColor: Colors.lightgrey,
+ borderBottomLeftRadius: 8,
+ borderTopRightRadius: 8,
+ },
+ gallery: {
+ position: 'absolute',
+ bottom: 0,
+ right: 0,
+ padding: 8,
+ backgroundColor: Colors.lightgrey,
+ borderBottomRightRadius: 8,
+ borderTopLeftRadius: 8,
+ },
+ alert: {
+ height: 32,
+ },
+ detail: {
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'center',
+ color: Colors.text,
+ paddingLeft: 32,
+ paddingRight: 32,
+ },
+ attribute: {
+ display: 'flex',
+ flexDirection: 'row',
+ paddingBottom: 8,
+ },
+ nonametext: {
+ fontSize: 18,
+ paddingRight: 8,
+ fontWeight: 'bold',
+ color: Colors.grey,
+ },
+ nametext: {
+ fontSize: 18,
+ paddingRight: 8,
+ fontWeight: 'bold',
+ },
+ locationtext: {
+ fontSize: 16,
+ paddingLeft: 8,
+ color: Colors.text,
+ },
+ nolocationtext: {
+ fontSize: 16,
+ paddingLeft: 8,
+ color: Colors.grey,
+ },
+ descriptiontext: {
+ fontSize: 16,
+ paddingLeft: 8,
+ color: Colors.text,
+ },
+ nodescriptiontext: {
+ fontSize: 16,
+ paddingLeft: 8,
+ color: Colors.grey,
+ },
+ visible: {
+ display: 'flex',
+ flexDirection: 'row',
+ justifyContent: 'center',
+ alignItems: 'center',
+ paddingTop: 16,
+ },
+ visibleText: {
+ fontSize: 16,
+ color: Colors.text,
+ },
+ visibleSwitch: {
+ transform: [{ scaleX: .7 }, { scaleY: .7 }],
+ },
+ logout: {
+ marginTop: 32,
+ borderRadius: 4,
+ backgroundColor: Colors.primary,
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
+ paddingLeft: 8,
+ paddingRight: 8,
+ paddingTop: 8,
+ paddingBottom: 8,
+ },
+ logoutText: {
+ color: Colors.white,
+ paddingLeft: 8,
+ },
+ unconfirmed: {
+ backgroundColor: Colors.lightgrey,
+ borderRadius: 4,
+ padding: 8,
+ width: 72,
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+ remove: {
+ backgroundColor: Colors.error,
+ borderRadius: 4,
+ padding: 8,
+ width: 72,
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ },
+ removeText: {
+ color: Colors.white,
+ },
+ switch: {
+ false: Colors.grey,
+ true: Colors.background,
+ },
+ editWrapper: {
+ display: 'flex',
+ width: '100%',
+ height: '100%',
+ alignItems: 'center',
+ justifyContent: 'center',
+ backgroundColor: 'rgba(52, 52, 52, 0.8)'
+ },
+ editContainer: {
+ backgroundColor: Colors.formBackground,
+ padding: 16,
+ width: '80%',
+ maxWidth: 400,
+ },
+ editHeader: {
+ fontSize: 18,
+ paddingBottom: 16,
+ },
+ editList: {
+ width: '100%',
+ borderWidth: 1,
+ borderColor: Colors.lightgrey,
+ borderRadius: 2,
+ },
+ inputField: {
+ width: '100%',
+ borderWidth: 1,
+ borderColor: Colors.lightgrey,
+ borderRadius: 4,
+ padding: 8,
+ marginBottom: 8,
+ maxHeight: 92,
+ display: 'flex',
+ flexDirection: 'row',
+ },
+ input: {
+ fontSize: 14,
+ flexGrow: 1,
+ },
+ editControls: {
+ display: 'flex',
+ flexDirection: 'row',
+ justifyContent: 'flex-end',
+ },
+ close: {
+ borderWidth: 1,
+ borderColor: Colors.lightgrey,
+ borderRadius: 4,
+ padding: 8,
+ marginTop: 8,
+ width: 72,
+ display: 'flex',
+ alignItems: 'center',
+ },
+ cancel: {
+ borderWidth: 1,
+ borderColor: Colors.lightgrey,
+ borderRadius: 4,
+ padding: 8,
+ marginRight: 8,
+ width: 72,
+ display: 'flex',
+ alignItems: 'center',
+ },
+ disabled: {
+ borderWidth: 1,
+ borderColor: Colors.lightgrey,
+ padding: 8,
+ borderRadius: 4,
+ width: 72,
+ display: 'flex',
+ alignItems: 'center',
+ },
+ disabledText: {
+ color: Colors.disabled,
+ },
+ save: {
+ padding: 8,
+ borderRadius: 4,
+ backgroundColor: Colors.primary,
+ width: 72,
+ display: 'flex',
+ alignItems: 'center',
+ },
+ save: {
+ padding: 8,
+ borderRadius: 4,
+ backgroundColor: Colors.primary,
+ width: 72,
+ display: 'flex',
+ alignItems: 'center',
+ },
+ link: {
+ marginTop: 16,
+ },
+ linkText: {
+ color: Colors.primary,
+ },
+ delete: {
+ backgroundColor: Colors.error,
+ marginTop: 16,
+ display: 'flex',
+ flexDirection: 'row',
+ alignItems: 'center',
+ paddingLeft: 8,
+ paddingRight: 8,
+ paddingTop: 8,
+ paddingBottom: 8,
+ borderRadius: 4,
+ },
+ deleteText: {
+ paddingLeft: 8,
+ color: Colors.white,
+ },
+ saveText: {
+ color: Colors.white,
+ },
+ disconnected: {
+ color: Colors.alert,
+ },
+})
+
diff --git a/app/mobile/src/session/profile/blockedContacts/BlockedContacts.jsx b/app/mobile/src/session/profile/profileBody/blockedContacts/BlockedContacts.jsx
similarity index 100%
rename from app/mobile/src/session/profile/blockedContacts/BlockedContacts.jsx
rename to app/mobile/src/session/profile/profileBody/blockedContacts/BlockedContacts.jsx
diff --git a/app/mobile/src/session/profile/blockedContacts/BlockedContacts.styled.js b/app/mobile/src/session/profile/profileBody/blockedContacts/BlockedContacts.styled.js
similarity index 100%
rename from app/mobile/src/session/profile/blockedContacts/BlockedContacts.styled.js
rename to app/mobile/src/session/profile/profileBody/blockedContacts/BlockedContacts.styled.js
diff --git a/app/mobile/src/session/profile/blockedContacts/useBlockedContacts.hook.js b/app/mobile/src/session/profile/profileBody/blockedContacts/useBlockedContacts.hook.js
similarity index 100%
rename from app/mobile/src/session/profile/blockedContacts/useBlockedContacts.hook.js
rename to app/mobile/src/session/profile/profileBody/blockedContacts/useBlockedContacts.hook.js
diff --git a/app/mobile/src/session/profile/blockedMessages/BlockedMessages.jsx b/app/mobile/src/session/profile/profileBody/blockedMessages/BlockedMessages.jsx
similarity index 100%
rename from app/mobile/src/session/profile/blockedMessages/BlockedMessages.jsx
rename to app/mobile/src/session/profile/profileBody/blockedMessages/BlockedMessages.jsx
diff --git a/app/mobile/src/session/profile/blockedMessages/BlockedMessages.styled.js b/app/mobile/src/session/profile/profileBody/blockedMessages/BlockedMessages.styled.js
similarity index 100%
rename from app/mobile/src/session/profile/blockedMessages/BlockedMessages.styled.js
rename to app/mobile/src/session/profile/profileBody/blockedMessages/BlockedMessages.styled.js
diff --git a/app/mobile/src/session/profile/blockedMessages/useBlockedMessages.hook.js b/app/mobile/src/session/profile/profileBody/blockedMessages/useBlockedMessages.hook.js
similarity index 100%
rename from app/mobile/src/session/profile/blockedMessages/useBlockedMessages.hook.js
rename to app/mobile/src/session/profile/profileBody/blockedMessages/useBlockedMessages.hook.js
diff --git a/app/mobile/src/session/profile/blockedTopics/BlockedTopics.jsx b/app/mobile/src/session/profile/profileBody/blockedTopics/BlockedTopics.jsx
similarity index 100%
rename from app/mobile/src/session/profile/blockedTopics/BlockedTopics.jsx
rename to app/mobile/src/session/profile/profileBody/blockedTopics/BlockedTopics.jsx
diff --git a/app/mobile/src/session/profile/blockedTopics/BlockedTopics.styled.js b/app/mobile/src/session/profile/profileBody/blockedTopics/BlockedTopics.styled.js
similarity index 100%
rename from app/mobile/src/session/profile/blockedTopics/BlockedTopics.styled.js
rename to app/mobile/src/session/profile/profileBody/blockedTopics/BlockedTopics.styled.js
diff --git a/app/mobile/src/session/profile/blockedTopics/useBlockedTopics.hook.js b/app/mobile/src/session/profile/profileBody/blockedTopics/useBlockedTopics.hook.js
similarity index 100%
rename from app/mobile/src/session/profile/blockedTopics/useBlockedTopics.hook.js
rename to app/mobile/src/session/profile/profileBody/blockedTopics/useBlockedTopics.hook.js
diff --git a/app/mobile/src/session/profile/profileBody/useProfileBody.hook.js b/app/mobile/src/session/profile/profileBody/useProfileBody.hook.js
new file mode 100644
index 00000000..148c1c7c
--- /dev/null
+++ b/app/mobile/src/session/profile/profileBody/useProfileBody.hook.js
@@ -0,0 +1,179 @@
+import { useState, useEffect, useRef, useContext } from 'react';
+import { useNavigate } from 'react-router-dom';
+import { useWindowDimensions } from 'react-native';
+import { ProfileContext } from 'context/ProfileContext';
+import { AccountContext } from 'context/AccountContext';
+import { AppContext } from 'context/AppContext';
+import config from 'constants/Config';
+
+export function useProfileBody() {
+
+ const [state, setState] = useState({
+ name: null,
+ handle: null,
+ location: null,
+ description: null,
+ node: null,
+ imageSource: null,
+ searchable: null,
+ showDetailEdit: false,
+ showLoginEdit: false,
+ editName: null,
+ editLocation: null,
+ editDescription: null,
+ editHandle: null,
+ editPassword: null,
+ editConfirm: null,
+ checked: true,
+ available: true,
+ showPassword: false,
+ showConfirm: false,
+ blockedChannels: false,
+ blockedCards: false,
+ blockedMessages: false,
+ tabbed: null,
+ disconnected: false,
+ });
+
+ const app = useContext(AppContext);
+ const dimensions = useWindowDimensions();
+ const account = useContext(AccountContext);
+ const profile = useContext(ProfileContext);
+ const navigate = useNavigate();
+ const debounce = useRef(null);
+
+ const updateState = (value) => {
+ setState((s) => ({ ...s, ...value }));
+ }
+
+ useEffect(() => {
+ if (dimensions.width > config.tabbedWidth) {
+ updateState({ tabbed: false });
+ }
+ else {
+ updateState({ tabbed: true });
+ }
+ }, [dimensions]);
+
+ useEffect(() => {
+ const { name, handle, node, location, description, image } = profile.state.profile;
+ const imageSource = image ? profile.state.imageUrl : 'avatar';
+ updateState({ name, handle, node, location, description, imageSource, editHandle: handle,
+ editName: name, editLocation: location, editDescription: description });
+ }, [profile]);
+
+ useEffect(() => {
+ updateState({ searchable: account.state.status.searchable });
+ }, [account]);
+
+ useEffect(() => {
+ const { disconnected } = app.state;
+ updateState({ disconnected });
+ }, [app]);
+
+ const actions = {
+ logout: () => {
+ app.actions.logout();
+ navigate('/');
+ },
+ remove: async () => {
+ await app.actions.remove();
+ updateState({ showDelete: false });
+ navigate('/');
+ },
+ setVisible: async (searchable) => {
+ updateState({ searchable });
+ await account.actions.setSearchable(searchable);
+ },
+ setProfileImage: async (data) => {
+ await profile.actions.setProfileImage(data);
+ },
+ showBlockedChannels: () => {
+ updateState({ blockedChannels: true });
+ },
+ hideBlockedChannels: () => {
+ updateState({ blockedChannels: false });
+ },
+ showBlockedCards: () => {
+ updateState({ blockedCards: true });
+ },
+ hideBlockedCards: () => {
+ updateState({ blockedCards: false });
+ },
+ showBlockedMessages: () => {
+ updateState({ blockedMessages: true });
+ },
+ hideBlockedMessages: () => {
+ updateState({ blockedMessages: false });
+ },
+ showLoginEdit: () => {
+ updateState({ showLoginEdit: true });
+ },
+ hideLoginEdit: () => {
+ updateState({ showLoginEdit: false });
+ },
+ showDetailEdit: () => {
+ updateState({ showDetailEdit: true });
+ },
+ hideDetailEdit: () => {
+ updateState({ showDetailEdit: false });
+ },
+ setEditName: (editName) => {
+ updateState({ editName });
+ },
+ setEditLocation: (editLocation) => {
+ updateState({ editLocation });
+ },
+ setEditDescription: (editDescription) => {
+ updateState({ editDescription });
+ },
+ showPassword: () => {
+ updateState({ showPassword: true });
+ },
+ hidePassword: () => {
+ updateState({ showPassword: false });
+ },
+ showConfirm: () => {
+ updateState({ showConfirm: true });
+ },
+ hideConfirm: () => {
+ updateState({ showConfirm: false });
+ },
+ setEditHandle: (editHandle) => {
+ updateState({ editHandle, checked: false });
+
+ if (debounce.current != null) {
+ clearTimeout(debounce.current);
+ }
+ debounce.current = setTimeout(async () => {
+ try {
+ if (editHandle === state.handle) {
+ updateState({ available: true, checked: true });
+ }
+ else {
+ const available = await profile.actions.getHandle(editHandle);
+ updateState({ available, checked: true });
+ }
+ }
+ catch (err) {
+ console.log(err);
+ }
+ }, 1000);
+ },
+ setEditPassword: (editPassword) => {
+ updateState({ editPassword });
+ },
+ setEditConfirm: (editConfirm) => {
+ updateState({ editConfirm });
+ },
+ saveDetails: async () => {
+ await profile.actions.setProfileData(state.editName, state.editLocation, state.editDescription);
+ },
+ saveLogin: async () => {
+ await account.actions.setLogin(state.editHandle, state.editPassword);
+ },
+ };
+
+ return { state, actions };
+}
+
diff --git a/app/mobile/src/session/profile/useProfile.hook.js b/app/mobile/src/session/profile/useProfile.hook.js
index 82aeb9be..5ebe17b9 100644
--- a/app/mobile/src/session/profile/useProfile.hook.js
+++ b/app/mobile/src/session/profile/useProfile.hook.js
@@ -2,7 +2,6 @@ import { useState, useEffect, useRef, useContext } from 'react';
import { useNavigate } from 'react-router-dom';
import { useWindowDimensions } from 'react-native';
import { ProfileContext } from 'context/ProfileContext';
-import { AccountContext } from 'context/AccountContext';
import { AppContext } from 'context/AppContext';
import config from 'constants/Config';
@@ -11,38 +10,16 @@ export function useProfile() {
const [state, setState] = useState({
name: null,
handle: null,
- location: null,
- description: null,
node: null,
- imageSource: null,
- searchable: null,
- showDetailEdit: false,
- showLoginEdit: false,
- editName: null,
- editLocation: null,
- editDescription: null,
- editHandle: null,
- editPassword: null,
- editConfirm: null,
- checked: true,
- available: true,
- showPassword: false,
- showConfirm: false,
showDelete: false,
- blockedChannels: false,
- blockedCards: false,
- blockedMessages: false,
tabbed: null,
- disconnected: false,
confirmDelete: null,
});
const app = useContext(AppContext);
const dimensions = useWindowDimensions();
- const account = useContext(AccountContext);
const profile = useContext(ProfileContext);
const navigate = useNavigate();
- const debounce = useRef(null);
const updateState = (value) => {
setState((s) => ({ ...s, ...value }));
@@ -64,10 +41,6 @@ export function useProfile() {
editName: name, editLocation: location, editDescription: description });
}, [profile]);
- useEffect(() => {
- updateState({ searchable: account.state.status.searchable });
- }, [account]);
-
useEffect(() => {
const { disconnected } = app.state;
updateState({ disconnected });
@@ -83,105 +56,14 @@ export function useProfile() {
updateState({ showDelete: false });
navigate('/');
},
- setVisible: async (searchable) => {
- updateState({ searchable });
- await account.actions.setSearchable(searchable);
- },
- setProfileImage: async (data) => {
- await profile.actions.setProfileImage(data);
- },
- showBlockedChannels: () => {
- updateState({ blockedChannels: true });
- },
- hideBlockedChannels: () => {
- updateState({ blockedChannels: false });
- },
- showBlockedCards: () => {
- updateState({ blockedCards: true });
- },
- hideBlockedCards: () => {
- updateState({ blockedCards: false });
- },
- showBlockedMessages: () => {
- updateState({ blockedMessages: true });
- },
- hideBlockedMessages: () => {
- updateState({ blockedMessages: false });
- },
- showLoginEdit: () => {
- updateState({ showLoginEdit: true });
- },
- hideLoginEdit: () => {
- updateState({ showLoginEdit: false });
- },
- showDetailEdit: () => {
- updateState({ showDetailEdit: true });
- },
- hideDetailEdit: () => {
- updateState({ showDetailEdit: false });
- },
- setEditName: (editName) => {
- updateState({ editName });
- },
- setEditLocation: (editLocation) => {
- updateState({ editLocation });
- },
- setEditDescription: (editDescription) => {
- updateState({ editDescription });
- },
- setConfirmDelete: (confirmDelete) => {
- updateState({ confirmDelete });
- },
- showPassword: () => {
- updateState({ showPassword: true });
- },
- hidePassword: () => {
- updateState({ showPassword: false });
- },
- showConfirm: () => {
- updateState({ showConfirm: true });
- },
- hideConfirm: () => {
- updateState({ showConfirm: false });
- },
showDelete: () => {
updateState({ showDelete: true });
},
hideDelete: () => {
updateState({ showDelete: false });
},
- setEditHandle: (editHandle) => {
- updateState({ editHandle, checked: false });
-
- if (debounce.current != null) {
- clearTimeout(debounce.current);
- }
- debounce.current = setTimeout(async () => {
- try {
- if (editHandle === state.handle) {
- updateState({ available: true, checked: true });
- }
- else {
- const available = await profile.actions.getHandle(editHandle);
- updateState({ available, checked: true });
- }
- }
- catch (err) {
- console.log(err);
- }
- }, 1000);
- },
- setEditPassword: (editPassword) => {
- updateState({ editPassword });
- },
- setEditConfirm: (editConfirm) => {
- updateState({ editConfirm });
- },
- saveDetails: async () => {
- await profile.actions.setProfileData(state.editName, state.editLocation, state.editDescription);
- },
- saveLogin: async () => {
- await account.actions.setLogin(state.editHandle, state.editPassword);
+ setConfirmDelete: (confirmDelete) => {
+ updateState({ confirmDelete });
},
};