Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pages/actions/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,8 @@
},
"upload-files": {
"title": "Upload Files"
},
"wakelock": {
"title": "Wakelock"
}
}
62 changes: 62 additions & 0 deletions pages/actions/wakelock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# wakelock

The wakelock action controls the device's screen wakelock, preventing the screen from automatically turning off while the app is in use. This is particularly useful for apps that display information users need to view continuously without interaction, such as recipe apps, navigation, or presentation modes.

### Properties

| Property | Type | Description |
| :--------- | :------ | :---------------------------------------------------------------------------------------------------- |
| enable | boolean | Controls the wakelock state. `true` to keep screen on, `false` to allow normal screen timeout. (default: true) |
| onComplete | action | Callback Action executed after the wakelock state is successfully changed |
| onError | action | Callback Action if wakelock operation fails. Error details available under 'error' field |

**Example**

```yaml
View:
header:
title: Wakelock Control
body:
Column:
styles: { gap: 16, padding: 24 }
children:
- Button:
label: Enable Wakelock
onTap:
wakelock:
enable: true
onComplete: |
//@code
status.text = 'Wakelock enabled - screen will stay on';
onError: |
//@code
status.text = 'Error: ' + error;
- Button:
label: Disable Wakelock
onTap:
wakelock:
enable: false
onComplete: |
//@code
status.text = 'Wakelock disabled - normal screen timeout';
- Button:
label: Check Wakelock Status
onTap: |
//@code
status.text = 'Wakelock is ' + (device.wakelockEnabled ? 'enabled' : 'disabled');
- Text:
id: status
text: Press a button to control wakelock
```

### Use Cases

- **Recipe/Cooking Apps**: Keep the screen on while users are following cooking instructions
- **Navigation**: Prevent screen timeout during route guidance
- **Presentations**: Keep display active during slideshows or demonstrations
- **Reading Apps**: Allow continuous reading without screen dimming
- **Fitness Apps**: Keep workout instructions visible during exercise sessions

### Note

The wakelock state can be checked at any time using `device.wakelockEnabled`, which returns `true` if the wakelock is currently active and `false` otherwise.
21 changes: 21 additions & 0 deletions pages/device-object.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,24 @@ View:
- Text:
text: Size of bottom area used by device is ${device.safeAreaBottom}
```

## device.wakelockEnabled

Returns a boolean indicating whether the device's screen wakelock is currently active. When the wakelock is enabled (`true`), the screen will not automatically turn off due to inactivity. When disabled (`false`), the device follows its normal screen timeout settings.

```yaml
View:
body:
Column:
styles: { gap: 16, padding: 24 }
children:
- Text:
text: Wakelock is ${device.wakelockEnabled ? 'enabled' : 'disabled'}
- Button:
label: Toggle Wakelock
onTap:
wakelock:
enable: ${!device.wakelockEnabled}
```

This property is useful for checking the current wakelock state before toggling it or displaying the status to users. See the [wakelock action](/actions/wakelock) for controlling the wakelock state.