Welcome to Scripting! This app enables you to create custom widgets for iOS using TypeScript and a React-like TSX syntax. With Scripting, you can build complex UIs quickly by combining familiar TypeScript code with SwiftUI components. Here’s how you can get started:
To create a widget for your iOS home screen, follow these steps:
widget.tsx
widget.tsx
.scripting
package.In this example:
MyWidgetView
is a function component that uses SwiftUI-inspired components (like VStack
and Text
) to structure and style the UI.Widget.present(<MyWidgetView />)
renders your component as the widget view on your home screen.To adapt your widget’s content to different contexts, you can use the following properties available through the Widget
API:
Widget.displaySize
: Provides the size of the widget being displayed, useful for adjusting the layout based on widget dimensions.Widget.family
: Returns the widget family (e.g., small, medium, large) to help tailor the UI for each available widget size.Widget.parameter
: Allows you to configure a custom parameter for the widget in the iOS home screen widget configuration panel. This parameter can be used within your component to customize the widget based on user input or preferences.Widget.present
, add a Scripting widget to your iOS home screen.The widget will now render MyWidgetView
(or whichever component you specified) directly on your home screen.
The Scripting app allows you to wrap and use SwiftUI views within your TypeScript code. This flexibility provides access to powerful, native iOS UI components and smooth integration with TypeScript’s logic and React-like TSX syntax.
Use the SwiftUI-inspired components available within Scripting, such as VStack
, Text
, and others, to achieve the look and feel you want.
widget.tsx
file, or you can create components in multiple files and then import them using import { OtherComponent } from "./other_component
.Widget.reloadAll()
. When you update the widget.tsx code, you can reload the widget by tapping the Refresh Widget
button in the lower right corner. Allowing for rapid development and testing.scripting
package.Enjoy building your custom widgets with Scripting! Feel free to explore and experiment with different layouts and components to create the perfect home screen widgets tailored to your needs.