irongit

A Neovim plugin enabling you to solve LeetCode problems.

feat: better premium indicator

kawreauthored
parent 323857ecommit e95d37d022367bac74877119d94b88941587d292Browse files

5 files changed, +18 -3

+10-2lua/leetcode-ui/group/similar-questions.lua
@@ -36,8 +36,16 @@ function SimilarQuestions:init(questions)
3636 button:append(fid .. " ", "leetcode_normal")
3737 button:append(utils.translate(p.title, p.title_cn))
3838
39- if not config.auth.is_premium and q.paid_only then
40- button:append((" %s "):format(config.icons.lock) .. t("Premium"), "leetcode_medium")
39+ if q.paid_only then
40+ local txt
41+
42+ if config.auth.is_premium then
43+ txt = " " .. config.icons.unlock
44+ else
45+ txt = (" %s "):format(config.icons.lock) .. t("Premium")
46+ end
47+
48+ button:append(txt, "leetcode_medium")
4149 end
4250
4351 self:insert(button)
+1-0lua/leetcode-ui/lines/footer.lua
@@ -15,6 +15,7 @@ function Footer:contents()
1515 self:endgrp()
1616
1717 self:append(t("Signed in as") .. ": ", "leetcode_alt")
18+ if config.auth.is_premium then self:append(config.icons.star .. " ", "leetcode_medium") end
1819 self:append(config.auth.name):endl()
1920 end
2021
+1-0lua/leetcode-ui/split/description.lua
@@ -119,6 +119,7 @@ function Description:populate()
119119
120120 header:append(q.frontend_id .. ". ", "leetcode_normal")
121121 header:append(utils.translate(q.title, q.translated_title))
122+ if q.is_paid_only then header:append(" " .. t("Premium"), "leetcode_medium") end
122123 header:endgrp()
123124
124125 local show_stats = self.show_stats
+3-0lua/leetcode/config/icons.lua
@@ -3,6 +3,8 @@ local icons = {
33 circle = "",
44 square = "󱓻",
55 lock = "",
6+ unlock = "",
7+ star = "",
68 status = {
79 ac = "",
810 notac = "󱎖",
@@ -17,6 +19,7 @@ icons.hl = {
1719 todo = { icons.status.todo, "leetcode_alt" },
1820 },
1921 lock = { icons.lock, "leetcode_medium" },
22+ unlock = { icons.unlock, "leetcode_medium" },
2023 }
2124
2225 icons.indent = ("\t%s "):format(icons.bar)
+3-1lua/leetcode/pickers/question.lua
@@ -34,7 +34,9 @@ end
3434
3535 ---@param question lc.cache.Question
3636 local function display_user_status(question)
37- if question.paid_only and not config.auth.is_premium then return config.icons.hl.lock end
37+ if question.paid_only then
38+ return config.auth.is_premium and config.icons.hl.unlock or config.icons.hl.lock
39+ end
3840
3941 if question.status == vim.NIL then return { "" } end
4042 return config.icons.hl.status[question.status] or { "" }