* Initial commit post input * Fix message posting, add create direct channel and minor fixes * Fix "is typing" and "react to last post" behaviour * Some reordering, better handling of upload error, properly clear draft on send message, and fix minor progress bar misbehavior * Add keyboard listener for shift-enter, add selection between video or photo while attaching, add alert when trying to attach more than you are allowed, add paste functionality, minor fixes and reordering * Add library patch * Fix lint * Address feedback * Address feedback * Add missing negation * Check for group name and fix typo on draft comparisons * Address feedback * Address feedback * Address feedback * Address feedback * Fix several bugs * Remove @app imports * Address feedback * fix post list & post draft layout on iOS * Fix post draft cursor position * Fix file upload route * Allow to pick multiple images using the image picker * accurately get the channel member count * remove android cursor workaround * Remove local const INPUT_LINE_HEIGHT * move getPlaceHolder out of the component * use substring instead of legacy substr for hardward keyboard * Move onAppStateChange above the effects * Fix camera action bottom sheet * no need to memo SendButton * properly use memberCount in sender handler * Refactor how to get memberCount * Fix queryRecentPostsInThread * Remove unused isDirectChannelVisible && isGroupChannelVisible util functions * rename errorBadUser to errorUnkownUser * extract localized strings * use ClientErrorProps instead of ClientError * Minor improvements Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
101 lines
2.7 KiB
TypeScript
101 lines
2.7 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import React from 'react';
|
|
import {Platform, StyleSheet, View} from 'react-native';
|
|
|
|
import CameraAction from './camera_quick_action';
|
|
import FileAction from './file_quick_action';
|
|
import ImageAction from './image_quick_action';
|
|
import InputAction from './input_quick_action';
|
|
|
|
type Props = {
|
|
testID?: string;
|
|
canUploadFiles: boolean;
|
|
fileCount: number;
|
|
maxFileCount: number;
|
|
|
|
// Draft Handler
|
|
value: string;
|
|
updateValue: (value: string) => void;
|
|
addFiles: (file: FileInfo[]) => void;
|
|
}
|
|
|
|
const style = StyleSheet.create({
|
|
container: {
|
|
display: 'flex',
|
|
flexDirection: 'row',
|
|
justifyContent: 'space-between',
|
|
alignItems: 'center',
|
|
paddingBottom: Platform.select({
|
|
ios: 1,
|
|
android: 2,
|
|
}),
|
|
},
|
|
quickActionsContainer: {
|
|
display: 'flex',
|
|
flexDirection: 'row',
|
|
height: 44,
|
|
},
|
|
});
|
|
|
|
export default function QuickActions({
|
|
testID,
|
|
canUploadFiles,
|
|
value,
|
|
fileCount,
|
|
maxFileCount,
|
|
updateValue,
|
|
addFiles,
|
|
}: Props) {
|
|
const atDisabled = value[value.length - 1] === '@';
|
|
const slashDisabled = value.length > 0;
|
|
|
|
const atInputActionTestID = `${testID}.at_input_action`;
|
|
const slashInputActionTestID = `${testID}.slash_input_action`;
|
|
const fileActionTestID = `${testID}.file_action`;
|
|
const imageActionTestID = `${testID}.image_action`;
|
|
const cameraActionTestID = `${testID}.camera_action`;
|
|
|
|
const uploadProps = {
|
|
disabled: !canUploadFiles,
|
|
fileCount,
|
|
maxFileCount,
|
|
maxFilesReached: fileCount >= maxFileCount,
|
|
onUploadFiles: addFiles,
|
|
};
|
|
|
|
return (
|
|
<View
|
|
testID={testID}
|
|
style={style.quickActionsContainer}
|
|
>
|
|
<InputAction
|
|
testID={atInputActionTestID}
|
|
disabled={atDisabled}
|
|
inputType='at'
|
|
onTextChange={updateValue}
|
|
value={value}
|
|
/>
|
|
<InputAction
|
|
testID={slashInputActionTestID}
|
|
disabled={slashDisabled}
|
|
inputType='slash'
|
|
onTextChange={updateValue}
|
|
value={''} // Only enabled when value == ''
|
|
/>
|
|
<FileAction
|
|
testID={fileActionTestID}
|
|
{...uploadProps}
|
|
/>
|
|
<ImageAction
|
|
testID={imageActionTestID}
|
|
{...uploadProps}
|
|
/>
|
|
<CameraAction
|
|
testID={cameraActionTestID}
|
|
{...uploadProps}
|
|
/>
|
|
</View>
|
|
);
|
|
}
|