added reblog setting support

This commit is contained in:
noumantahir 2021-12-07 23:31:17 +05:00
parent 1f83c5c1a7
commit 3addec09c5
2 changed files with 21 additions and 6 deletions

View File

@ -1,8 +1,8 @@
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react'; import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
import { useIntl } from 'react-intl'; import { useIntl } from 'react-intl';
import { ScrollView, View } from 'react-native'; import { View } from 'react-native';
import { BeneficiaryModal, DateTimePicker, Modal, SettingsItem } from '../../../components'; import { DateTimePicker, Modal, SettingsItem } from '../../../components';
import styles from './editorSettingsModalStyles'; import styles from './editorSettingsModalStyles';
import ThumbSelectionContent from './thumbSelectionContent'; import ThumbSelectionContent from './thumbSelectionContent';
import {View as AnimatedView} from 'react-native-animatable'; import {View as AnimatedView} from 'react-native-animatable';
@ -35,19 +35,23 @@ export interface EditorSettingsModalRef {
interface EditorSettingsModalProps { interface EditorSettingsModalProps {
body:string; body:string;
draftId:string; draftId:string;
isCommunityPost:boolean;
handleRewardChange:(rewardType:string)=>void; handleRewardChange:(rewardType:string)=>void;
handleThumbSelection:(index:number)=>void; handleThumbSelection:(index:number)=>void;
handleScheduleChange:(datetime:string|null)=>void; handleScheduleChange:(datetime:string|null)=>void;
handleBeneficiariesChange:(beneficiaries:Beneficiary[])=>void; handleBeneficiariesChange:(beneficiaries:Beneficiary[])=>void;
handleShouldReblogChange:(shouldReblog:boolean)=>void;
} }
const EditorSettingsModal = forwardRef(({ const EditorSettingsModal = forwardRef(({
body, body,
draftId, draftId,
isCommunityPost,
handleRewardChange, handleRewardChange,
handleThumbSelection, handleThumbSelection,
handleScheduleChange, handleScheduleChange,
handleBeneficiariesChange, handleBeneficiariesChange,
handleShouldReblogChange,
}: EditorSettingsModalProps, ref) => { }: EditorSettingsModalProps, ref) => {
const intl = useIntl(); const intl = useIntl();
@ -55,6 +59,7 @@ const EditorSettingsModal = forwardRef(({
const [rewardTypeIndex, setRewardTypeIndex] = useState(0); const [rewardTypeIndex, setRewardTypeIndex] = useState(0);
const [thumbIndex, setThumbIndex] = useState(0); const [thumbIndex, setThumbIndex] = useState(0);
const [scheduleLater, setScheduleLater] = useState(false) const [scheduleLater, setScheduleLater] = useState(false)
const [shouldReblog, setShouldReblog] = useState(false);
const [scheduledFor, setScheduledFor] = useState(''); const [scheduledFor, setScheduledFor] = useState('');
useEffect(() => { useEffect(() => {
@ -71,6 +76,10 @@ const EditorSettingsModal = forwardRef(({
handleScheduleChange(scheduledFor) handleScheduleChange(scheduledFor)
} }
}, [scheduleLater, scheduledFor]) }, [scheduleLater, scheduledFor])
useEffect(() => {
handleShouldReblogChange(shouldReblog)
}, [shouldReblog])
useImperativeHandle(ref, () => ({ useImperativeHandle(ref, () => ({
@ -134,15 +143,19 @@ const EditorSettingsModal = forwardRef(({
handleOnChange={_handleRewardChange} handleOnChange={_handleRewardChange}
/> />
{/* <SettingsItem
{isCommunityPost && (
<SettingsItem
title={intl.formatMessage({ title={intl.formatMessage({
id: 'editor.setting_reblog', id: 'editor.setting_reblog',
})} })}
type="toggle" type="toggle"
actionType="reblog" actionType="reblog"
selectedOptionIndex={rewardTypeIndex} isOn={shouldReblog}
handleOnChange={_handleRewardChange} handleOnChange={setShouldReblog}
/> */} />
)}
<ThumbSelectionContent <ThumbSelectionContent
body={body} body={body}

View File

@ -463,10 +463,12 @@ class EditorScreen extends Component {
ref={(componentRef) => (this.editorSettingsModalRef = componentRef)} ref={(componentRef) => (this.editorSettingsModalRef = componentRef)}
body={fields.body} body={fields.body}
draftId={draftId} draftId={draftId}
isCommunityPost={false}
handleThumbSelection={this._handleOnThumbSelection} handleThumbSelection={this._handleOnThumbSelection}
handleRewardChange={handleRewardChange} handleRewardChange={handleRewardChange}
handleScheduleChange={this._handleScheduleChange} handleScheduleChange={this._handleScheduleChange}
handleBeneficiariesChange={handleBeneficiaries} handleBeneficiariesChange={handleBeneficiaries}
handleShouldReblogChange={()=>{}}
/> />
</View> </View>
); );