Skip to main content

Example app

example/ is a NitroUI drawing app built on nitro-ui-sketch. Its App.tsx shows:

FeatureAPI used
Canvas with zoom from 0.5× to 8×SketchCanvas minimumZoom, maximumZoom, onViewportChange
Stroke count and status lineonDrawingChange, Drawing.strokeCount
Finger or stylus-only drawingdrawingPolicy
ClearDrawing.clear()
PNG exportDrawing.toImage({ format: 'png', quality: 100, scale: 2 })
Save and loadDrawing.toData(), Drawing.fromData()
Delete and duplicate a selectiononSelectionChange, deleteSelection(), duplicateSelection()
Tool picker with ruler and density switchToolPicker rulerActive, onRulerActiveChange, density
A 1× zoom reset button in the barToolPicker accessory, ToolPickerButton, setViewport()
Closing the options card on touchonTouchDown, 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.