Example app
example/ is a NitroUI drawing app built on nitro-ui-sketch. Its App.tsx shows:
| Feature | API used |
|---|---|
| Canvas with zoom from 0.5× to 8× | SketchCanvas minimumZoom, maximumZoom, onViewportChange |
| Stroke count and status line | onDrawingChange, Drawing.strokeCount |
| Finger or stylus-only drawing | drawingPolicy |
| Clear | Drawing.clear() |
| PNG export | Drawing.toImage({ format: 'png', quality: 100, scale: 2 }) |
| Save and load | Drawing.toData(), Drawing.fromData() |
| Delete and duplicate a selection | onSelectionChange, deleteSelection(), duplicateSelection() |
| Tool picker with ruler and density switch | ToolPicker rulerActive, onRulerActiveChange, density |
| A 1× zoom reset button in the bar | ToolPicker accessory, ToolPickerButton, setViewport() |
| Closing the options card on touch | onTouchDown, ToolPickerHandle.dismissOptions() |
Run it
From a fresh clone:
bun install
cd example
bun run nitro-ui prepare
bun run ios --device <simulator-UDID>
bun run android --device <adb-serial>
bun install at the root links the workspace, copies tgfx into vendor/ and prepares the example.
Native tests
The example also hosts the nitro-ui-harness tests in example/__tests__, which run inside the app on a simulator or emulator. See Contributing.