Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1e97a08
[IMPROVE] Add emoji picker to iOS
reinaldonetof Jul 13, 2022
14c31e2
clean left and right buttons
reinaldonetof Jul 14, 2022
12246bd
fix the redux in emojipicker
reinaldonetof Jul 14, 2022
b231131
fix behavior when emoji keyboard is openning
reinaldonetof Jul 15, 2022
643e1a7
added isIOS
reinaldonetof Jul 15, 2022
83b7220
fix show reactions when emoji is open
reinaldonetof Jul 18, 2022
524d41e
minor tweak
reinaldonetof Jul 18, 2022
e3eb91a
add provider
reinaldonetof Jul 18, 2022
4f5b1bd
fix baseurl
reinaldonetof Jul 18, 2022
ede578c
minor tweak
reinaldonetof Jul 18, 2022
1d5a1ab
create closeEmojiAndAction and added to record
reinaldonetof Jul 19, 2022
b6ad909
fix actionsheet for omnichannel
reinaldonetof Jul 19, 2022
2d248fb
Merge branch 'develop' into improve.ios-keyboard
reinaldonetof Jul 19, 2022
5424f34
fix action sheet
reinaldonetof Jul 19, 2022
4eb6023
fix close emoji when navigate to other screen
reinaldonetof Jul 19, 2022
2c1c0d1
added iactionsheetprovider to roomview
reinaldonetof Jul 20, 2022
ed92cda
clean variables
reinaldonetof Jul 20, 2022
2023e1c
fix theme
reinaldonetof Jul 22, 2022
15d6b7e
close the emojikeyboard when click on message
reinaldonetof Jul 22, 2022
1782b10
apoint package.json to new pr
reinaldonetof Jul 22, 2022
ddbf4dc
fix branch
reinaldonetof Jul 28, 2022
ab6e90e
Merge branch 'develop' into improve.ios-keyboard
reinaldonetof Jul 29, 2022
6168401
fix package.json
reinaldonetof Jul 29, 2022
988da56
Merge branch 'develop' into improve.ios-keyboard
reinaldonetof Aug 2, 2022
bd3d6db
Merge branch 'develop' into improve.ios-keyboard
reinaldonetof Aug 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/containers/EmojiPicker/EmojiCategory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class EmojiCategory extends React.Component<IEmojiCategory> {
initialNumToRender={45}
removeClippedSubviews
{...scrollPersistTaps}
keyboardDismissMode={'none'}
Comment thread
reinaldonetof marked this conversation as resolved.
/>
);
}
Expand Down
7 changes: 4 additions & 3 deletions app/containers/EmojiPicker/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import protectedFunction from '../../lib/methods/helpers/protectedFunction';
import shortnameToUnicode from '../../lib/methods/helpers/shortnameToUnicode';
import log from '../../lib/methods/helpers/log';
import { themes } from '../../lib/constants';
import { TSupportedThemes, withTheme } from '../../theme';
import { TSupportedThemes } from '../../theme';
import { IEmoji, TGetCustomEmoji, IApplicationState, ICustomEmojis, TFrequentlyUsedEmojiModel } from '../../definitions';

