scriptable-testlab
Version:
A lightweight, efficient tool designed to manage and update scripts for Scriptable.
116 lines (113 loc) • 3.15 kB
text/typescript
import { AbsWidgetDate } from 'scriptable-abstract';
/**
* Represents the date format options.
*/
type DateFormat = 'time' | 'date' | 'relative' | 'offset' | 'timer';
/**
* Represents the text alignment options.
*/
type TextAlignment = 'left' | 'center' | 'right';
/**
* Represents the state of a widget date element.
*/
interface WidgetDateMockState {
readonly date: Date;
readonly textColor: Color;
readonly font: Font;
readonly textOpacity: number;
readonly lineLimit: number;
readonly minimumScaleFactor: number;
readonly shadowColor: Color;
readonly shadowRadius: number;
readonly shadowOffset: Readonly<Point>;
readonly url: string;
readonly dateFormat: DateFormat;
readonly textAlignment: TextAlignment;
readonly appliedStyles: ReadonlyArray<string>;
}
/**
* Mock implementation of Scriptable's WidgetDate.
* Provides a date element for displaying dates in widgets.
*
* @example
* ```typescript
* const date = new Date();
* const widgetDate = new MockWidgetDate(date);
* widgetDate.applyTimeStyle();
* widgetDate.centerAlignText();
* ```
*/
declare class MockWidgetDate extends AbsWidgetDate<WidgetDateMockState> {
/**
* Creates a new widget date element with the specified date.
*/
constructor(date: Date);
get date(): Date;
set date(value: Date);
get textColor(): Color;
set textColor(value: Color);
get font(): Font;
set font(value: Font);
get textOpacity(): number;
set textOpacity(value: number);
get lineLimit(): number;
set lineLimit(value: number);
get minimumScaleFactor(): number;
set minimumScaleFactor(value: number);
get shadowColor(): Color;
set shadowColor(value: Color);
get shadowRadius(): number;
set shadowRadius(value: number);
get shadowOffset(): Point;
set shadowOffset(value: Point);
get url(): string;
set url(value: string);
/**
* Applies the time style to the date element.
*/
applyTimeStyle(): void;
/**
* Applies the date style to the date element.
*/
applyDateStyle(): void;
/**
* Applies the relative style to the date element.
*/
applyRelativeStyle(): void;
/**
* Applies the offset style to the date element.
*/
applyOffsetStyle(): void;
/**
* Applies the timer style to the date element.
*/
applyTimerStyle(): void;
/**
* Centers the text in its container.
*/
centerAlignText(): void;
/**
* Aligns the text to the left of its container.
*/
leftAlignText(): void;
/**
* Aligns the text to the right of its container.
*/
rightAlignText(): void;
/**
* Gets the current date format.
* @returns The current date format.
*/
getDateFormat(): DateFormat;
/**
* Gets the current text alignment.
* @returns The current text alignment.
*/
getTextAlignment(): TextAlignment;
/**
* Gets the list of applied styles.
* @returns A copy of the applied styles array.
*/
getAppliedStyles(): ReadonlyArray<string>;
}
export { MockWidgetDate };