@showlotus/open-scriptable 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/count-down.js +1 -1
- package/package.json +1 -1
package/dist/count-down.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let t;t=config.runsInWidget?config.widgetFamily||"small":"large";const o={small:3,medium:3,large:7}[t];const e=new ListWidget;e.useDefaultPadding(),e.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c")),e.spacing=8;const n=Object.entries(
|
|
1
|
+
let t;t=config.runsInWidget?config.widgetFamily||"small":"large";const o={small:3,medium:3,large:7}[t];const e=new ListWidget;e.useDefaultPadding(),e.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c")),e.spacing=8;const n=Object.entries(__GLOBAL_CONFIG__.days||{}).map(([t,o])=>({name:t,date:o})).sort((t,o)=>t.date>o.date?1:-1).filter(t=>{const[o,e,n]=t.date.split("-").map(Number),a=new Date;return o>a.getFullYear()||o===a.getFullYear()&&(e>a.getMonth()+1||e===a.getMonth()+1&&n>=a.getDate())}).slice(0,o);if(n.length<o)for(let a=n.length;a<o;a++)n.push({name:"",date:"",isEmpty:!0});n.forEach((o,a)=>{const l=e.addStack();l.layoutHorizontally();const r=l.addStack();r.layoutVertically(),r.spacing=1;const i=r.addStack();i.layoutHorizontally(),i.spacing=2;const d=i.addText(o.name);d.font=Font.systemFont(16),d.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF"));const s=r.addStack();s.layoutHorizontally(),s.spacing=2;const c=o.isEmpty?null:function(t){try{const[o,e,n]=t.split("-").map(Number);return new Date(o,e-1,n)}catch(o){return null}}(o.date),g=s.addText(o.isEmpty?" ":function(o){const e=["周日","周一","周二","周三","周四","周五","周六"][o.getDay()],n=(o.getMonth()+1).toString().padStart(2,"0"),a=o.getDate().toString().padStart(2,"0");return`${o.getFullYear()}/${n}/${a}${"small"===t?"":`, ${e}`}`}(c));g.font=Font.regularRoundedSystemFont(9),g.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),l.addSpacer();const m=l.addStack();m.layoutHorizontally(),m.bottomAlignContent(),m.spacing=2;const u=o.isEmpty?" ":function(t){const o=new Date;o.setHours(0,0,0,0);const e=t.getTime()-o.getTime();return Math.floor(e/864e5)}(c),F=m.addStack();F.spacing=2,F.topAlignContent();const y=F.addText(u.toString());y.font=Font.boldRoundedSystemFont(22),y.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),y.rightAlignText();const p=m.addStack();if(p.setPadding(0,0,4,0),!o.isEmpty){const t=p.addText("天");t.font=Font.boldRoundedSystemFont(10),t.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),t.rightAlignText()}if(a<n.length-1){const n=e.addStack();n.layoutHorizontally(),n.setPadding(0,0,0,0),n.size=new Size("small"===t?126:306,1),n.borderWidth=1,n.borderColor=o.isEmpty?new Color("#FFFFFF",0):Color.dynamic(new Color("#E5E5E5"),new Color("#333333")),n.cornerRadius=1}}),config.runsInWidget?Script.setWidget(e):config.runsInApp&&("small"===t?e.presentSmall():"medium"===t?e.presentMedium():"large"===t&&e.presentLarge()),Script.complete();
|