From d8d040733be9a2e1b8e46c1d65da19e6b4be0d79 Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Mon, 28 Dec 2020 23:05:32 +0300 Subject: [PATCH] [DE mobile] Added font color page, custom font color page into text settings --- apps/documenteditor/mobile/locale/en.json | 3 +- .../mobile/src/controller/edit/EditText.jsx | 6 ++ .../mobile/src/store/textSettings.js | 7 +- .../mobile/src/view/edit/Edit.jsx | 18 ++-- .../mobile/src/view/edit/EditText.jsx | 84 +++++++++++++------ 5 files changed, 84 insertions(+), 34 deletions(-) diff --git a/apps/documenteditor/mobile/locale/en.json b/apps/documenteditor/mobile/locale/en.json index 84cf4e0c4..82355eea9 100644 --- a/apps/documenteditor/mobile/locale/en.json +++ b/apps/documenteditor/mobile/locale/en.json @@ -174,7 +174,8 @@ "textStartAt": "Start at", "textFontColors": "Font Colors", "textAutomatic": "Automatic", - "textAddCustomColor": "Add Custom Color" + "textAddCustomColor": "Add Custom Color", + "textCustomColor": "Custom Color" }, "Add": { "textTable": "Table", diff --git a/apps/documenteditor/mobile/src/controller/edit/EditText.jsx b/apps/documenteditor/mobile/src/controller/edit/EditText.jsx index a86f5cdcb..12f544509 100644 --- a/apps/documenteditor/mobile/src/controller/edit/EditText.jsx +++ b/apps/documenteditor/mobile/src/controller/edit/EditText.jsx @@ -40,6 +40,11 @@ class EditTextController extends Component { api.put_TextColor(color); } + onTextColor(color) { + const api = Common.EditorApi.get(); + api.put_TextColor(Common.Utils.ThemeColor.getRgbColor(color)); + } + toggleBold(value) { const api = Common.EditorApi.get(); if (api) { @@ -182,6 +187,7 @@ class EditTextController extends Component { { const isAndroid = Device.android; @@ -210,32 +210,62 @@ const PageLineSpacing = props => { ) }; +const PageCustomFontColor = props => { + const { t } = useTranslation(); + const _t = t('Edit', {returnObjects: true}); + const store = props.storeTextSettings; + let textColor = store.textColor; + if (typeof textColor === 'object') { + textColor = textColor.color; + } + const onAddNewColor = (colors, color) => { + props.storeTextSettings.changeCustomTextColors(colors); + props.onTextColor(color); + props.f7router.back(); + }; + return( + + + + + ) +}; + const PageFontColor = props => { const { t } = useTranslation(); const _t = t('Edit', {returnObjects: true}); - const [stateColor, setColor] = useState(); - const changeCurColor = (color) => { - setColor(color); - }; - const onAddCustomColor = () => { - console.log('add custom color'); + const store = props.storeTextSettings; + const textColor = store.textColor; + const customColors = store.customTextColors; + const changeColor = (color, effectId) => { + if (color !== 'empty') { + if (effectId !==undefined ) { + props.onTextColor({color: color, effectId: effectId}); + } else { + props.onTextColor(color); + } + } else { + // open custom color menu + props.f7router.navigate('/edit-text-custom-font-color/'); + } }; return( - { + { props.onTextColorAuto(); - setColor('auto'); }}>
- + - {onAddCustomColor()}}> +
) @@ -269,7 +299,8 @@ const EditText = props => { {!isAndroid && } @@ -334,18 +365,21 @@ const EditText = props => { }; const EditTextContainer = inject("storeTextSettings", "storeFocusObjects")(observer(EditText)); -const PageFontsContainer = inject("storeTextSettings", "storeFocusObjects")(observer(PageFonts)); -const PageAddFormattingContainer = inject("storeTextSettings", "storeFocusObjects")(observer(PageAdditionalFormatting)); -const PageBulletsContainer = inject("storeTextSettings")(observer(PageBullets)); -const PageNumbersContainer = inject("storeTextSettings")(observer(PageNumbers)); -const PageLineSpacingContainer = inject("storeTextSettings")(observer(PageLineSpacing)); +const PageTextFonts = inject("storeTextSettings", "storeFocusObjects")(observer(PageFonts)); +const PageTextAddFormatting = inject("storeTextSettings", "storeFocusObjects")(observer(PageAdditionalFormatting)); +const PageTextBullets = inject("storeTextSettings")(observer(PageBullets)); +const PageTextNumbers = inject("storeTextSettings")(observer(PageNumbers)); +const PageTextLineSpacing = inject("storeTextSettings")(observer(PageLineSpacing)); +const PageTextFontColor = inject("storeTextSettings")(observer(PageFontColor)); +const PageTextCustomFontColor = inject("storeTextSettings")(observer(PageCustomFontColor)); export { EditTextContainer as EditText, - PageFontsContainer as PageFonts, - PageAddFormattingContainer as PageAdditionalFormatting, - PageBulletsContainer as PageBullets, - PageNumbersContainer as PageNumbers, - PageLineSpacingContainer as PageLineSpacing, - PageFontColor + PageTextFonts, + PageTextAddFormatting, + PageTextBullets, + PageTextNumbers, + PageTextLineSpacing, + PageTextFontColor, + PageTextCustomFontColor }; \ No newline at end of file