interface IEmojiPickerProps {
Expand Down Expand Up @@ -198,7 +198,8 @@ class EmojiPicker extends Component<IEmojiPickerProps, IEmojiPickerState> {
}

const mapStateToProps = (state: IApplicationState) => ({
customEmojis: state.customEmojis
customEmojis: state.customEmojis,
baseUrl: state.share.server.server || state.server.server
});

export default connect(mapStateToProps)(withTheme(EmojiPicker));
export default connect(mapStateToProps)(EmojiPicker);
37 changes: 13 additions & 24 deletions app/containers/MessageBox/EmojiKeyboard.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,28 @@
import React from 'react';
import { View } from 'react-native';
import { KeyboardRegistry } from 'react-native-ui-lib/keyboard';
import { Provider } from 'react-redux';

import { store } from '../../lib/store/auxStore';
import store from '../../lib/store';
import EmojiPicker from '../EmojiPicker';
import styles from './styles';
import { themes } from '../../lib/constants';
import { TSupportedThemes, withTheme } from '../../theme';
import { TSupportedThemes } from '../../theme';

interface IMessageBoxEmojiKeyboard {
theme: TSupportedThemes;
}

export default class EmojiKeyboard extends React.PureComponent<IMessageBoxEmojiKeyboard, any> {
private readonly baseUrl: string;

constructor(props: IMessageBoxEmojiKeyboard) {
super(props);
const state = store.getState();
this.baseUrl = state.share.server.server || state.server.server;
}

onEmojiSelected = (emoji: string) => {
const EmojiKeyboard = ({ theme }: { theme: TSupportedThemes }) => {
const onEmojiSelected = (emoji: string) => {
KeyboardRegistry.onItemSelected('EmojiKeyboard', { emoji });
};

render() {
const { theme } = this.props;
return (
return (
<Provider store={store}>
<View
style={[styles.emojiKeyboardContainer, { borderTopColor: themes[theme].borderColor }]}
testID='messagebox-keyboard-emoji'>
<EmojiPicker onEmojiSelected={this.onEmojiSelected} baseUrl={this.baseUrl} theme={theme} />
<EmojiPicker onEmojiSelected={onEmojiSelected} theme={theme} />
</View>
);
}
}
KeyboardRegistry.registerKeyboard('EmojiKeyboard', () => withTheme(EmojiKeyboard));
</Provider>
);
};

KeyboardRegistry.registerKeyboard('EmojiKeyboard', () => EmojiKeyboard);
24 changes: 0 additions & 24 deletions app/containers/MessageBox/LeftButtons.ios.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions app/containers/MessageBox/RecordAudio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface IMessageBoxRecordAudioProps {
permissionToUpload: boolean;
recordingCallback: Function;
onFinish: Function;
onStart: Function;
}

const RECORDING_EXTENSION = '.m4a';
Expand Down Expand Up @@ -116,6 +117,9 @@ export default class RecordAudio extends React.PureComponent<IMessageBoxRecordAu
};

startRecordingAudio = async () => {
const { onStart } = this.props;
onStart();

logEvent(events.ROOM_AUDIO_RECORD);
if (!this.isRecorderBusy) {
this.isRecorderBusy = true;
Expand Down
17 changes: 0 additions & 17 deletions app/containers/MessageBox/RightButtons.ios.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import { View } from 'react-native';

import { isIOS } from '../../lib/methods/helpers';
import { ActionsButton, SendButton } from './buttons';
import styles from './styles';

Expand All @@ -18,7 +19,7 @@ const RightButtons = React.memo(({ showSend, submit, showMessageBoxActions, isAc
if (isActionsEnabled) {
return <ActionsButton onPress={showMessageBoxActions} />;
}
return <View style={styles.buttonsWhitespace} />;
return !isIOS ? <View style={styles.buttonsWhitespace} /> : null;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't see a visual difference in this case here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The VIEW was implemented before only for Android, because of this I created this conditional. I was not able to find why this was implemented only for android. But I remember that at some point a long time ago @diegolmello commented with me about this view. So instead create a regression, I implemented this conditional.

});

export default RightButtons;
2 changes: 2 additions & 0 deletions app/containers/MessageBox/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export const MENTIONS_TRACKING_TYPE_COMMANDS = '/';
export const MENTIONS_TRACKING_TYPE_ROOMS = '#';
export const MENTIONS_TRACKING_TYPE_CANNED = '!';
export const MENTIONS_COUNT_TO_DISPLAY = 4;

export const TIMEOUT_CLOSE_EMOJI = 300;
40 changes: 21 additions & 19 deletions app/containers/MessageBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ import RecordAudio from './RecordAudio';
import I18n from '../../i18n';
import ReplyPreview from './ReplyPreview';
import { themes } from '../../lib/constants';
// @ts-ignore
// eslint-disable-next-line import/extensions,import/no-unresolved
import LeftButtons from './LeftButtons';
// @ts-ignore
// eslint-disable-next-line import/extensions,import/no-unresolved
import RightButtons from './RightButtons';
import { canUploadFile } from '../../lib/methods/helpers/media';
import EventEmiter from '../../lib/methods/helpers/events';
Expand All @@ -37,12 +33,13 @@ import {
MENTIONS_TRACKING_TYPE_COMMANDS,
MENTIONS_TRACKING_TYPE_EMOJIS,
MENTIONS_TRACKING_TYPE_ROOMS,
MENTIONS_TRACKING_TYPE_USERS
MENTIONS_TRACKING_TYPE_USERS,
TIMEOUT_CLOSE_EMOJI
} from './constants';
import CommandsPreview from './CommandsPreview';
import { getUserSelector } from '../../selectors/login';
import Navigation from '../../lib/navigation/appNavigation';
import { withActionSheet } from '../ActionSheet';
import { TActionSheetOptionsItem, withActionSheet } from '../ActionSheet';
import { sanitizeLikeString } from '../../lib/database/utils';
import { CustomIcon } from '../CustomIcon';
import { forceJpgExtension } from './forceJpgExtension';
Expand All @@ -58,14 +55,12 @@ import {
} from '../../definitions';
import { MasterDetailInsideStackParamList } from '../../stacks/MasterDetailStack/types';
import { getPermalinkMessage, search, sendFileMessage } from '../../lib/methods';
import { hasPermission, debounce, isAndroid, isTablet } from '../../lib/methods/helpers';
import { hasPermission, debounce, isAndroid, isIOS, isTablet } from '../../lib/methods/helpers';
import { Services } from '../../lib/services';
import { TSupportedThemes } from '../../theme';
import { ChatsStackParamList } from '../../stacks/types';

if (isAndroid) {
require('./EmojiKeyboard');
}
require('./EmojiKeyboard');

const imagePickerConfig = {
cropping: true,
Expand Down Expand Up @@ -270,6 +265,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
}, 500);
});
this.unsubscribeBlur = navigation.addListener('blur', () => {
this.closeEmoji();
this.component?.blur();
});
}
Expand Down Expand Up @@ -330,6 +326,9 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
if (nextProps.theme !== theme) {
return true;
}
if (nextState.showEmojiKeyboard !== showEmojiKeyboard) {
return true;
}
if (!isFocused()) {
return false;
}
Expand All @@ -342,9 +341,6 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
if (nextProps.editing !== editing) {
return true;
}
if (nextState.showEmojiKeyboard !== showEmojiKeyboard) {
return true;
}
if (nextState.trackingType !== trackingType) {
return true;
}
Expand Down Expand Up @@ -809,7 +805,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
const { permissionToUpload } = this.state;
const { showActionSheet, goToCannedResponses } = this.props;

