Skip to content

Commit

Permalink
MD Icons вместо emoji в выписке
Browse files Browse the repository at this point in the history
  • Loading branch information
Sominemo committed Apr 23, 2020
1 parent 8c712a4 commit 38a91e2
Show file tree
Hide file tree
Showing 20 changed files with 507 additions and 65 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mono-pwa",
"version": "4.0.0-dev.4",
"version": "4.0.0-dev.5",
"description": "monobank PWA",
"main": "index.html",
"config": {
Expand All @@ -12,6 +12,7 @@
"build": "webpack --config webpack/webpack.config.js --env.PRODUCTION --env.ANALYTICS",
"build-debug": "webpack --config webpack/webpack.config.js --env.PRODUCTION --env.ANALYTICS --env.DEBUG",
"ci": "webpack --config webpack/webpack.config.js --env.CI",
"update-emojis": "node webpack/scripts/updateEmojis",
"test": "echo \"No tests specified\""
},
"repository": "git+https://github.com/SominemoMono-PWA.git",
Expand Down
11 changes: 0 additions & 11 deletions run.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/app/debug/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Nav } from "@Environment/Library/DOM/buildBlock"
import Navigation from "@Core/Services/navigation"
import WindowManager from "@Core/Services/SimpleWindowManager"
import Design from "@Core/Services/design"
import Report from "@Core/Services/reportOld"
import Report from "@Core/Services/Report/Report"
import DBTool from "@Core/Tools/db/DBTool"
import DBUserPresence from "@Core/Services/DBUserPresence"
import SettingsStorage from "@Core/Services/Settings/SettingsStorage"
Expand Down
8 changes: 8 additions & 0 deletions src/app/loaders/SettingsDefaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ CoreLoader.registerTask({
onupdate(a) { MoneyPrintConfig.showMinorPart = a },
},
},
{
name: "enable_tab_navigation",
rule: {
default: false,
checker: new FieldChecker({ type: "boolean" }),
onfail: async (a, b, c) => { await c(!!a); return true },
},
},
], "flags")

SettingsCheckProvider.setRules([
Expand Down
1 change: 1 addition & 0 deletions src/app/loaders/UI/SettingsLayoutLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ CoreLoader.registerTask({
cursor: "pointer",
display: "flex",
},
class: ["clickable-square"],
}),
)
elements.push(element)
Expand Down
12 changes: 9 additions & 3 deletions src/app/modules/mono/API/classes/MCC.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import mcc from "mcc"
import mccLocal from "@Resources/datasets/MCC-Localize-Dataset/mcc-loc.json"
import icons from "@Resources/datasets/Emoji-To-MD-Icon/dataset"
import { $$ } from "@Core/Services/Language/handler"

const emojiFallback = "\uD83D\uDCB3"

Expand All @@ -13,7 +15,7 @@ export default class MCC {
constructor(code) {
const data = mcc.get(code)

let irsDescription = "Operation"
let irsDescription = $$("statement/operation")
let usdaDescription = ""
let combinedDescription = ""
let editedDescription = ""
Expand All @@ -31,8 +33,10 @@ export default class MCC {

const textCode = String(code).padStart(4, "0")
const locMccData = mccLocal[textCode]
if (locMccData.uk && locMccData.uk.length > 0) this.ukTitle = locMccData.uk
if (locMccData.ru && locMccData.ru.length > 0) this.ruTitle = locMccData.ru
if (locMccData) {
if (locMccData.uk && locMccData.uk.length > 0) this.ukTitle = locMccData.uk
if (locMccData.ru && locMccData.ru.length > 0) this.ruTitle = locMccData.ru
}

this.id = id
this.code = code
Expand All @@ -43,5 +47,7 @@ export default class MCC {
} catch (e) {
this.emoji = emojiFallback
}

this.md = icons[this.emoji] || icons[emojiFallback]
}
}
27 changes: 26 additions & 1 deletion src/app/modules/mono/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import WindowManager from "@Core/Services/SimpleWindowManager"
import Navigation from "@Core/Services/navigation"
import { $$ } from "@Core/Services/Language/handler"
import { CoreLoader } from "@Core/Init/CoreLoader"
import { Title } from "@Environment/Library/DOM/object"
import { Title, Icon } from "@Environment/Library/DOM/object"
import { Card, CardList } from "@Environment/Library/DOM/object/card"
import IconSide from "@Environment/Library/DOM/object/iconSide"
import Tip from "@App/library/Tip"
Expand All @@ -14,6 +14,8 @@ import LanguageCore from "@Core/Services/Language/core"
import SettingsStorage from "@Core/Services/Settings/SettingsStorage"
import Sleep from "@Core/Tools/objects/sleep"
import { ContextMenu } from "@Environment/Library/DOM/elements"
import icons from "@Resources/datasets/Emoji-To-MD-Icon/dataset"
import DOM from "@DOMPath/DOM/Classes/dom"
import Auth from "./services/Auth"
import PWA from "../main/PWA"

Expand Down Expand Up @@ -72,6 +74,29 @@ export default class MenuUI {
}), true),
))

