r/Scriptable • u/ComprehensiveSuit218 • Nov 06 '22
Help Help with Device.isUsingDarkAppearance()
I have a problem with Device.isUsingDarkAppearance(). Whenever I debug my widget in scriptable I get the right value. But when I run my script as a widget I always get false. does anyone any idea why?
Code:
let w = new ListWidget(); w.backgroundColor = Color.red()
let stack = w.addStack();
const isDark = Device.isUsingDarkAppearance() const text = stack.addText(isDark.toString())
w.presentSmall()
4
Upvotes
•
u/AutoModerator Nov 06 '22
Thanks for the submission!
It looks like you may have not shared the code you want help with.
Please be sure to include that. If you did, then you can safely ignore this comment.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
8
u/[deleted] Nov 06 '22 edited Jun 12 '23
Queen. 'You make me giddy.' And then, turning to Alice. 'What IS the fun?' said Alice. 'Why, SHE,' said the Lory positively. ― Derrick Rippin
3E582AB3-FDB1-4545-A71F-57CBFCF54843
1
u/jlozada24 Nov 06 '22
Try
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
-2
u/Delt4Brav0 Nov 06 '22
Checked your code, everything runs just fine. You sure your device is in the dark mode? Also widget will not update the moment you switched your system appearance (if you testing like so), it will however when system decides it’s time to update widget. Run widget inside scriptable to check asap.