[SSE mobile] Corrected highlighting tabs

This commit is contained in:
SergeyEzhin 2021-03-30 15:17:24 +03:00
parent 3f8e1390be
commit fe684e0edb
3 changed files with 70 additions and 48 deletions

View file

@ -10,7 +10,6 @@ const Statusbar = inject('sheets', 'storeAppOptions', 'users')(props => {
const {sheets, storeAppOptions, users} = props; const {sheets, storeAppOptions, users} = props;
const {t} = useTranslation(); const {t} = useTranslation();
const _t = t('Statusbar', {returnObjects: true}); const _t = t('Statusbar', {returnObjects: true});
// console.log(props);
let isEdit = storeAppOptions.isEdit; let isEdit = storeAppOptions.isEdit;
let isDisconnected = users.isDisconnected; let isDisconnected = users.isDisconnected;
@ -18,7 +17,7 @@ const Statusbar = inject('sheets', 'storeAppOptions', 'users')(props => {
useEffect(() => { useEffect(() => {
const onDocumentReady = () => { const onDocumentReady = () => {
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
api.asc_registerCallback('asc_onUpdateTabColor', onApiUpdateTabColor); // api.asc_registerCallback('asc_onUpdateTabColor', onApiUpdateTabColor);
api.asc_registerCallback('asc_onWorkbookLocked', onWorkbookLocked); api.asc_registerCallback('asc_onWorkbookLocked', onWorkbookLocked);
api.asc_registerCallback('asc_onWorksheetLocked', onWorksheetLocked); api.asc_registerCallback('asc_onWorksheetLocked', onWorksheetLocked);
api.asc_registerCallback('asc_onSheetsChanged', onApiSheetsChanged); api.asc_registerCallback('asc_onSheetsChanged', onApiSheetsChanged);
@ -44,7 +43,7 @@ const Statusbar = inject('sheets', 'storeAppOptions', 'users')(props => {
Common.Notifications.off('document:ready', onApiSheetsChanged); Common.Notifications.off('document:ready', onApiSheetsChanged);
const api = Common.EditorApi.get(); const api = Common.EditorApi.get();
api.asc_unregisterCallback('asc_onUpdateTabColor', onApiUpdateTabColor); // api.asc_unregisterCallback('asc_onUpdateTabColor', onApiUpdateTabColor);
api.asc_unregisterCallback('asc_onWorkbookLocked', onWorkbookLocked); api.asc_unregisterCallback('asc_onWorkbookLocked', onWorkbookLocked);
api.asc_unregisterCallback('asc_onWorksheetLocked', onWorksheetLocked); api.asc_unregisterCallback('asc_onWorksheetLocked', onWorksheetLocked);
api.asc_unregisterCallback('asc_onSheetsChanged', onApiSheetsChanged); api.asc_unregisterCallback('asc_onSheetsChanged', onApiSheetsChanged);
@ -63,7 +62,8 @@ const Statusbar = inject('sheets', 'storeAppOptions', 'users')(props => {
}; };
const onWorksheetLocked = (index, locked) => { const onWorksheetLocked = (index, locked) => {
let model = sheets.sheets.find(sheet => sheet.index === index); // let model = sheets.sheets.find(sheet => sheet.index === index);
let model = sheets.at(index);
if(model && model.locked != locked) if(model && model.locked != locked)
model.locked = locked; model.locked = locked;
}; };
@ -87,58 +87,57 @@ const Statusbar = inject('sheets', 'storeAppOptions', 'users')(props => {
color : api.asc_getWorksheetTabColor(i) color : api.asc_getWorksheetTabColor(i)
}; };
// (api.asc_isWorksheetHidden(i) ? hiddentems : items).push(tab);
items.push(tab); items.push(tab);
} }
sheets.resetSheets(items); sheets.resetSheets(items);
updateTabsColors(); // updateTabsColors();
}; };
const loadTabColor = sheetindex => { // const loadTabColor = sheetindex => {
const api = Common.EditorApi.get(); // const api = Common.EditorApi.get();
let tab = sheets.sheets.find(sheet => sheet.index === sheetindex); // let tab = sheets.sheets.find(sheet => sheet.index === sheetindex);
if (tab) { // if (tab) {
setTabLineColor(tab, api.asc_getWorksheetTabColor(sheetindex)); // setTabLineColor(tab, api.asc_getWorksheetTabColor(sheetindex));
} // }
}; // };
const onApiUpdateTabColor = index => { // const onApiUpdateTabColor = index => {
loadTabColor(index); // loadTabColor(index);
}; // };
const setTabLineColor = (tab, color) => { // const setTabLineColor = (tab, color) => {
console.log(tab); // console.log(color);
if (tab) { // if (tab) {
if (null !== color) { // if (null !== color) {
color = '#' + Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()); // color = '#' + Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());
} else { // } else {
color = ''; // color = '';
} // }
if (color.length) { // if (color.length) {
if (!tab.active) { // if (!tab.active) {
color = '0px 4px 0 ' + Common.Utils.RGBColor(color).toRGBA(0.7) + ' inset'; // color = '0px 4px 0 ' + Common.Utils.RGBColor(color).toRGBA(0.7) + ' inset';
} else { // } else {
color = '0px 4px 0 ' + color + ' inset'; // color = '0px 4px 0 ' + color + ' inset';
} // }
$$('.sheet-tabs .tab a').eq(tab.index).css('box-shadow', color); // $$('.sheet-tabs .tab a').eq(tab.index).css('box-shadow', color);
} else { // } else {
$$('.sheet-tabs .tab a').eq(tab.index).css('box-shadow', ''); // $$('.sheet-tabs .tab a').eq(tab.index).css('box-shadow', '');
} // }
} // }
}; // };
const updateTabsColors = () => { // const updateTabsColors = () => {
const api = Common.EditorApi.get(); // const api = Common.EditorApi.get();
sheets.sheets.forEach(model => { // sheets.sheets.forEach(model => {
setTabLineColor(model, api.asc_getWorksheetTabColor(model.index)); // setTabLineColor(model, api.asc_getWorksheetTabColor(model.index));
}); // });
}; // };
const onTabClicked = i => { const onTabClicked = i => {
const model = sheets.at(i); const model = sheets.at(i);
@ -195,7 +194,7 @@ const Statusbar = inject('sheets', 'storeAppOptions', 'users')(props => {
} else { } else {
f7.popover.close('#idx-tab-context-menu-popover', false); f7.popover.close('#idx-tab-context-menu-popover', false);
onTabClicked(i); onTabClicked(i);
Common.Notifications.trigger('sheet:active', index); // Common.Notifications.trigger('sheet:active', index);
} }
}; };
@ -305,7 +304,7 @@ const Statusbar = inject('sheets', 'storeAppOptions', 'users')(props => {
} else { } else {
f7.popover.close('#idx-hidden-sheets-popover'); f7.popover.close('#idx-hidden-sheets-popover');
api['asc_showWorksheet'](index); api['asc_showWorksheet'](index);
loadTabColor(index); // loadTabColor(index);
} }
}; };

View file

@ -45,7 +45,7 @@
> li { > li {
a { a {
font-size: 12px; font-size: 12px;
padding: 0 20px 0; padding: 0 10px 0;
line-height: @statusbar-height; line-height: @statusbar-height;
color: @text-normal; color: @text-normal;
height: 100%; height: 100%;

View file

@ -15,7 +15,29 @@ const StatusbarView = inject('sheets')(observer(props => {
const isPhone = Device.isPhone; const isPhone = Device.isPhone;
const { sheets } = props; const { sheets } = props;
const hiddenSheets = sheets.hiddenWorksheets(); const hiddenSheets = sheets.hiddenWorksheets();
const allSheets = sheets.sheets;
const getTabClassList = model => `tab ${model.active ? 'active' : ''} ${model.locked ? 'locked' : ''}`; const getTabClassList = model => `tab ${model.active ? 'active' : ''} ${model.locked ? 'locked' : ''}`;
const getTabColor = model => {
let color = model.color;
if (color) {
color = '#' + Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());
} else {
color = '';
}
if (color.length) {
if (!model.active) {
color = '0px 4px 0 ' + Common.Utils.RGBColor(color).toRGBA(0.7) + ' inset';
} else {
color = '0px 4px 0 ' + color + ' inset';
}
}
return color;
}
// const $boxTabs = $$('.sheet-tabs'); // const $boxTabs = $$('.sheet-tabs');
// const $statusBar = $$('.statusbar'); // const $statusBar = $$('.statusbar');
@ -102,11 +124,12 @@ const StatusbarView = inject('sheets')(observer(props => {
</div> </div>
<div className="statusbar--box-tabs"> <div className="statusbar--box-tabs">
<ul className="sheet-tabs bottom"> <ul className="sheet-tabs bottom">
{sheets.sheets.map((model,i) => {allSheets.map((model,i) =>
model.hidden ? null : model.hidden ? null :
<li className={getTabClassList(model)} key={i} onClick={(e) => props.onTabClick(i, e.target)}> <li className={getTabClassList(model)} key={i} onClick={(e) => props.onTabClick(i, e.target)}>
<a /* onClick={e => props.onTabClicked(i)} */>{model.name}</a> <a style={{boxShadow: getTabColor(model)}}>{model.name}</a>
</li> </li>
)} )}
</ul> </ul>
</div> </div>