Array.from(Object.values(icons)).forEach((e) => {
w.render(
new DOM({
new: "div",
style: {
display: "inline-flex",
width: "42px",
height: "42px",
minWidth: "42px",
minHeight: "42px",
alignItems: "center",
justifyContent: "center",
margin: "5px",
background: e.color,
borderRadius: "50%",
},
content: [
new Icon(e.icon, { fontSize: "23px" }),
],
}),
)
})

delayAction(async () => {
const lastSeen = await SettingsStorage.getFlag("changelog_seen")
if (lastSeen === lastChangelog.version) return
Expand Down
40 changes: 27 additions & 13 deletions src/app/modules/mono/statementUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import printMoney from "@App/tools/transform/printMoney"
import cubicBeizer from "@DOMPath/Animation/Library/Timing/cubicBeizer"
import { Card } from "@Environment/Library/DOM/object/card"
import {
Preloader, TwoSidesWrapper, Title,
Preloader, TwoSidesWrapper, Title, Icon,
} from "@Environment/Library/DOM/object"
import { Align } from "@Environment/Library/DOM/style"
import LottieAnimation from "@App/library/LottieAnimation"
Expand Down Expand Up @@ -148,27 +148,38 @@ export default class StatementUI {

const descriptionArray = []

if (item.comment) descriptionArray.push(`👋 ${item.comment}`)
descriptionArray.push(
(LanguageCore.language.info.code === "ru" ? item.mcc.ruTitle : item.mcc.ukTitle)
|| item.mcc.title,
)
if (item.comment) descriptionArray.push([new Icon("chat_bubble"), new DOM({ new: "span", content: `${item.comment}` })])
descriptionArray.push([
new DOM({
new: "span",
content: (LanguageCore.language.info.code === "ru" ? item.mcc.ruTitle : item.mcc.ukTitle)
|| item.mcc.title,
}),
])

if (!(item.cashback instanceof NoCashback || item.cashback.amount === 0)) {
if (item.cashback instanceof MoneyCashback) {
if (!item.cashback.object.isZero) descriptionArray.push(`👛 ${(item.cashback.sign === -1 ? "-" : "") + printMoney(item.cashback.object, true)}`)
if (!item.cashback.object.isZero) descriptionArray.push([new Icon("account_balance_wallet"), new DOM({ new: "span", content: `${(item.cashback.sign === -1 ? "-" : "") + printMoney(item.cashback.object, true)}` })])
} else if (item.cashback instanceof MilesCashback) {
descriptionArray.push(`✈ ${item.cashback.amount} mi`)
descriptionArray.push([new Icon("flight"), new DOM({ new: "span", content: `${item.cashback.amount} mi` })])
} else {
descriptionArray.push(`✨ ${item.cashback.amount} ${item.cashback.type}`)
descriptionArray.push([new Icon("assistant"), new DOM({ new: "span", content: `${item.cashback.amount} ${item.cashback.type}` })])
}
}

if (!item.commissionRate.isZero) {
descriptionArray.push(`➖ ${item.commissionRate.string}`)
descriptionArray.push([new Icon("remove_circle"), new DOM({ new: "span", content: `${item.commissionRate.string}` })])
}

const description = descriptionArray.join(" | ")
const description = descriptionArray.reduce(
(r, a, ind) => r.concat(
...[...a,
...(ind + 1 === descriptionArray.length
? []
: [new DOM({ new: "div", content: "|", style: { margin: "0 0.25em" } })]),
],
), [],
)

toRender.push(new DOM({
new: "div",
Expand All @@ -195,7 +206,10 @@ export default class StatementUI {
new DOM({
new: "div",
class: "statement-item-category",
content: item.mcc.emoji,
content: new Icon(item.mcc.md.icon),
style: {
background: item.mcc.md.color,
},
}),
new DOM({
new: "div",
Expand Down Expand Up @@ -223,7 +237,7 @@ export default class StatementUI {
),
}))
} catch (e) {
Report.error("Failed to render statement item", JSON.parse(JSON.stringify(item)))
Report.error("Failed to render statement item", e, JSON.parse(JSON.stringify(item)))
}
})

Expand Down
Loading

0 comments on commit 38a91e2

Please sign in to comment.