[DE mobile] Refactoring fonts list

This commit is contained in:
Julia Radzhabova 2022-05-24 20:12:00 +03:00
parent bf0b45cef9
commit c6437146a7

View file

@ -46,11 +46,15 @@ const PageFonts = props => {
const renderExternal = (vl, vlData) => { const renderExternal = (vl, vlData) => {
setVlFonts((prevState) => { setVlFonts((prevState) => {
let fonts = [...prevState.vlData.items]; let fonts = [...prevState.vlData.items],
fonts.splice(vlData.fromIndex, vlData.toIndex, ...vlData.items); drawFonts = [...vlData.items];
let images = getImageUri(fonts);
let images = [],
drawImages = getImageUri(drawFonts);
for (let i = 0; i < drawFonts.length; i++) {
fonts[i + vlData.fromIndex] = drawFonts[i];
images[i + vlData.fromIndex] = drawImages[i];
}
return {vlData: { return {vlData: {
items: fonts, items: fonts,
images, images,
@ -104,13 +108,13 @@ const PageFonts = props => {
}}> }}>
<ul> <ul>
{vlFonts.vlData.items.map((item, index) => ( {vlFonts.vlData.items.map((item, index) => (
<ListItem className="font-item" key={index} radio checked={curFontName === item.name} onClick={() => { <ListItem className="font-item" key={index} radio checked={curFontName === (item || fonts[index]).name} onClick={() => {
storeTextSettings.changeFontFamily(item.name); storeTextSettings.changeFontFamily((item || fonts[index]).name);
props.changeFontFamily(item.name); props.changeFontFamily((item || fonts[index]).name);
storeTextSettings.addFontToRecent(item); storeTextSettings.addFontToRecent((item || fonts[index]));
addRecentStorage(); addRecentStorage();
}}> }}>
<img src={vlFonts.vlData.images[index]} style={{width: `${iconWidth}px`, height: `${iconHeight}px`}} /> {vlFonts.vlData.images[index] && <img src={vlFonts.vlData.images[index]} style={{width: `${iconWidth}px`, height: `${iconHeight}px`}} />}
</ListItem> </ListItem>
))} ))}
</ul> </ul>