This repository was archived by the owner on Sep 15, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import dayjs from 'dayjs' ;
22
33import { App } from '../app' ;
4+ import { TimeApp } from '../time' ;
45import { SmartDisplayController } from '../../smart-display-controller' ;
56
67export class DateApp implements App {
@@ -21,14 +22,20 @@ export class DateApp implements App {
2122 }
2223
2324 render ( ) : void {
25+ this . renderDate ( ) ;
26+
27+ TimeApp . renderWeekday ( this . controller ) ;
28+
29+ this . _wasRendered = true ;
30+ }
31+
32+ private renderDate ( ) : void {
2433 const date = dayjs ( ) . format ( 'DD.MM.' ) ;
2534
2635 this . controller . drawText ( {
2736 hexColor : '#00C8C8' ,
2837 text : date ,
2938 position : { x : 7 , y : 1 } ,
3039 } ) ;
31-
32- this . _wasRendered = true ;
3340 }
3441}
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ export class TimeApp implements App {
1616
1717 render ( ) : void {
1818 this . renderTime ( ) ;
19- this . renderWeekday ( ) ;
19+
20+ TimeApp . renderWeekday ( this . controller ) ;
2021
2122 // toggle colon
2223 this . showColon = ! this . showColon ;
@@ -29,19 +30,19 @@ export class TimeApp implements App {
2930 this . controller . drawText ( {
3031 hexColor : '#00C8C8' ,
3132 text : time ,
32- position : { x : 7 , y : 1 }
33+ position : { x : 7 , y : 1 } ,
3334 } ) ;
3435 }
3536
36- private renderWeekday ( ) : void {
37+ static renderWeekday ( controller : SmartDisplayController ) : void {
3738 const currentWeekday = dayjs ( ) . weekday ( ) ;
3839 const getXPositionByWeekDay = ( weekday : number ) => weekday * 4 + 2 ;
3940
4041 for ( let weekday = 0 ; weekday < 7 ; weekday ++ ) {
4142 const xPosition = getXPositionByWeekDay ( weekday ) ;
4243 const color = weekday === currentWeekday ? '#00C8C8' : '#A0A0A0' ;
4344
44- this . controller . drawLine (
45+ controller . drawLine (
4546 { x : xPosition , y : 7 } ,
4647 { x : xPosition + 2 , y : 7 } ,
4748 color
You can’t perform that action at this time.
0 commit comments