@showlotus/open-scriptable 0.1.14 → 0.1.15
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
|
-
!function(){let t;t=config.runsInWidget?config.widgetFamily||"small":"
|
|
1
|
+
!function(){let t;t=config.runsInWidget?config.widgetFamily||"small":"large";const e={small:3,medium:3,large:7}[t],n=new ListWidget;n.backgroundColor=Color.dynamic(new Color("#FFFFFF"),new Color("#1c1c1c")),n.spacing=8;const o=Object.entries(function(t,e=""){try{return __GLOBAL_CONFIG__[t]}catch(n){return e}}("days",{})||{}).map(([t,e])=>({name:t,date:e,isEmpty:!1})).sort((t,e)=>t.date>e.date?1:-1).filter(t=>{const[e,n,o]=t.date.split("-").map(Number),a=new Date;return e>a.getFullYear()||e===a.getFullYear()&&(n>a.getMonth()+1||n===a.getMonth()+1&&o>=a.getDate())}).slice(0,e);if(o.length>0&&o.length<e)for(let a=o.length;a<e;a++)o.push({name:"",date:"",isEmpty:!0});o.forEach((e,a)=>{const l=n.addStack();l.layoutHorizontally();const r=l.addStack();r.layoutVertically(),r.spacing=1;const c=r.addStack();c.layoutHorizontally(),c.spacing=2;const i=c.addText(e.name);i.font=Font.mediumRoundedSystemFont(14),i.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF"));const d=r.addStack();d.layoutHorizontally(),d.spacing=2;const s=e.isEmpty?null:function(t){try{const[e,n,o]=t.split("-").map(Number);return new Date(e,n-1,o)}catch(e){return null}}(e.date),g=d.addText(e.isEmpty?" ":function(e){const n=["周日","周一","周二","周三","周四","周五","周六"][e.getDay()],o=(e.getMonth()+1).toString().padStart(2,"0"),a=e.getDate().toString().padStart(2,"0");return`${e.getFullYear()}/${o}/${a}${"small"===t?"":`, ${n}`}`}(s));g.font=Font.regularRoundedSystemFont(10),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=e.isEmpty?" ":function(t){const e=new Date;e.setHours(0,0,0,0);const n=t.getTime()-e.getTime();return Math.floor(n/864e5)}(s),p=m.addStack();p.spacing=2,p.topAlignContent();const y=p.addText(u.toString());y.font=Font.mediumRoundedSystemFont(24),y.textColor=Color.dynamic(new Color("#000000"),new Color("#FFFFFF")),y.rightAlignText();const F=m.addStack();if(F.setPadding(0,0,4,0),!e.isEmpty){const t=F.addText("天");t.font=Font.boldRoundedSystemFont(10),t.textColor=Color.dynamic(new Color("#979797"),new Color("#8e8e8e")),t.rightAlignText()}if(a<o.length-1){const o=n.addStack();o.layoutHorizontally(),o.centerAlignContent();const a="small"===t?126:305,l=1;let r=new Color("#8C8C8C",.2);e.isEmpty&&(r=new Color("#ffffff",0));const c=o.addImage(function(t,e,n){const o=new DrawContext;o.size=new Size(t,e),o.opaque=!1,o.respectScreenScale=!0,o.setFillColor(n);const a=new Path;return a.addRoundedRect(new Rect(0,0,t,e),e/2,e/2),o.addPath(a),o.fillPath(),o.getImage()}(a,l,r));c.centerAlignImage()}}),config.runsInWidget?Script.setWidget(n):config.runsInApp&&("small"===t?n.presentSmall():"medium"===t?n.presentMedium():"large"===t&&n.presentLarge()),Script.complete()}();
|