diff --git a/native/chat/settings/thread-settings-avatar.react.js b/native/chat/settings/thread-settings-avatar.react.js
--- a/native/chat/settings/thread-settings-avatar.react.js
+++ b/native/chat/settings/thread-settings-avatar.react.js
@@ -1,13 +1,15 @@
// @flow
+import { useNavigation } from '@react-navigation/native';
import * as React from 'react';
-import { View, TouchableWithoutFeedback } from 'react-native';
+import { View } from 'react-native';
import { type ResolvedThreadInfo } from 'lib/types/thread-types.js';
-import SWMansionIcon from '../../components/swmansion-icon.react.js';
+import EditAvatar from '../../components/edit-avatar.react.js';
import ThreadAvatar from '../../components/thread-avatar.react.js';
-import { useColors, useStyles } from '../../themes/colors.js';
+import { EmojiAvatarCreationRouteName } from '../../navigation/route-names.js';
+import { useStyles } from '../../themes/colors.js';
type Props = {
+threadInfo: ResolvedThreadInfo,
@@ -16,47 +18,28 @@
function ThreadSettingsAvatar(props: Props): React.Node {
const { threadInfo, canChangeSettings } = props;
- const colors = useColors();
- const styles = useStyles(unboundStyles);
-
- const onPressEditAvatar = React.useCallback(() => {
- // TODO:
- // Display action sheet with all the different avatar creation options
- }, []);
+ const { navigate } = useNavigation();
- const editBadge = React.useMemo(() => {
- if (!canChangeSettings) {
- return null;
- }
+ const styles = useStyles(unboundStyles);
- return (
-
-
-
- );
- }, [
- canChangeSettings,
- colors.floatingButtonLabel,
- styles.editAvatarIcon,
- styles.editAvatarIconContainer,
- ]);
+ const onPressEmojiAvatarFlow = React.useCallback(() => {
+ navigate<'EmojiAvatarCreation'>({
+ name: EmojiAvatarCreationRouteName,
+ params: {
+ threadID: threadInfo.id,
+ containingThreadID: threadInfo.containingThreadID,
+ },
+ });
+ }, [navigate, threadInfo.containingThreadID, threadInfo.id]);
return (
-
-
-
- {editBadge}
-
-
+
+
);
}
@@ -68,21 +51,6 @@
flex: 1,
paddingVertical: 16,
},
- editAvatarIconContainer: {
- position: 'absolute',
- bottom: 0,
- right: 0,
- borderWidth: 2,
- borderColor: 'panelForeground',
- borderRadius: 18,
- width: 36,
- height: 36,
- backgroundColor: 'purpleButton',
- justifyContent: 'center',
- },
- editAvatarIcon: {
- textAlign: 'center',
- },
};
const MemoizedThreadSettingsAvatar: React.ComponentType =
diff --git a/native/components/edit-avatar.react.js b/native/components/edit-avatar.react.js
new file mode 100644
--- /dev/null
+++ b/native/components/edit-avatar.react.js
@@ -0,0 +1,73 @@
+// @flow
+
+import * as React from 'react';
+import { View, TouchableWithoutFeedback } from 'react-native';
+
+import SWMansionIcon from '../components/swmansion-icon.react.js';
+import { useColors, useStyles } from '../themes/colors.js';
+
+type Props = {
+ +children: React.Node, // also could maybe make this children?
+ +onPressEmojiAvatarFlow: () => mixed,
+ +disabled?: boolean,
+};
+function EditAvatar(props: Props): React.Node {
+ const { onPressEmojiAvatarFlow, children, disabled } = props;
+
+ const colors = useColors();
+ const styles = useStyles(unboundStyles);
+
+ const editBadge = React.useMemo(() => {
+ if (disabled) {
+ return null;
+ }
+
+ return (
+
+
+
+ );
+ }, [
+ colors.floatingButtonLabel,
+ disabled,
+ styles.editAvatarIcon,
+ styles.editAvatarIconContainer,
+ ]);
+
+ return (
+
+
+ {children}
+ {editBadge}
+
+
+ );
+}
+
+const unboundStyles = {
+ editAvatarIconContainer: {
+ position: 'absolute',
+ bottom: 0,
+ right: 0,
+ borderWidth: 2,
+ borderColor: 'panelForeground',
+ borderRadius: 18,
+ width: 36,
+ height: 36,
+ backgroundColor: 'purpleButton',
+ justifyContent: 'center',
+ },
+ editAvatarIcon: {
+ textAlign: 'center',
+ },
+};
+
+export default EditAvatar;
diff --git a/native/profile/profile-screen.react.js b/native/profile/profile-screen.react.js
--- a/native/profile/profile-screen.react.js
+++ b/native/profile/profile-screen.react.js
@@ -1,14 +1,7 @@
// @flow
import * as React from 'react';
-import {
- View,
- Text,
- Alert,
- Platform,
- ScrollView,
- TouchableWithoutFeedback,
-} from 'react-native';
+import { View, Text, Alert, Platform, ScrollView } from 'react-native';
import { logOutActionTypes, logOut } from 'lib/actions/user-actions.js';
import { useStringForUser } from 'lib/hooks/ens-cache.js';
@@ -28,13 +21,14 @@
import { deleteNativeCredentialsFor } from '../account/native-credentials.js';
import Action from '../components/action-row.react.js';
import Button from '../components/button.react.js';
+import EditAvatar from '../components/edit-avatar.react.js';
import EditSettingButton from '../components/edit-setting-button.react.js';
import { SingleLine } from '../components/single-line.react.js';
-import SWMansionIcon from '../components/swmansion-icon.react.js';
import UserAvatar from '../components/user-avatar.react.js';
import type { NavigationRoute } from '../navigation/route-names.js';
import {
EditPasswordRouteName,
+ EmojiAvatarCreationRouteName,
DeleteAccountRouteName,
BuildInfoRouteName,
DevToolsRouteName,
@@ -137,22 +131,12 @@
-
-
-
-
-
-
-
-
+
+
+
>
);
@@ -212,9 +196,11 @@
);
}
- onPressEditAvatar = () => {
- // TODO:
- // Display action sheet with all the different avatar creation options
+ onPressEmojiAvatarFlow = () => {
+ this.props.navigation.navigate<'EmojiAvatarCreation'>({
+ name: EmojiAvatarCreationRouteName,
+ params: {},
+ });
};
onPressLogOut = () => {
@@ -333,21 +319,6 @@
alignItems: 'center',
paddingVertical: 16,
},
- editAvatarIconContainer: {
- position: 'absolute',
- bottom: 0,
- right: 0,
- borderWidth: 2,
- borderColor: 'panelForeground',
- borderRadius: 18,
- width: 36,
- height: 36,
- backgroundColor: '#6D49AB',
- justifyContent: 'center',
- },
- editAvatarIcon: {
- textAlign: 'center',
- },
container: {
flex: 1,
},