forked from FOSS/BangleApps
commit
10072d745e
|
@ -196,7 +196,7 @@ const layout = new L({
|
|||
]
|
||||
}
|
||||
]
|
||||
}, {lazy: true});
|
||||
} as const, {lazy: true});
|
||||
|
||||
class State {
|
||||
paused: boolean = true;
|
||||
|
@ -248,7 +248,7 @@ class State {
|
|||
}
|
||||
}
|
||||
|
||||
const repToLabel = (i: number, id: string) => {
|
||||
const repToLabel = (i: number, id: "cur" | "next") => {
|
||||
const rep = reps[i];
|
||||
if(rep)
|
||||
layout[`${id}_name`]!.label = `${rep.label} / ${msToMinSec(rep.dur)}`;
|
||||
|
@ -256,7 +256,7 @@ const repToLabel = (i: number, id: string) => {
|
|||
emptyLabel(id);
|
||||
};
|
||||
|
||||
const emptyLabel = (id: string) => {
|
||||
const emptyLabel = (id: "cur" | "next") => {
|
||||
layout[`${id}_name`]!.label = "<none> / 0m";
|
||||
};
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
type Prev = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||
|
||||
type UnionToIntersection<U> =
|
||||
(U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never
|
||||
|
||||
type ExtractIds<T extends Layout.Hierarchy, Depth extends Prev[number] = 9> =
|
||||
[Depth] extends [never]
|
||||
? never
|
||||
: (T extends { id: infer Id extends string }
|
||||
? { [k in Id]: T }
|
||||
: (T extends { id?: infer Id extends string }
|
||||
? { [k in Id]: { -readonly [P in keyof T]: T[P] extends string ? string : T[P] } }
|
||||
: never)
|
||||
|
|
||||
(
|
||||
|
@ -15,7 +18,7 @@ type ExtractIds<T extends Layout.Hierarchy, Depth extends Prev[number] = 9> =
|
|||
|
||||
declare module Layout {
|
||||
type Layouter<T extends Hierarchy> =
|
||||
ExtractIds<T>
|
||||
UnionToIntersection<ExtractIds<T>>
|
||||
&
|
||||
{
|
||||
// these actually change T
|
||||
|
@ -31,6 +34,7 @@ declare module Layout {
|
|||
setUI(): void;
|
||||
};
|
||||
|
||||
// Note: you must use new Layout({...} as const) to have ids inferred
|
||||
var Layout: {
|
||||
new <T extends Hierarchy>(
|
||||
hier: T,
|
||||
|
|
Loading…
Reference in New Issue