A Neovim plugin enabling you to solve LeetCode problems.
feat: better premium indicator
5 files changed, +18 -3
+10-2lua/leetcode-ui/group/similar-questions.lua
| @@ -36,8 +36,16 @@ function SimilarQuestions:init(questions) | ||
| 36 | 36 | button:append(fid .. " ", "leetcode_normal") |
| 37 | 37 | button:append(utils.translate(p.title, p.title_cn)) |
| 38 | 38 | |
| 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") | |
| 41 | 49 | end |
| 42 | 50 | |
| 43 | 51 | self:insert(button) |
+1-0lua/leetcode-ui/split/description.lua
| @@ -119,6 +119,7 @@ function Description:populate() | ||
| 119 | 119 | |
| 120 | 120 | header:append(q.frontend_id .. ". ", "leetcode_normal") |
| 121 | 121 | header:append(utils.translate(q.title, q.translated_title)) |
| 122 | + if q.is_paid_only then header:append(" " .. t("Premium"), "leetcode_medium") end | |
| 122 | 123 | header:endgrp() |
| 123 | 124 | |
| 124 | 125 | local show_stats = self.show_stats |
+3-0lua/leetcode/config/icons.lua
| @@ -3,6 +3,8 @@ local icons = { | ||
| 3 | 3 | circle = "", |
| 4 | 4 | square = "", |
| 5 | 5 | lock = "", |
| 6 | + unlock = "", | |
| 7 | + star = "", | |
| 6 | 8 | status = { |
| 7 | 9 | ac = "", |
| 8 | 10 | notac = "", |
| @@ -17,6 +19,7 @@ icons.hl = { | ||
| 17 | 19 | todo = { icons.status.todo, "leetcode_alt" }, |
| 18 | 20 | }, |
| 19 | 21 | lock = { icons.lock, "leetcode_medium" }, |
| 22 | + unlock = { icons.unlock, "leetcode_medium" }, | |
| 20 | 23 | } |
| 21 | 24 | |
| 22 | 25 | icons.indent = ("\t%s "):format(icons.bar) |
+3-1lua/leetcode/pickers/question.lua
| @@ -34,7 +34,9 @@ end | ||
| 34 | 34 | |
| 35 | 35 | ---@param question lc.cache.Question |
| 36 | 36 | 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 | |
| 38 | 40 | |
| 39 | 41 | if question.status == vim.NIL then return { "" } end |
| 40 | 42 | return config.icons.hl.status[question.status] or { "" } |