UNPKG

scriptable-testlab

Version:

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

122 lines (119 loc) 3.78 kB
import { AbsWidgetImage } from 'scriptable-abstract'; /** * Represents the content mode options for an image. */ type ContentMode = 'fitting' | 'filling'; /** * Represents the alignment options for an image. */ type ImageAlignment = 'left' | 'center' | 'right'; /** * Represents the state of a widget image element. */ interface WidgetImageMockState { readonly image: Image; readonly resizable: boolean; readonly imageSize: Size; readonly imageOpacity: number; readonly cornerRadius: number; readonly borderWidth: number; readonly borderColor: Color; readonly containerRelativeShape: boolean; readonly tintColor: Color; readonly url: string; readonly contentMode: ContentMode; readonly alignment: ImageAlignment; } /** * Mock implementation of Scriptable's WidgetImage. * Represents an image that can be displayed in a widget. * * @example * ```typescript * const image = MockImage.fromFile('example.jpg'); * const widgetImage = new MockWidgetImage(image); * widgetImage.imageSize = new MockSize(200, 100); * widgetImage.cornerRadius = 10; * widgetImage.centerAlignImage(); * ``` */ declare class MockWidgetImage extends AbsWidgetImage<WidgetImageMockState> { /** * Creates a new widget image element with the specified image. */ constructor(image?: Image); /** * Creates a new widget image instance. * @param image - The image to display in the widget. * @returns A new widget image instance. */ static create(image?: Image): WidgetImage; get image(): Image; set image(value: Image); get resizable(): boolean; set resizable(value: boolean); get imageSize(): Size; set imageSize(value: Size); /** * Gets or sets the opacity of the image. * Value should be between 0 (fully transparent) and 1 (fully opaque). */ get imageOpacity(): number; set imageOpacity(value: number); /** * Gets or sets the corner radius of the image. * Negative values will be converted to 0. */ get cornerRadius(): number; set cornerRadius(value: number); /** * Gets or sets the border width of the image. * Negative values will be converted to 0. */ get borderWidth(): number; set borderWidth(value: number); get borderColor(): Color; set borderColor(value: Color); get containerRelativeShape(): boolean; set containerRelativeShape(value: boolean); get tintColor(): Color; set tintColor(value: Color); get url(): string; set url(value: string); /** * Aligns the image to the left of its container. * @returns this for method chaining */ leftAlignImage(): this; /** * Centers the image in its container. * @returns this for method chaining */ centerAlignImage(): this; /** * Aligns the image to the right of its container. * @returns this for method chaining */ rightAlignImage(): this; /** * Sets the content mode to fitting, which scales the image to fit within its container while maintaining aspect ratio. * @returns this for method chaining */ applyFittingContentMode(): this; /** * Sets the content mode to filling, which scales the image to fill its container while maintaining aspect ratio. * @returns this for method chaining */ applyFillingContentMode(): this; /** * Gets the current alignment of the image. * @returns The current alignment ('left', 'center', or 'right'). */ getAlignment(): ImageAlignment; /** * Gets the current content mode of the image. * @returns The current content mode ('fitting' or 'filling'). */ getContentMode(): ContentMode; } export { MockWidgetImage };