File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 13
13
},
14
14
"dependencies" : {
15
15
"@nativescript/core" : " ^8.5.3" ,
16
- "@vallemar/nativescript-vueuse" : " ^0.0.11 " ,
16
+ "@vallemar/nativescript-vueuse" : " ^0.0.12 " ,
17
17
"nativescript-vue" : " 3.0.0-beta.8"
18
18
},
19
19
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import ElementSizeView from "~/components/ElementSizeView.vue";
7
7
import ColorModeView from " ~/components/ColorModeView.vue" ;
8
8
import EventListenerComponent from " ~/components/EventListenerComponent.vue" ;
9
9
import RootLayoutView from ' ./rootLayout/RootLayoutView.vue' ;
10
+ import ScreenOrientationComponent from ' ./ScreenOrientationComponent.vue' ;
10
11
11
12
function onUseElementSize() {
12
13
$navigateTo (ElementSizeView )
@@ -23,6 +24,10 @@ function onUseRootLayout() {
23
24
$navigateTo (RootLayoutView )
24
25
}
25
26
27
+ function onUseScreenOrientation() {
28
+ $navigateTo (ScreenOrientationComponent )
29
+ }
30
+
26
31
</script >
27
32
28
33
<template >
@@ -35,6 +40,7 @@ function onUseRootLayout() {
35
40
<Button @tap =" onUseColorMode" text =" Use Color Mode" class =" mt-8 m-1" ></Button >
36
41
<Button @tap =" onUseEventListener" text =" Use Event Listener" class =" mt-8 m-1" ></Button >
37
42
<Button @tap =" onUseRootLayout" text =" Use Root Layout" class =" mt-8 m-1" ></Button >
43
+ <Button @tap =" onUseScreenOrientation" text =" Use Screen Orientation" class =" mt-8 m-1" ></Button >
38
44
</StackLayout >
39
45
</Page >
40
46
</Frame >
Original file line number Diff line number Diff line change
1
+ <script lang="ts" setup>
2
+ import { useScreenOrientation } from ' @vallemar/nativescript-vueuse' ;
3
+
4
+ const {
5
+ orientation,
6
+ setOrientation,
7
+ enableRotation,
8
+ disableRotation
9
+ } = useScreenOrientation ({
10
+ onChange : (orientation ) => {
11
+ console .log (" useScreenOrientation onChange " + orientation );
12
+ }
13
+ })
14
+
15
+ </script >
16
+
17
+ <template >
18
+ <Page actionBarHidden =" true" >
19
+ <ScrollView >
20
+ <StackLayout class =" p-3" >
21
+ <Label class =" text-center text-2xl" >ScreenOrientation {{ orientation }}</Label >
22
+ <Button @tap =" setOrientation('portrait')" class =" mx-1 mt-8" text =" Set portrait" ></Button >
23
+ <Button @tap =" setOrientation('landscape')" class =" mx-1 mt-8" text =" Set landscape" ></Button >
24
+ <Button @tap =" setOrientation('landscapeleft')" class =" mx-1 mt-8" text =" Set landscapeleft" ></Button >
25
+ <Button @tap =" setOrientation('landscaperight')" class =" mx-1 mt-8" text =" Set landscaperight" ></Button >
26
+ <Button @tap =" enableRotation" class =" mx-1 mt-8" text =" Enable rotation" ></Button >
27
+ <Button @tap =" disableRotation" class =" mx-1 mt-8" text =" Disable rotation" ></Button >
28
+ </StackLayout >
29
+ </ScrollView >
30
+ </Page >
31
+ </template >
You can’t perform that action at this time.
0 commit comments