fixed the layout
This commit is contained in:
parent
dfcea278de
commit
ed92eb80f3
|
@ -7,6 +7,8 @@ import { IAvatar } from './interfaces';
|
||||||
import I18n from '../../i18n';
|
import I18n from '../../i18n';
|
||||||
import { useTheme } from '../../theme';
|
import { useTheme } from '../../theme';
|
||||||
import { BUTTON_HIT_SLOP } from '../message/utils';
|
import { BUTTON_HIT_SLOP } from '../message/utils';
|
||||||
|
import { useAppSelector } from '../../lib/hooks';
|
||||||
|
import { compareServerVersion } from '../../lib/methods/helpers';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
editAvatarButton: {
|
editAvatarButton: {
|
||||||
|
@ -42,6 +44,10 @@ const AvatarWithEdit = ({
|
||||||
}: IAvatarContainer): React.ReactElement => {
|
}: IAvatarContainer): React.ReactElement => {
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
|
|
||||||
|
const { serverVersion } = useAppSelector(state => ({
|
||||||
|
serverVersion: state.server.version
|
||||||
|
}));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AvatarContainer
|
<AvatarContainer
|
||||||
|
@ -58,7 +64,7 @@ const AvatarWithEdit = ({
|
||||||
isStatic={isStatic}
|
isStatic={isStatic}
|
||||||
rid={rid}
|
rid={rid}
|
||||||
/>
|
/>
|
||||||
{handleEdit ? (
|
{handleEdit && serverVersion && compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '3.6.0') ? (
|
||||||
<Button
|
<Button
|
||||||
title={I18n.t('Edit')}
|
title={I18n.t('Edit')}
|
||||||
type='secondary'
|
type='secondary'
|
||||||
|
|
|
@ -5,7 +5,6 @@ import { StackNavigationProp } from '@react-navigation/stack';
|
||||||
import ImagePicker, { Image } from 'react-native-image-crop-picker';
|
import ImagePicker, { Image } from 'react-native-image-crop-picker';
|
||||||
import { shallowEqual } from 'react-redux';
|
import { shallowEqual } from 'react-redux';
|
||||||
|
|
||||||
import { compareServerVersion } from '../../lib/methods/helpers';
|
|
||||||
import KeyboardView from '../../containers/KeyboardView';
|
import KeyboardView from '../../containers/KeyboardView';
|
||||||
import sharedStyles from '../Styles';
|
import sharedStyles from '../Styles';
|
||||||
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
|
import scrollPersistTaps from '../../lib/methods/helpers/scrollPersistTaps';
|
||||||
|
@ -65,11 +64,10 @@ const ChangeAvatarView = () => {
|
||||||
const [state, dispatch] = useReducer(reducer, initialState);
|
const [state, dispatch] = useReducer(reducer, initialState);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
const { colors } = useTheme();
|
const { colors } = useTheme();
|
||||||
const { userId, username, serverVersion } = useAppSelector(
|
const { userId, username } = useAppSelector(
|
||||||
state => ({
|
state => ({
|
||||||
userId: getUserSelector(state).id,
|
userId: getUserSelector(state).id,
|
||||||
username: getUserSelector(state).username,
|
username: getUserSelector(state).username
|
||||||
serverVersion: state.server.version
|
|
||||||
}),
|
}),
|
||||||
shallowEqual
|
shallowEqual
|
||||||
);
|
);
|
||||||
|
@ -110,7 +108,6 @@ const ChangeAvatarView = () => {
|
||||||
const submit = async () => {
|
const submit = async () => {
|
||||||
try {
|
try {
|
||||||
setSaving(true);
|
setSaving(true);
|
||||||
console.log('🚀 ~ file: index.tsx:117 ~ submit ~ state', state);
|
|
||||||
if (context === 'room' && room?.rid) {
|
if (context === 'room' && room?.rid) {
|
||||||
// Change Rooms Avatar
|
// Change Rooms Avatar
|
||||||
await changeRoomsAvatar(room.rid);
|
await changeRoomsAvatar(room.rid);
|
||||||
|
@ -133,7 +130,6 @@ const ChangeAvatarView = () => {
|
||||||
|
|
||||||
const changeRoomsAvatar = async (rid: string) => {
|
const changeRoomsAvatar = async (rid: string) => {
|
||||||
try {
|
try {
|
||||||
console.log('🚀 ~ file: index.tsx:135 ~ changeRoomsAvatar ~ rid', rid, state);
|
|
||||||
await Services.saveRoomSettings(rid, { roomAvatar: state?.data });
|
await Services.saveRoomSettings(rid, { roomAvatar: state?.data });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log(e);
|
log(e);
|
||||||
|
@ -143,7 +139,6 @@ const ChangeAvatarView = () => {
|
||||||
|
|
||||||
const changeUserAvatar = async (avatarUpload: IAvatar) => {
|
const changeUserAvatar = async (avatarUpload: IAvatar) => {
|
||||||
try {
|
try {
|
||||||
console.log('🚀 ~ file: index.tsx:144 ~ changeUserAvatar ~ avatarUpload', avatarUpload);
|
|
||||||
await Services.setAvatarFromService(avatarUpload);
|
await Services.setAvatarFromService(avatarUpload);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return handleError(e, 'changing_avatar');
|
return handleError(e, 'changing_avatar');
|
||||||
|
@ -152,7 +147,6 @@ const ChangeAvatarView = () => {
|
||||||
|
|
||||||
const resetUserAvatar = async () => {
|
const resetUserAvatar = async () => {
|
||||||
try {
|
try {
|
||||||
console.log('🚀 ~ file: index.tsx:154 ~ resetUserAvatar ~ userId', userId);
|
|
||||||
await Services.resetAvatar(userId);
|
await Services.resetAvatar(userId);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return handleError(e, 'changing_avatar');
|
return handleError(e, 'changing_avatar');
|
||||||
|
@ -255,7 +249,7 @@ const ChangeAvatarView = () => {
|
||||||
onPress={pickImage}
|
onPress={pickImage}
|
||||||
testID='change-avatar-view-logout-other-locations'
|
testID='change-avatar-view-logout-other-locations'
|
||||||
/>
|
/>
|
||||||
{context === 'room' && serverVersion && compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '3.6.0') ? (
|
{context === 'room' ? (
|
||||||
<Button
|
<Button
|
||||||
title={I18n.t('Delete_image')}
|
title={I18n.t('Delete_image')}
|
||||||
type='primary'
|
type='primary'
|
||||||
|
|
|
@ -6,7 +6,7 @@ export default StyleSheet.create({
|
||||||
avatarContainer: {
|
avatarContainer: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginBottom: 32
|
marginBottom: 24
|
||||||
},
|
},
|
||||||
separator: {
|
separator: {
|
||||||
marginVertical: 16
|
marginVertical: 16
|
||||||
|
|
|
@ -527,7 +527,7 @@ class RoomInfoEditView extends React.Component<IRoomInfoEditViewProps, IRoomInfo
|
||||||
{...scrollPersistTaps}
|
{...scrollPersistTaps}
|
||||||
>
|
>
|
||||||
<View style={styles.avatarContainer}>
|
<View style={styles.avatarContainer}>
|
||||||
<AvatarWithEdit type={room.t} text={room.name} rid={room.rid} size={100} handleEdit={this.handleEditAvatar} />
|
<AvatarWithEdit type={room.t} text={room.name} rid={room.rid} handleEdit={this.handleEditAvatar} />
|
||||||
</View>
|
</View>
|
||||||
<FormTextInput
|
<FormTextInput
|
||||||
inputRef={e => {
|
inputRef={e => {
|
||||||
|
|
|
@ -76,7 +76,8 @@ export default StyleSheet.create({
|
||||||
avatarContainer: {
|
avatarContainer: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginBottom: 10
|
marginBottom: 32,
|
||||||
|
marginTop: 16
|
||||||
},
|
},
|
||||||
resetButton: {
|
resetButton: {
|
||||||
padding: 4,
|
padding: 4,
|
||||||
|
|
|
@ -416,7 +416,6 @@ class RoomInfoView extends React.Component<IRoomInfoViewProps, IRoomInfoViewStat
|
||||||
text={room.name || roomUser.username}
|
text={room.name || roomUser.username}
|
||||||
style={styles.avatar}
|
style={styles.avatar}
|
||||||
type={this.t}
|
type={this.t}
|
||||||
size={100}
|
|
||||||
rid={room?.rid}
|
rid={room?.rid}
|
||||||
handleEdit={showAvatarEdit ? this.handleEditAvatar : undefined}
|
handleEdit={showAvatarEdit ? this.handleEditAvatar : undefined}
|
||||||
>
|
>
|
||||||
|
|
|
@ -21,7 +21,8 @@ export default StyleSheet.create({
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
paddingVertical: 8
|
paddingBottom: 8,
|
||||||
|
paddingTop: 32
|
||||||
},
|
},
|
||||||
avatar: {
|
avatar: {
|
||||||
marginHorizontal: 10
|
marginHorizontal: 10
|
||||||
|
|
Loading…
Reference in New Issue