From b50002384f3fe281945cd0bf85be96bd815c9585 Mon Sep 17 00:00:00 2001 From: SergeyEzhin Date: Thu, 10 Aug 2023 01:06:23 +0300 Subject: [PATCH] [DE PE mobile] Change routing and props --- .../src/controller/edit/EditHyperlink.jsx | 4 +- apps/documenteditor/mobile/src/page/main.jsx | 7 +- .../mobile/src/view/edit/EditingPage.jsx | 16 +- .../mobile/src/controller/Preview.jsx | 2 +- .../mobile/src/controller/add/AddLink.jsx | 4 +- .../mobile/src/controller/edit/EditLink.jsx | 4 +- .../mobile/src/page/main.jsx | 36 ++-- .../mobile/src/view/add/Add.jsx | 177 +++------------- .../mobile/src/view/add/AddingPage.jsx | 110 ++++++++++ .../mobile/src/view/edit/Edit.jsx | 193 +++--------------- .../mobile/src/view/edit/EditingPage.jsx | 134 ++++++++++++ 11 files changed, 343 insertions(+), 344 deletions(-) create mode 100644 apps/presentationeditor/mobile/src/view/add/AddingPage.jsx create mode 100644 apps/presentationeditor/mobile/src/view/edit/EditingPage.jsx diff --git a/apps/documenteditor/mobile/src/controller/edit/EditHyperlink.jsx b/apps/documenteditor/mobile/src/controller/edit/EditHyperlink.jsx index 63f9b84b1c..c2a80e58c9 100644 --- a/apps/documenteditor/mobile/src/controller/edit/EditHyperlink.jsx +++ b/apps/documenteditor/mobile/src/controller/edit/EditHyperlink.jsx @@ -90,7 +90,7 @@ class EditHyperlinkController extends Component { return ( !this.props.isNavigate ? Device.phone ? - this.props.onClosed('edit-link')}> + this.props.closeOptions('edit-link')}> : - this.props.onClosed('edit-link')}> + this.props.closeOptions('edit-link')}> } - { - !this.state.editLinkSettingsVisible ? null : - + {!this.state.editLinkSettingsVisible ? null : + } {!this.state.settingsVisible ? null : } {!this.state.collaborationVisible ? null : diff --git a/apps/documenteditor/mobile/src/view/edit/EditingPage.jsx b/apps/documenteditor/mobile/src/view/edit/EditingPage.jsx index 80350c643f..3ea6566ac9 100644 --- a/apps/documenteditor/mobile/src/view/edit/EditingPage.jsx +++ b/apps/documenteditor/mobile/src/view/edit/EditingPage.jsx @@ -34,14 +34,14 @@ const EditLayoutNavbar = ({ editors }) => { return ( - {editors.length > 1 ? -
- {editors.map((item, index) => {item.caption})} - {isAndroid && } -
: - {editors[0].caption} - } - {Device.phone && } + {editors.length > 1 ? +
+ {editors.map((item, index) => {item.caption})} + {isAndroid && } +
: + {editors[0].caption} + } + {Device.phone && }
) }; diff --git a/apps/presentationeditor/mobile/src/controller/Preview.jsx b/apps/presentationeditor/mobile/src/controller/Preview.jsx index bd9e4fe6fa..f7b2ec0db9 100644 --- a/apps/presentationeditor/mobile/src/controller/Preview.jsx +++ b/apps/presentationeditor/mobile/src/controller/Preview.jsx @@ -86,7 +86,7 @@ const PreviewController = props => { // API Handlers const onEndDemonstration = () => { - props.onclosed(); + props.closeOptions('preview'); }; return ( diff --git a/apps/presentationeditor/mobile/src/controller/add/AddLink.jsx b/apps/presentationeditor/mobile/src/controller/add/AddLink.jsx index 599130ed10..102956adf1 100644 --- a/apps/presentationeditor/mobile/src/controller/add/AddLink.jsx +++ b/apps/presentationeditor/mobile/src/controller/add/AddLink.jsx @@ -138,13 +138,13 @@ class AddLinkController extends Component { return ( !this.props.isNavigate ? Device.phone ? - this.props.onClosed('add-link')}> + this.props.closeOptions('add-link')}> : - this.props.onClosed('add-link')}> + this.props.closeOptions('add-link')}> diff --git a/apps/presentationeditor/mobile/src/controller/edit/EditLink.jsx b/apps/presentationeditor/mobile/src/controller/edit/EditLink.jsx index 32f2aafa0d..124b787b4d 100644 --- a/apps/presentationeditor/mobile/src/controller/edit/EditLink.jsx +++ b/apps/presentationeditor/mobile/src/controller/edit/EditLink.jsx @@ -188,7 +188,7 @@ class EditLinkController extends Component { return ( !this.props.isNavigate ? Device.phone ? - this.props.onClosed('edit-link')}> + this.props.closeOptions('edit-link')}> : - this.props.onClosed('edit-link')}> + this.props.closeOptions('edit-link')}> - {!this.state.previewVisible ? null : } + {!this.state.previewVisible ? null : + + } {/* Top Navbar */} @@ -175,21 +177,17 @@ class MainPage extends Component { - { - !this.state.editOptionsVisible ? null : - + {!this.state.editOptionsVisible ? null : } + {!this.state.addOptionsVisible ? null : } + {!this.state.addLinkSettingsVisible ? null : + } - { - !this.state.addOptionsVisible ? null : - - } - { - !this.state.addLinkSettingsVisible ? null : - - } - { - !this.state.editLinkSettingsVisible ? null : - + {!this.state.editLinkSettingsVisible ? null : + } {!this.state.settingsVisible ? null : } {!this.state.collaborationVisible ? null : @@ -198,7 +196,9 @@ class MainPage extends Component { /> } {appOptions.isDocReady && - + } diff --git a/apps/presentationeditor/mobile/src/view/add/Add.jsx b/apps/presentationeditor/mobile/src/view/add/Add.jsx index b1aecb4f19..6798b68744 100644 --- a/apps/presentationeditor/mobile/src/view/add/Add.jsx +++ b/apps/presentationeditor/mobile/src/view/add/Add.jsx @@ -1,22 +1,21 @@ -import React, {Component, useEffect} from 'react'; -import {View,Page,Navbar,NavRight, NavTitle, Link,Popup,Popover,Icon,Tabs,Tab} from 'framework7-react'; -import { useTranslation } from 'react-i18next'; -import {f7} from 'framework7-react'; -import { observer, inject } from "mobx-react"; -import {Device} from '../../../../../common/mobile/utils/device'; - -import AddSlideController from "../../controller/add/AddSlide"; -import AddShapeController from "../../controller/add/AddShape"; -import {AddImageController} from "../../controller/add/AddImage"; -import {PageImageLinkSettings} from "./AddImage"; -import {AddOtherController} from "../../controller/add/AddOther"; -import {PageAddTable} from "./AddOther"; -import {AddLinkController} from "../../controller/add/AddLink"; +import React, { useContext, useEffect } from 'react'; +import { View, Popup, Popover, f7 } from 'framework7-react'; +import { Device } from '../../../../../common/mobile/utils/device'; +import { AddImageController } from "../../controller/add/AddImage"; +import { PageImageLinkSettings } from "./AddImage"; +import { PageAddTable } from "./AddOther"; +import { AddLinkController } from "../../controller/add/AddLink"; import { PageTypeLink, PageLinkTo } from "./AddLink"; import { EditLinkController } from '../../controller/edit/EditLink'; import { PageEditTypeLink, PageEditLinkTo } from '../../view/edit/EditLink'; +import AddingPage from './AddingPage'; +import { MainContext } from '../../page/main'; const routes = [ + { + path: '/adding-page/', + component: AddingPage + }, // Image { path: '/add-image-from-url/', @@ -68,138 +67,30 @@ routes.forEach(route => { }; }); -const AddLayoutNavbar = ({ tabs, inPopover }) => { - const isAndroid = Device.android; - return ( - - {tabs.length > 1 ? -
- {tabs.map((item, index) => - - - )} - {isAndroid && } -
: - {tabs[0].caption} - } - { !inPopover && } -
- ) -}; +const AddView = () => { + const mainContext = useContext(MainContext); -const AddLayoutContent = ({ tabs }) => { - return ( - - {tabs.map((item, index) => - - {item.component} - - )} - - ) -}; - -const AddTabs = props => { - const { t } = useTranslation(); - const _t = t('View.Add', {returnObjects: true}); - const api = Common.EditorApi.get(); - const countPages = api.getCountPages(); - const showPanels = props.showPanels; - const tabs = []; - if (!showPanels && countPages) { - tabs.push({ - caption: _t.textSlide, - id: 'add-slide', - icon: 'icon-add-slide', - component: - }); - tabs.push({ - caption: _t.textShape, - id: 'add-shape', - icon: 'icon-add-shape', - component: - }); - - // tabs.push({ - // caption: _t.textImage, - // id: 'add-image', - // icon: 'icon-add-image', - // component: - // }); - - tabs.push({ - caption: _t.textOther, - id: 'add-other', - icon: 'icon-add-other', - component: - }); - } - if(!showPanels && !countPages) { - tabs.push({ - caption: _t.textSlide, - id: 'add-slide', - icon: 'icon-add-slide', - component: - }); - } - - // if (showPanels && showPanels === 'link') { - // tabs.push({ - // caption: _t.textAddLink, - // id: 'add-link', - // component: - // }); - // } + useEffect(() => { + if(Device.phone) { + f7.popup.open('.add-popup'); + } else { + f7.popover.open('#add-popover', '#btn-add'); + } + }, []); return ( - - - - - - + !Device.phone ? + mainContext.closeOptions('add')}> + + + + : + mainContext.closeOptions('add')}> + + + + ) -}; - -class AddView extends Component { - constructor(props) { - super(props); - - this.onoptionclick = this.onoptionclick.bind(this); - } - onoptionclick(page){ - f7.views.current.router.navigate(page); - } - render() { - const show_popover = this.props.usePopover; - return ( - show_popover ? - this.props.onclosed()}> - - : - this.props.onclosed()}> - - - ) - } } -const Add = props => { - useEffect(() => { - if ( Device.phone ) - f7.popup.open('.add-popup'); - else f7.popover.open('#add-popover', '#btn-add'); - - return () => { - // component will unmount - } - }); - const onviewclosed = () => { - if ( props.onclosed ) { - props.onclosed(); - } - }; - return -}; - -export default Add; \ No newline at end of file +export default AddView; \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/view/add/AddingPage.jsx b/apps/presentationeditor/mobile/src/view/add/AddingPage.jsx new file mode 100644 index 0000000000..27215a97db --- /dev/null +++ b/apps/presentationeditor/mobile/src/view/add/AddingPage.jsx @@ -0,0 +1,110 @@ +import React, { useContext, useEffect } from 'react'; +import { Page, Navbar, NavRight, NavTitle, Link, Icon, Tabs, Tab, f7 } from 'framework7-react'; +import { useTranslation } from 'react-i18next'; +import { Device } from '../../../../../common/mobile/utils/device'; +import AddSlideController from "../../controller/add/AddSlide"; +import AddShapeController from "../../controller/add/AddShape"; +import { AddOtherController } from "../../controller/add/AddOther"; +import { MainContext } from '../../page/main'; + +const AddLayoutNavbar = ({ tabs }) => { + const isAndroid = Device.android; + + return ( + + {tabs.length > 1 ? +
+ {tabs.map((item, index) => + + + )} + {isAndroid && } +
: + {tabs[0].caption} + } + {Device.phone && } +
+ ) +}; + +const AddLayoutContent = ({ tabs }) => { + return ( + + {tabs.map((item, index) => + + {item.component} + + )} + + ) +}; + +const AddingPage = () => { + const { t } = useTranslation(); + const _t = t('View.Add', {returnObjects: true}); + const api = Common.EditorApi.get(); + const countPages = api.getCountPages(); + const mainContext = useContext(MainContext); + const showPanels = mainContext.showPanels; + const tabs = []; + + useEffect(() => { + f7.tab.show('#add-other', false); + }, []); + + if (!showPanels && countPages) { + tabs.push({ + caption: _t.textSlide, + id: 'add-slide', + icon: 'icon-add-slide', + component: + }); + + tabs.push({ + caption: _t.textShape, + id: 'add-shape', + icon: 'icon-add-shape', + component: + }); + + // tabs.push({ + // caption: _t.textImage, + // id: 'add-image', + // icon: 'icon-add-image', + // component: + // }); + + tabs.push({ + caption: _t.textOther, + id: 'add-other', + icon: 'icon-add-other', + component: + }); + } + + if(!showPanels && !countPages) { + tabs.push({ + caption: _t.textSlide, + id: 'add-slide', + icon: 'icon-add-slide', + component: + }); + } + + // if (showPanels && showPanels === 'link') { + // tabs.push({ + // caption: _t.textAddLink, + // id: 'add-link', + // component: + // }); + // } + + return ( + + + + + ) +}; + +export default AddingPage; \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/view/edit/Edit.jsx b/apps/presentationeditor/mobile/src/view/edit/Edit.jsx index f57aad6bf1..ae3b8acc83 100644 --- a/apps/presentationeditor/mobile/src/view/edit/Edit.jsx +++ b/apps/presentationeditor/mobile/src/view/edit/Edit.jsx @@ -1,29 +1,24 @@ -import React, {useState, useEffect} from 'react'; -import {observer, inject} from "mobx-react"; -import { Popover, Sheet, View, Page, Navbar, NavRight, NavLeft, NavTitle, Tabs, Tab, Link } from 'framework7-react'; -import { f7 } from 'framework7-react'; -import { useTranslation } from 'react-i18next'; -import {Device} from '../../../../../common/mobile/utils/device'; - -import EditSlideController from "../../controller/edit/EditSlide"; -import EditTextController from "../../controller/edit/EditText"; -import EditShapeController from "../../controller/edit/EditShape"; -import EditImageController from "../../controller/edit/EditImage"; -import EditTableController from "../../controller/edit/EditTable"; -import EditChartController from "../../controller/edit/EditChart"; +import React, { useContext, useEffect } from 'react'; +import { Popover, Sheet, View, f7 } from 'framework7-react'; +import { Device } from '../../../../../common/mobile/utils/device'; import { EditLinkController } from "../../controller/edit/EditLink"; - import { Theme, Layout, Transition, Type, Effect, StyleFillColor, CustomFillColor } from './EditSlide'; import { PageTextFonts, PageTextFontColor, PageTextHighlightColor, PageTextCustomFontColor, PageTextAddFormatting, PageTextBulletsAndNumbers, PageTextLineSpacing, PageTextBulletsLinkSettings } from './EditText'; import { PageShapeStyle, PageShapeStyleNoFill, PageReplaceContainer, PageReorderContainer, PageAlignContainer, PageShapeBorderColor, PageShapeCustomBorderColor, PageShapeCustomFillColor } from './EditShape'; import { PageImageReplace, PageImageReorder, PageImageAlign, PageLinkSettings } from './EditImage'; import { PageTableStyle, PageTableStyleOptions, PageTableCustomFillColor, PageTableBorderColor, PageTableCustomBorderColor, PageTableReorder, PageTableAlign } from './EditTable'; import { PageChartDesign, PageChartDesignType, PageChartDesignStyle, PageChartDesignFill, PageChartDesignBorder, PageChartCustomFillColor, PageChartBorderColor, PageChartCustomBorderColor, PageChartReorder, PageChartAlign } from './EditChart' +import EditingPage from './EditingPage'; +import { MainContext } from '../../page/main'; const routes = [ + { + path: '/editing-page/', + component: EditingPage, + keepAlive: true + }, // Slides - { path: '/layout/', component: Layout @@ -232,162 +227,30 @@ routes.forEach(route => { }; }); -const EmptyEditLayout = () => { - const { t } = useTranslation(); - const _t = t('View.Edit', {returnObjects: true}); - return ( - -
-
-

{_t.textSelectObjectToEdit}

-
-
-
- ) -}; +const EditView = () => { + const mainContext = useContext(MainContext); -const EditLayoutNavbar = ({ editors, inPopover }) => { - const isAndroid = Device.android; - return ( - - { - editors.length > 1 ? -
- {editors.map((item, index) => {item.caption})} - {isAndroid && } -
: - { editors[0].caption } - } - { !inPopover && } -
- ) -}; - -const EditLayoutContent = ({ editors }) => { - if (editors.length > 1) { - return ( - - {editors.map((item, index) => - - {item.component} - - )} - - ) - } else { - return ( - - {editors[0].component} - - ) - } -}; - -const EditTabs = props => { - const { t } = useTranslation(); - const _t = t('View.Edit', {returnObjects: true}); - - const settings = props.storeFocusObjects.settings; - - let editors = []; - if (settings.length < 1) { - editors.push({ - caption: _t.textSettings, - component: - }); - } else { - if (settings.indexOf('image') > -1) { - editors.push({ - caption: _t.textImage, - id: 'edit-image', - component: - }) + useEffect(() => { + if(Device.phone) { + f7.sheet.open('#edit-sheet'); + } else { + f7.popover.open('#edit-popover', '#btn-edit'); } - if (settings.indexOf('shape') > -1) { - editors.push({ - caption: _t.textShape, - id: 'edit-shape', - component: - }) - } - if (settings.indexOf('table') > -1) { - editors.push({ - caption: _t.textTable, - id: 'edit-table', - component: - }) - } - if (settings.indexOf('chart') > -1) { - editors.push({ - caption: _t.textChart, - id: 'edit-chart', - component: - }) - } - if (settings.indexOf('text') > -1) { - editors.push({ - caption: _t.textText, - id: 'edit-text', - component: - }) - } - if (settings.indexOf('slide') > -1) { - editors.push({ - caption: _t.textSlide, - id: 'edit-slide', - component: - }) - } - } + }, []); return ( - - - - - - - ) -}; - -const EditTabsContainer = inject("storeFocusObjects")(observer(EditTabs)); - -const EditView = props => { - const onOptionClick = (page) => { - $f7.views.current.router.navigate(page); - }; - const show_popover = props.usePopover; - return ( - show_popover ? - props.onClosed()}> - + !Device.phone ? + mainContext.closeOptions('edit')}> + + + : - props.onClosed()}> - + mainContext.closeOptions('edit')}> + + + ) }; -const EditOptions = props => { - useEffect(() => { - if ( Device.phone ) - f7.sheet.open('#edit-sheet'); - else f7.popover.open('#edit-popover', '#btn-edit'); - - return () => { - // component will unmount - } - }); - - const onviewclosed = () => { - if ( props.onclosed ) { - props.onclosed(); - } - }; - - return ( - - ) -}; - -export default EditOptions; \ No newline at end of file +export default EditView; \ No newline at end of file diff --git a/apps/presentationeditor/mobile/src/view/edit/EditingPage.jsx b/apps/presentationeditor/mobile/src/view/edit/EditingPage.jsx new file mode 100644 index 0000000000..7449624b67 --- /dev/null +++ b/apps/presentationeditor/mobile/src/view/edit/EditingPage.jsx @@ -0,0 +1,134 @@ +import React from 'react'; +import { observer, inject } from "mobx-react"; +import { Page, Navbar, NavRight, NavTitle, Tabs, Tab, Link } from 'framework7-react'; +import { useTranslation } from 'react-i18next'; +import { Device } from '../../../../../common/mobile/utils/device'; +import EditSlideController from "../../controller/edit/EditSlide"; +import EditTextController from "../../controller/edit/EditText"; +import EditShapeController from "../../controller/edit/EditShape"; +import EditImageController from "../../controller/edit/EditImage"; +import EditTableController from "../../controller/edit/EditTable"; +import EditChartController from "../../controller/edit/EditChart"; + +const EmptyEditLayout = () => { + const { t } = useTranslation(); + const _t = t('View.Edit', {returnObjects: true}); + + return ( + +
+
+

{_t.textSelectObjectToEdit}

+
+
+
+ ) +}; + +const EditLayoutNavbar = ({ editors }) => { + const isAndroid = Device.android; + + return ( + + {editors.length > 1 ? +
+ {editors.map((item, index) => {item.caption})} + {isAndroid && } +
: + { editors[0].caption } + } + {Device.phone && } +
+ ) +}; + +const EditLayoutContent = ({ editors }) => { + if (editors.length > 1) { + return ( + + {editors.map((item, index) => + + {item.component} + + )} + + ) + } else { + return ( + + {editors[0].component} + + ) + } +}; + +const EditingPage = inject('storeFocusObjects')(observer(props => { + const { t } = useTranslation(); + const _t = t('View.Edit', {returnObjects: true}); + const settings = props.storeFocusObjects.settings; + let editors = []; + + if (settings.length < 1) { + editors.push({ + caption: _t.textSettings, + component: + }); + } else { + if (settings.indexOf('image') > -1) { + editors.push({ + caption: _t.textImage, + id: 'edit-image', + component: + }) + } + + if (settings.indexOf('shape') > -1) { + editors.push({ + caption: _t.textShape, + id: 'edit-shape', + component: + }) + } + + if (settings.indexOf('table') > -1) { + editors.push({ + caption: _t.textTable, + id: 'edit-table', + component: + }) + } + + if (settings.indexOf('chart') > -1) { + editors.push({ + caption: _t.textChart, + id: 'edit-chart', + component: + }) + } + + if (settings.indexOf('text') > -1) { + editors.push({ + caption: _t.textText, + id: 'edit-text', + component: + }) + } + + if (settings.indexOf('slide') > -1) { + editors.push({ + caption: _t.textSlide, + id: 'edit-slide', + component: + }) + } + } + + return ( + + + + + ) +})); + +export default EditingPage; \ No newline at end of file