diff --git a/script_library/index.json b/script_library/index.json index 4d8272f..7bf5d4c 100644 --- a/script_library/index.json +++ b/script_library/index.json @@ -1,7 +1,7 @@ { "format_version": 1, - "data_version": 7, - "updated": "2026-03-18T16:39:32Z", + "data_version": 8, + "updated": "2026-03-18T16:49:17.705Z", "announcement": null, "categories": [ { @@ -357,6 +357,29 @@ "updated": null, "status": "active", "lines": 560 + }, + { + "id": "script_mmwa0ets", + "name": "习惯追踪器", + "name_en": "习惯追踪器", + "desc": "习惯追踪器", + "desc_en": "习惯追踪器", + "category": "widgets", + "file": "scripts/widgets/script_mmwa0ets.py", + "thumbnail": null, + "version": 1, + "file_type": "py", + "author": "今晚打老虎🐯", + "author_en": "今晚打老虎🐯", + "tags": [ + "community" + ], + "requires": [], + "min_app_version": "1.5.0", + "added": "2026-03-18", + "updated": null, + "status": "active", + "lines": 95 } ] } diff --git a/script_library/scripts/widgets/script_mmwa0ets.py b/script_library/scripts/widgets/script_mmwa0ets.py new file mode 100644 index 0000000..ca26ce2 --- /dev/null +++ b/script_library/scripts/widgets/script_mmwa0ets.py @@ -0,0 +1,94 @@ +# -*- coding: utf-8 -*- +"""习惯追踪器 — 7 habits, streak, progress ring.""" + +from widget import Widget, family, SMALL, MEDIUM, LARGE +import time, random + +habits = [ + ("💧", "喝水", True), + ("📖", "阅读", True), + ("🏃", "运动", False), + ("🧘", "冥想", True), + ("🍎", "水果", True), + ("😴", "早睡", False), + ("📝", "日记", True), +] + +done = sum(1 for *_, ok in habits if ok) +total = len(habits) +streak = 12 + +bg = {"gradient": ["#6366F1", "#8B5CF6"], "direction": "diagonal"} +card_bg = ("#FFFFFF", "#1E1B4B") +txt_main = ("#1E1B4B", "#E0E7FF") +txt_sub = ("#6366F1", "#A5B4FC") +done_clr = ("#22C55E", "#4ADE80") +miss_clr = ("#E5E7EB", "#312E81") + +w = Widget(background=bg, padding=12) + +if family in (SMALL, "small"): + with w.vstack(spacing=6): + with w.hstack(spacing=6, align="center"): + w.icon("checkmark.circle.fill", size=16, color="#A5B4FC") + w.text("习惯", size=15, weight="bold", color="#FFFFFF") + w.spacer() + w.text(f"🔥{streak}天", size=12, color="#FDE68A") + w.gauge(done, total, label="", size=54, color="#34D399", + track_color=("#C7D2FE", "#312E81"), line_width=6) + w.text(f"{done}/{total} 已完成", size=12, weight="medium", + color="#E0E7FF", align="center") + +elif family in (MEDIUM, "medium"): + with w.hstack(spacing=10): + with w.vstack(spacing=4, padding=4): + with w.hstack(spacing=4, align="center"): + w.icon("checkmark.circle.fill", size=14, color="#A5B4FC") + w.text("习惯追踪", size=14, weight="bold", color="#FFFFFF") + w.spacer() + w.gauge(done, total, label="", size=56, color="#34D399", + track_color=("#C7D2FE", "#312E81"), line_width=6) + w.text(f"{done}/{total}", size=11, color="#E0E7FF", align="center") + with w.vstack(spacing=3): + with w.hstack(spacing=4, align="center"): + w.text(f"🔥 连续 {streak} 天", size=11, weight="semibold", + color="#FDE68A") + w.spacer() + for emoji, name, ok in habits: + with w.hstack(spacing=4, align="center"): + w.text(emoji, size=12) + w.text(name, size=11, color="#E0E7FF") + w.spacer() + w.icon("checkmark.circle.fill" if ok else "circle", + size=13, + color="#4ADE80" if ok else "#6366F1") + +else: + with w.vstack(spacing=6): + with w.hstack(spacing=6, align="center"): + w.icon("checkmark.circle.fill", size=18, color="#A5B4FC") + w.text("习惯追踪器", size=17, weight="bold", color="#FFFFFF") + w.spacer() + w.text(f"🔥 连续 {streak} 天", size=13, weight="semibold", + color="#FDE68A") + w.divider(color="#818CF8") + with w.hstack(spacing=8, align="center"): + w.gauge(done, total, label="", size=64, color="#34D399", + track_color=("#C7D2FE", "#312E81"), line_width=7) + with w.vstack(spacing=2): + w.text(f"{done}/{total} 已完成", size=13, weight="semibold", + color="#E0E7FF") + pct = int(done / total * 100) + w.progress(done, total, color="#34D399", height=6, + track_color=("#C7D2FE", "#312E81")) + w.text(f"完成率 {pct}%", size=11, color="#A5B4FC") + w.divider(color="#818CF8") + with w.hstack(spacing=6): + for emoji, name, ok in habits: + with w.vstack(spacing=2, align="center"): + w.text(emoji, size=18) + w.icon("checkmark.circle.fill" if ok else "circle", + size=14, + color="#4ADE80" if ok else "#6366F1") + +w.render()