Skip to content

Commit 5f09d71

Browse files
committed
updated the docs for Wakelock action
1 parent c172f7a commit 5f09d71

3 files changed

Lines changed: 86 additions & 0 deletions

File tree

pages/actions/_meta.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,5 +175,8 @@
175175
},
176176
"upload-files": {
177177
"title": "Upload Files"
178+
},
179+
"wakelock": {
180+
"title": "Wakelock"
178181
}
179182
}

pages/actions/wakelock.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# wakelock
2+
3+
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.
4+
5+
### Properties
6+
7+
| Property | Type | Description |
8+
| :--------- | :------ | :---------------------------------------------------------------------------------------------------- |
9+
| enable | boolean | Controls the wakelock state. `true` to keep screen on, `false` to allow normal screen timeout. (default: true) |
10+
| onComplete | action | Callback Action executed after the wakelock state is successfully changed |
11+
| onError | action | Callback Action if wakelock operation fails. Error details available under 'error' field |
12+
13+
**Example**
14+
15+
```yaml
16+
View:
17+
header:
18+
title: Wakelock Control
19+
body:
20+
Column:
21+
styles: { gap: 16, padding: 24 }
22+
children:
23+
- Button:
24+
label: Enable Wakelock
25+
onTap:
26+
wakelock:
27+
enable: true
28+
onComplete: |
29+
//@code
30+
status.text = 'Wakelock enabled - screen will stay on';
31+
onError: |
32+
//@code
33+
status.text = 'Error: ' + error;
34+
- Button:
35+
label: Disable Wakelock
36+
onTap:
37+
wakelock:
38+
enable: false
39+
onComplete: |
40+
//@code
41+
status.text = 'Wakelock disabled - normal screen timeout';
42+
- Button:
43+
label: Check Wakelock Status
44+
onTap: |
45+
//@code
46+
status.text = 'Wakelock is ' + (device.wakelockEnabled ? 'enabled' : 'disabled');
47+
- Text:
48+
id: status
49+
text: Press a button to control wakelock
50+
```
51+
52+
### Use Cases
53+
54+
- **Recipe/Cooking Apps**: Keep the screen on while users are following cooking instructions
55+
- **Navigation**: Prevent screen timeout during route guidance
56+
- **Presentations**: Keep display active during slideshows or demonstrations
57+
- **Reading Apps**: Allow continuous reading without screen dimming
58+
- **Fitness Apps**: Keep workout instructions visible during exercise sessions
59+
60+
### Note
61+
62+
The wakelock state can be checked at any time using `device.wakelockEnabled`, which returns `true` if the wakelock is currently active and `false` otherwise.

pages/device-object.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,24 @@ View:
5151
- Text:
5252
text: Size of bottom area used by device is ${device.safeAreaBottom}
5353
```
54+
55+
## device.wakelockEnabled
56+
57+
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.
58+
59+
```yaml
60+
View:
61+
body:
62+
Column:
63+
styles: { gap: 16, padding: 24 }
64+
children:
65+
- Text:
66+
text: Wakelock is ${device.wakelockEnabled ? 'enabled' : 'disabled'}
67+
- Button:
68+
label: Toggle Wakelock
69+
onTap:
70+
wakelock:
71+
enable: ${!device.wakelockEnabled}
72+
```
73+
74+
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.

0 commit comments

Comments
 (0)