(args: EventData)
| 4 | import { Page } from '@nativescript/core/ui/page'; |
| 5 | |
| 6 | export function onNavigatedTo(args: EventData) { |
| 7 | const page = <Page>args.object; |
| 8 | |
| 9 | const orientationButton: Button = page.getViewById('orientation-match-media-btn'); |
| 10 | if (orientationButton) { |
| 11 | const mq = matchMedia('(orientation: portrait)'); |
| 12 | let mode = mq.matches ? 'portrait' : 'landscape'; |
| 13 | |
| 14 | orientationButton.text = `I' m in ${mode} mode!`; |
| 15 | |
| 16 | mq.addEventListener('change', (event: MediaQueryListEvent) => { |
| 17 | mode = event.matches ? 'portrait' : 'landscape'; |
| 18 | orientationButton.text = `I' m in ${mode} mode!`; |
| 19 | }); |
| 20 | } |
| 21 | |
| 22 | const themeModeButton: Button = page.getViewById('theme-match-media-btn'); |
| 23 | if (themeModeButton) { |
| 24 | const mq = matchMedia('(prefers-color-scheme: light)'); |
| 25 | let mode = mq.matches ? 'light' : 'dark'; |
| 26 | |
| 27 | themeModeButton.text = `I' m in ${mode} mode!`; |
| 28 | |
| 29 | mq.addEventListener('change', (event: MediaQueryListEvent) => { |
| 30 | mode = event.matches ? 'light' : 'dark'; |
| 31 | themeModeButton.text = `I' m in ${mode} mode!`; |
| 32 | }); |
| 33 | } |
| 34 | } |
nothing calls this directly
no test coverage detected