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 React, { useState, Fragment, useRef } from 'react';
import { View, Text, ActivityIndicator, SafeAreaView } from 'react-native'; import { View, Text, ActivityIndicator, SafeAreaView } from 'react-native';
import { injectIntl } from 'react-intl'; import { injectIntl } from 'react-intl';
import { useSelector } from 'react-redux';
import moment from 'moment';
// Components // Components
import { TextButton, Modal, BeneficiaryModal } from '../..'; import { TextButton } from '../..';
import { IconButton } from '../../iconButton'; import { IconButton } from '../../iconButton';
import { DropdownButton } from '../../dropdownButton'; import { DropdownButton } from '../../dropdownButton';
import { TextInput } from '../../textInput'; import { TextInput } from '../../textInput';
import { DateTimePicker } from '../../dateTimePicker';
// Constants // Constants
// Styles // Styles
@ -28,7 +25,6 @@ const BasicHeaderView = ({
intl, intl,
isDraftSaved, isDraftSaved,
isDraftSaving, isDraftSaving,
draftId,
isFormValid, isFormValid,
isHasDropdown, isHasDropdown,
isHasIcons, isHasIcons,
@ -46,23 +42,14 @@ const BasicHeaderView = ({
title, title,
handleOnSubmit, handleOnSubmit,
handleOnSearch, handleOnSearch,
handleDatePickerChange,
handleRewardChange, handleRewardChange,
handleBeneficiaries,
enableViewModeToggle, enableViewModeToggle,
handleSettingsPress, handleSettingsPress,
showThumbSelectionModal,
}) => { }) => {
const [isInputVisible, setIsInputVisible] = useState(false); 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 rewardMenuRef = useRef(null);
const scheduleRef = useRef(null);
/** /**
* *
@ -90,27 +77,6 @@ const BasicHeaderView = ({
handleOnSearch(value); 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) => { const _handleRewardMenuSelect = (index) => {
let rewardType = 'default'; 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> </Fragment>
)} )}
</View> </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 <OptionsModal
ref={rewardMenuRef} ref={rewardMenuRef}
options={[ options={[
@ -354,6 +246,7 @@ const BasicHeaderView = ({
title="Reward" title="Reward"
onPress={_handleRewardMenuSelect} onPress={_handleRewardMenuSelect}
/> />
</SafeAreaView> </SafeAreaView>
); );
}; };

View File

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

View File

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