UNPKG

scriptable-testlab

Version:

A lightweight, efficient tool designed to manage and update scripts for Scriptable.

115 lines 2.51 kB
import { AbsWidgetText } from "scriptable-abstract"; import { MockColor } from "../color"; import { MockFont } from "../font"; const DEFAULT_STATE = { text: "", textColor: new MockColor("#000000"), font: MockFont.systemFont(12), textOpacity: 1, lineLimit: 0, minimumScaleFactor: 1, shadowColor: new MockColor("#000000"), shadowRadius: 0, shadowOffset: { x: 0, y: 0 }, url: "", alignment: "default" }; class MockWidgetText extends AbsWidgetText { /** * Creates a new widget text element with the specified text. */ constructor(text) { super({ ...DEFAULT_STATE, text }); } /** * Creates a new widget text instance. */ static create(text) { return new MockWidgetText(text); } // Property accessors get text() { return this.state.text; } set text(value) { this.setState({ text: value }); } get textColor() { return this.state.textColor; } set textColor(value) { this.setState({ textColor: value }); } get font() { return this.state.font; } set font(value) { this.setState({ font: value }); } get textOpacity() { return this.state.textOpacity; } set textOpacity(value) { this.setState({ textOpacity: value }); } get lineLimit() { return this.state.lineLimit; } set lineLimit(value) { this.setState({ lineLimit: value }); } get minimumScaleFactor() { return this.state.minimumScaleFactor; } set minimumScaleFactor(value) { this.setState({ minimumScaleFactor: value }); } get shadowColor() { return this.state.shadowColor; } set shadowColor(value) { this.setState({ shadowColor: value }); } get shadowRadius() { return this.state.shadowRadius; } set shadowRadius(value) { this.setState({ shadowRadius: value }); } get shadowOffset() { return { ...this.state.shadowOffset }; } set shadowOffset(value) { this.setState({ shadowOffset: { ...value } }); } get url() { return this.state.url; } set url(value) { this.setState({ url: value }); } // Text alignment methods leftAlignText() { this.setState({ alignment: "left" }); } centerAlignText() { this.setState({ alignment: "center" }); } rightAlignText() { this.setState({ alignment: "right" }); } /** * Gets the current text alignment. * @returns The current text alignment value. */ getAlignment() { return this.state.alignment; } } export { MockWidgetText }; //# sourceMappingURL=text.js.map