Skip to content

Commit 5b6e2d1

Browse files
committed
add generic androidStatusBarBackground
1 parent 9d6cf64 commit 5b6e2d1

File tree

8 files changed

+110
-114
lines changed

8 files changed

+110
-114
lines changed

package-lock.json

Lines changed: 73 additions & 98 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/ColorModeView.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { ListItem } from "nativescript-vue";
33
import { useColorMode, useColorPalette } from "@vallemar/nativescript-vueuse";
44
import { Patelle, THEMES } from "~/data";
5+
import CustomPage from "./CustomPage.vue";
56
67
const { schema } = useColorMode({
78
onChanged: (mode) => {
@@ -18,7 +19,7 @@ function changeTheme(newTheme: any) {
1819
</script>
1920

2021
<template>
21-
<Page actionBarHidden="true">
22+
<CustomPage>
2223
<StackLayout class="py-4 pl-3">
2324
<Label :text="`Current Theme: ${schema}`" />
2425

@@ -46,5 +47,5 @@ function changeTheme(newTheme: any) {
4647
</StackLayout>
4748
</FlexboxLayout>
4849
</StackLayout>
49-
</Page>
50+
</CustomPage>
5051
</template>

src/components/CustomPage.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<script lang="ts" setup>
2+
import { useColorPalette } from '@vallemar/nativescript-vueuse';
3+
import { Patelle } from '~/data';
4+
5+
const { palette } = useColorPalette<string, Patelle>()
6+
</script>
7+
8+
<template>
9+
<Page actionBarHidden="true" :androidStatusBarBackground="palette?.colors.bg">
10+
<slot></slot>
11+
</Page>
12+
</template>
13+

src/components/ElementSizeView.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<script lang="ts" setup>
22
import { ref } from "nativescript-vue";
33
import { useElementSize, unrefView } from "@vallemar/nativescript-vueuse";
4+
import CustomPage from "./CustomPage.vue";
45
56
const refView = ref()
67
const { width, height } = useElementSize(refView);
78
89
function changeSize() {
910
const view = unrefView(refView);
10-
if(view){
11+
if (view) {
1112
view.height = view.getActualSize().height === 400 ? 150 : 400;
1213
}
1314
}
1415
</script>
1516

1617
<template>
17-
<Page actionBarHidden="true">
18+
<CustomPage>
1819
<StackLayout class="p-4">
1920
<StackLayout originY="0" ref="refView" class="bg-variant rounded-2xl p-3 text-center">
2021
<Label :text="`Width: ${width}`" />
@@ -23,5 +24,5 @@ function changeSize() {
2324

2425
<Button @tap="changeSize" text="Change size" class="mt-12 mx-1"></Button>
2526
</StackLayout>
26-
</Page>
27+
</CustomPage>
2728
</template>

src/components/EventListenerComponent.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script lang="ts" setup>
22
import { ref } from "nativescript-vue";
3-
import {alert, StackLayout} from "@nativescript/core";
3+
import { alert, StackLayout } from "@nativescript/core";
44
import { useEventListener } from "@vallemar/nativescript-vueuse";
5+
import CustomPage from "./CustomPage.vue";
56
67
const el = ref()
78
@@ -19,11 +20,11 @@ const { cleanup } = useEventListener<StackLayout>(el, {
1920
</script>
2021

2122
<template>
22-
<Page actionBarHidden="true">
23+
<CustomPage>
2324
<StackLayout class="p-4">
2425
<FlexboxLayout ref="el" class="bg-variant rounded-2xl p-3 text-center h-[200] items-center justify-center">
2526
<Label class="text-2xl">Tap Me!</Label>
2627
</FlexboxLayout>
2728
</StackLayout>
28-
</Page>
29+
</CustomPage>
2930
</template>

src/components/Home.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import ColorModeView from "~/components/ColorModeView.vue";
88
import EventListenerComponent from "~/components/EventListenerComponent.vue";
99
import RootLayoutView from './rootLayout/RootLayoutView.vue';
1010
import ScreenOrientationComponent from './ScreenOrientationComponent.vue';
11+
import { useColorPalette } from '@vallemar/nativescript-vueuse';
12+
import { Patelle } from '~/data';
13+
import CustomPage from './CustomPage.vue';
14+
15+
const { palette } = useColorPalette<string, Patelle>()
1116
1217
function onUseElementSize() {
1318
$navigateTo(ElementSizeView)
@@ -32,17 +37,16 @@ function onUseScreenOrientation() {
3237

3338
<template>
3439
<Frame backgroundColor="transparent">
35-
<Page actionBarHidden="true">
40+
<CustomPage>
3641
<StackLayout ref="test" class="px-4">
3742
<Label text="NativeScript-VueUse APP" class="text-2xl font-bold mt-3" />
38-
3943
<Button @tap="onUseElementSize" text="Use Element Size" class="mt-12 m-1"></Button>
4044
<Button @tap="onUseColorMode" text="Use Color Mode" class="mt-8 m-1"></Button>
4145
<Button @tap="onUseEventListener" text="Use Event Listener" class="mt-8 m-1"></Button>
4246
<Button @tap="onUseRootLayout" text="Use Root Layout" class="mt-8 m-1"></Button>
4347
<Button @tap="onUseScreenOrientation" text="Use Screen Orientation" class="mt-8 m-1"></Button>
4448
</StackLayout>
45-
</Page>
49+
</CustomPage>
4650
</Frame>
4751
</template>
4852

src/components/ScreenOrientationComponent.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts" setup>
22
import { useScreenOrientation } from '@vallemar/nativescript-vueuse';
3+
import CustomPage from './CustomPage.vue';
34
45
const {
56
orientation,
@@ -15,7 +16,7 @@ const {
1516
</script>
1617

1718
<template>
18-
<Page actionBarHidden="true">
19+
<CustomPage>
1920
<ScrollView>
2021
<StackLayout class="p-3">
2122
<Label class="text-center text-2xl">ScreenOrientation {{ orientation }}</Label>
@@ -27,5 +28,5 @@ const {
2728
<Button @tap="disableRotation" class="mx-1 mt-8" text="Disable rotation"></Button>
2829
</StackLayout>
2930
</ScrollView>
30-
</Page>
31+
</CustomPage>
3132
</template>

src/components/rootLayout/RootLayoutView.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import BottomSheet from "./BottomSheet.vue";
55
import Modal from './Modal.vue';
66
import SideBar from './SideBar.vue';
77
import SnackBar from './SnackBar.vue';
8+
import CustomPage from '../CustomPage.vue';
89
910
1011
const { show: showBottomSheet } = useRootLayout(BottomSheet, {
@@ -101,16 +102,15 @@ const { show: showSnackbar } = useRootLayout(SnackBar, {
101102
</script>
102103

103104
<template>
104-
<Page actionBarHidden="true">
105+
<CustomPage>
105106
<RootLayout>
106107
<StackLayout class="p-3">
107108
<Label class="text-center text-2xl">RootLayout example</Label>
108109
<Button @tap="showBottomSheet" class="mx-1 mt-8" text="Open BottomSheet"></Button>
109110
<Button @tap="showModal" class="mx-1 mt-8" text="Open Modal"></Button>
110111
<Button @tap="showSideBar" class="mx-1 mt-8" text="Open Sidebar"></Button>
111112
<Button @tap="showSnackbar" class="mx-1 mt-8" text="Open Snackbar"></Button>
112-
113113
</StackLayout>
114114
</RootLayout>
115-
</Page>
115+
</CustomPage>
116116
</template>

0 commit comments

Comments
 (0)