const options = [];
const options: TActionSheetOptionsItem[] = [];
if (goToCannedResponses) {
options.push({
title: I18n.t('Canned_Responses'),
Expand Down Expand Up @@ -847,7 +843,8 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
icon: 'discussions',
onPress: this.createDiscussion
});
showActionSheet({ options });

this.closeEmojiAndAction(showActionSheet, { options });
};

editCancel = () => {
Expand Down Expand Up @@ -883,6 +880,13 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
this.setState({ showEmojiKeyboard: false });
};

closeEmojiAndAction = (action?: Function, params?: any) => {
const { showEmojiKeyboard } = this.state;

this.closeEmoji();
setTimeout(() => action && action(params), showEmojiKeyboard && isIOS ? TIMEOUT_CLOSE_EMOJI : null);
};

submit = async () => {
const { tshow } = this.state;
const { onSubmit, rid: roomId, tmid, showSend, sharing } = this.props;
Expand Down Expand Up @@ -1089,6 +1093,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
recordingCallback={this.recordingCallback}
onFinish={this.finishAudioMessage}
permissionToUpload={permissionToUpload}
onStart={this.closeEmoji}
/>
);

Expand All @@ -1112,14 +1117,11 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
const textInputAndButtons = !recording ? (
<>
<LeftButtons
theme={theme}
showEmojiKeyboard={showEmojiKeyboard}
editing={editing}
showMessageBoxActions={this.showMessageBoxActions}
editCancel={this.editCancel}
openEmoji={this.openEmoji}
closeEmoji={this.closeEmoji}
isActionsEnabled={isActionsEnabled}
/>
<TextInput
ref={component => (this.component = component)}
Expand All @@ -1138,7 +1140,6 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
{...isAndroidTablet}
/>
<RightButtons
theme={theme}
showSend={showSend}
submit={this.submit}
showMessageBoxActions={this.showMessageBoxActions}
Expand Down Expand Up @@ -1187,6 +1188,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
renderContent={this.renderContent}
kbInputRef={this.component}
kbComponent={showEmojiKeyboard ? 'EmojiKeyboard' : null}
kbInitialProps={{ theme }}
onKeyboardResigned={this.onKeyboardResigned}
onItemSelected={this.onEmojiSelected}
trackInteractive
Expand Down
11 changes: 10 additions & 1 deletion app/containers/message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ interface IMessageContainerProps {
jumpToMessage?: (link: string) => void;
onPress?: () => void;
theme: TSupportedThemes;
closeEmojiAndAction?: (action?: Function, params?: any) => void;
}

interface IMessageContainerState {
Expand Down Expand Up @@ -114,6 +115,14 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
}
}

closeEmojiAndAction = () => {
const { closeEmojiAndAction } = this.props;

if (closeEmojiAndAction) {
closeEmojiAndAction(this.onPress);
}
};

onPress = debounce(
() => {
const { onPress } = this.props;
Expand Down Expand Up @@ -373,7 +382,7 @@ class MessageContainer extends React.Component<IMessageContainerProps, IMessageC
value={{
user,
baseUrl,
onPress: this.onPress,
onPress: this.closeEmojiAndAction,
onLongPress: this.onLongPress,
reactionInit: this.reactionInit,
onErrorPress: this.onErrorPress,
Expand Down
6 changes: 2 additions & 4 deletions app/views/RoomView/ReactionPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const margin = isAndroid ? 40 : 20;
const maxSize = 400;

interface IReactionPickerProps {
baseUrl: string;
message?: any;
show: boolean;
isMasterDetail: boolean;
Expand Down Expand Up @@ -42,7 +41,7 @@ class ReactionPicker extends React.Component<IReactionPickerProps> {
};

render() {
const { width, height, show, baseUrl, reactionClose, isMasterDetail, theme } = this.props;
const { width, height, show, reactionClose, isMasterDetail, theme } = this.props;

let widthStyle = width - margin;
let heightStyle = Math.min(width, height) - margin * 2;
Expand Down Expand Up @@ -70,15 +69,14 @@ class ReactionPicker extends React.Component<IReactionPickerProps> {
}
]}
testID='reaction-picker'>
<EmojiPicker theme={theme} onEmojiSelected={this.onEmojiSelected} baseUrl={baseUrl} />
<EmojiPicker theme={theme} onEmojiSelected={this.onEmojiSelected} />
</View>
</Modal>
) : null;
}
}

const mapStateToProps = (state: IApplicationState) => ({
baseUrl: state.server.server,
isMasterDetail: state.app.isMasterDetail
});

Expand Down
Loading