Просмотр исходного кода

feature(markup): добавлено изменение цветов для nav/notif баров

horanchikk 10 месяцев назад
Родитель
Сommit
85dd6c2d3f
4 измененных файлов с 28 добавлено и 0 удалено
  1. 7 0
      composables/useColors.ts
  2. 5 0
      layouts/default.vue
  3. 8 0
      layouts/news.vue
  4. 8 0
      layouts/none.vue

+ 7 - 0
composables/useColors.ts

@@ -0,0 +1,7 @@
+import { StatusBar } from '@capacitor/status-bar'
+import { NavigationBar } from '@capgo/capacitor-navigation-bar'
+
+export function updateColors(color: string) {
+  StatusBar.setBackgroundColor({ color })
+  NavigationBar.setNavigationBarColor({ color })
+}

+ 5 - 0
layouts/default.vue

@@ -14,6 +14,7 @@
 
 <script setup lang="ts">
 import { useSwipe } from '@vueuse/core'
+import { updateColors } from '~/composables/useColors'
 import { useSideBar } from '~/store/useSideBar'
 
 const store = useSideBar()
@@ -23,4 +24,8 @@ const { direction, lengthX } = useSwipe(globalWindow, {
     if (direction.value === 'right' && lengthX.value < -100) store.show()
   },
 })
+
+onMounted(() => {
+  updateColors('#212121')
+})
 </script>

+ 8 - 0
layouts/news.vue

@@ -5,3 +5,11 @@
     </main>
   </div>
 </template>
+
+<script setup lang="ts">
+import { updateColors } from '~/composables/useColors'
+
+onMounted(() => {
+  updateColors('#323232')
+})
+</script>

+ 8 - 0
layouts/none.vue

@@ -5,3 +5,11 @@
     </main>
   </div>
 </template>
+
+<script setup lang="ts">
+import { updateColors } from '~/composables/useColors'
+
+onMounted(() => {
+  updateColors('#212121')
+})
+</script>