removed unused modals and methods from editor screen and basic header

This commit is contained in:
Nouman Tahir 2022-06-08 12:53:30 +05:00
parent c69799d2d4
commit 38968d79a0
3 changed files with 10 additions and 130 deletions

View File

@ -1,15 +1,12 @@
import React, { useState, Fragment, useRef } from 'react';
import { View, Text, ActivityIndicator, SafeAreaView } from 'react-native';
import { injectIntl } from 'react-intl';
import { useSelector } from 'react-redux';
import moment from 'moment';
// Components
import { TextButton, Modal, BeneficiaryModal } from '../..';
import { TextButton } from '../..';
import { IconButton } from '../../iconButton';
import { DropdownButton } from '../../dropdownButton';
import { TextInput } from '../../textInput';
import { DateTimePicker } from '../../dateTimePicker';
// Constants
// Styles
@ -28,7 +25,6 @@ const BasicHeaderView = ({
intl,
isDraftSaved,
isDraftSaving,
draftId,
isFormValid,
isHasDropdown,
isHasIcons,
@ -46,23 +42,14 @@ const BasicHeaderView = ({
title,
handleOnSubmit,
handleOnSearch,
handleDatePickerChange,
handleRewardChange,
handleBeneficiaries,
enableViewModeToggle,
handleSettingsPress,
showThumbSelectionModal,
}) => {
const [isInputVisible, setIsInputVisible] = useState(false);
const [beneficiaryModal, setBeneficiaryModal] = useState(false);
const [showScheduleModal, setShowScheduleModal] = useState(false);
const [scheduledDate, setScheduledDate] = useState('');
const username = useSelector((state) => state.account.currentAccount.name);
const settingMenuRef = useRef(null);
const rewardMenuRef = useRef(null);
const scheduleRef = useRef(null);
/**
*
@ -90,27 +77,6 @@ const BasicHeaderView = ({
handleOnSearch(value);
};
const _handleSettingMenuSelect = (index) => {
switch (index) {
case 0:
setShowScheduleModal(true);
break;
case 1:
if (showThumbSelectionModal) {
showThumbSelectionModal();
}
break;
case 2:
rewardMenuRef.current.show();
break;
case 3:
setBeneficiaryModal(true);
break;
default:
break;
}
};
const _handleRewardMenuSelect = (index) => {
let rewardType = 'default';
@ -131,32 +97,7 @@ const BasicHeaderView = ({
}
};
const _handleOnSaveBeneficiaries = (beneficiaries) => {
const _beneficiaries = beneficiaries.map((item) => ({
account: item.account,
weight: item.weight,
}));
setBeneficiaryModal(false);
if (handleBeneficiaries) {
handleBeneficiaries(_beneficiaries);
}
};
const _handleDatePickerChange = (datePickerValue) => {
setScheduledDate(datePickerValue);
};
const _onPressDone = () => {
let dateString = scheduledDate;
if (dateString === '') {
dateString = moment().format();
}
setScheduledDate('');
handleDatePickerChange(dateString);
setShowScheduleModal(false);
};
/**
*
@ -291,57 +232,8 @@ const BasicHeaderView = ({
</Fragment>
)}
</View>
<Modal
isOpen={beneficiaryModal}
isFullScreen
isCloseButton
presentationStyle="formSheet"
handleOnModalClose={() => setBeneficiaryModal(false)}
title={intl.formatMessage({ id: 'editor.beneficiaries' })}
animationType="slide"
style={styles.beneficiaryModal}
>
<BeneficiaryModal
username={username}
handleOnSaveBeneficiaries={_handleOnSaveBeneficiaries}
draftId={draftId}
/>
</Modal>
<Modal
isFullScreen={false}
isOpen={showScheduleModal}
isBottomModal
isTransparent
isRadius
coverScreen={false}
title={intl.formatMessage({ id: 'editor.schedule_modal_title' })}
hasRightText
rightText="Done"
onPressRightText={_onPressDone}
onBackdropPress={() => setShowScheduleModal(false)}
>
<SafeAreaView style={styles.dateTimeModal}>
<DateTimePicker
type="datetime"
onChanged={_handleDatePickerChange}
disabled={!isFormValid}
ref={scheduleRef}
/>
</SafeAreaView>
</Modal>
<OptionsModal
ref={settingMenuRef}
options={[
intl.formatMessage({ id: 'editor.setting_schedule' }),
intl.formatMessage({ id: 'editor.setting_thumb' }),
intl.formatMessage({ id: 'editor.setting_reward' }),
intl.formatMessage({ id: 'editor.setting_beneficiary' }),
intl.formatMessage({ id: 'alert.cancel' }),
]}
cancelButtonIndex={4}
title={intl.formatMessage({ id: 'editor.options' })}
onPress={_handleSettingMenuSelect}
/>
<OptionsModal
ref={rewardMenuRef}
options={[
@ -354,6 +246,7 @@ const BasicHeaderView = ({
title="Reward"
onPress={_handleRewardMenuSelect}
/>
</SafeAreaView>
);
};

View File

@ -283,8 +283,6 @@ export const UploadsGalleryModal = forwardRef(({
}
return (
<Modal
isOpen={showModal}

View File

@ -39,7 +39,6 @@ class EditorScreen extends Component {
* ------------------------------------------------
* @prop { type } name - Description....
*/
thumbSelectionModalRef = null;
postOptionsModalRef = null;
constructor(props) {
@ -206,12 +205,6 @@ class EditorScreen extends Component {
}
};
_showThumbSelectionModal = () => {
const { fields } = this.state;
if (this.thumbSelectionModalRef) {
this.thumbSelectionModalRef.show(fields.body);
}
};
_handleScheduleChange = (datetime:string|null) => {
this.setState({
@ -406,8 +399,8 @@ class EditorScreen extends Component {
</Modal>
);
};
console.log('fields :', fields);
console.log('quickReplyText : ', quickReplyText);
return (
<View style={globalStyles.defaultContainer}>
@ -430,7 +423,6 @@ console.log('quickReplyText : ', quickReplyText);
isReply={isReply}
quickTitle={wordsCount > 0 && `${wordsCount} words`}
rightButtonText={rightButtonText}
showThumbSelectionModal={this._showThumbSelectionModal}
handleSettingsPress={this._handleSettingsPress}
/>
<PostForm
@ -474,12 +466,9 @@ console.log('quickReplyText : ', quickReplyText);
uploadProgress={uploadProgress}
/>
</PostForm>
{_renderCommunityModal()}
<ThumbSelectionModal
ref={(componentRef) => (this.thumbSelectionModalRef = componentRef)}
thumbIndex={thumbIndex}
onThumbSelection={this._handleOnThumbSelection}
/>
<PostOptionsModal
ref={(componentRef) => (this.postOptionsModalRef = componentRef)}
body={fields.body}