Skip to content
This repository was archived by the owner on Sep 15, 2024. It is now read-only.

Commit 313c5dd

Browse files
committed
show also weekday in DateApp
1 parent e38635e commit 313c5dd

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/apps/date/index.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import dayjs from 'dayjs';
22

33
import { App } from '../app';
4+
import { TimeApp } from '../time';
45
import { SmartDisplayController } from '../../smart-display-controller';
56

67
export 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
}

src/apps/time/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)