Quasar Hacks - preserve state, remove header-footer bg, use safe-area for mobile-app

avatar
(Edited)

Quasar - How to preserve data when switching pages?

If you navigate from one screen to other screen, usually you loose the data.
Because App navigated to a different route & it deallocated data of previous route. E.g. you are filling up a form, as a user, you go to different screen & come back to form, you should still see the half-filled-up-form.

To achieve it, you need to explicitly tell the router that it needs to keep alive. So, go to MainLayout.vue, and edit it as follows.

<template>
  <q-layout class="safe-area">
    <q-page-container>
      <router-view v-slot="{ Component }">
        <keep-alive> 
          <component :is="Component" />
        </keep-alive>
      </router-view>
    </q-page-container>
  </q-layout>
</template>

Reference link: https://stackoverflow.com/a/70010322/140765

<keep-alive>

With this, your components / pages will stay alive.


Quasar - How to remove footer background color?

In Quasar, If you use footer, it's not straight forward to remove the background color of it.

But if you inspect elements, you can easily find out that certain colors are applied to a class. Copy that class & put it in the style section.
Here is how I did it.

.q-layout__section--marginal {
  background-color: unset;
  color: unset;
}

Once color & background-color are unset, you can use the footer of your choice.


Quasar - How to use Safe-Areas for iOS & Android?

For iOS & Android users, default quasar-layout goes below top-notch & below bottom safe area. To avoid this, you can use following trick.

Open MainLayout.vue & put content as follows.

<template>
  <q-layout class="safe-area">
    <q-page-container>
      <router-view v-slot="{ Component }">
        <keep-alive>
          <component :is="Component" />
        </keep-alive>
      </router-view>
    </q-page-container>
  </q-layout>
</template>

<script lang="ts">
import { defineComponent } from 'vue';

export default defineComponent({
  name: 'MainLayout',
  setup() {
    return {};
  },
});
</script>

<style lang="scss" scoped>
.safe-area {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}
</style>

Here, you can see that we've added a custom CSS class named safe-area to put contents within safe area.

NOTE: Not applicable to classes like absolute-center, absolute-top.

If you use such absolute-top, absolte-bottom, don't forget to apply this safe-area class as an additional styling.

Additional Source / reference - https://quasar.dev/quasar-cli-vite/developing-capacitor-apps/troubleshooting-and-tips#status-bar-and-notch-safe-areas


My Previous posts about Development using Quasar


Support me

Please 🙏Support Me
Vote me as Hive WitnessDonate Hive Or HBD


0
0
0.000
24 comments
avatar

This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens. HP delegators and IUC token holders also get upto 20% additional vote weight.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

image.png

100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited..

This post received an extra 5.06% vote for delegating HP / holding IUC tokens.

0
0
0.000
avatar
(Edited)

PIZZA!
The Hive.Pizza team manually curated this post.

$PIZZA slices delivered:
sagarkothari88 tipped bhattg
@peter-stone(5/5) tipped @sagarkothari88 (x2)
bhattg tipped sagarkothari88
sagarkothari88 tipped peter-stone
sagarkothari88 tipped indiaunited
sagarkothari88 tipped weone

Please vote for pizza.witness!

0
0
0.000
avatar

!giphy good work
!PIZZA
!DHEDGE

0
0
0.000
avatar

@bhattg - I recommend you to start learning Quasar development. It is very interesting & powerful app development framework. It combines power of vue-js, html5, scss. On top of that, with it gets super powers from CapacitorJS & many other npm libraries.

!PIZZA

0
0
0.000
avatar

He hee i wish I could do that but unfortunately I am not that much smart 😉🙃

0
0
0.000
avatar

Arey! Even I am also learning it day by day & I am sharing my learning here so that it can be helpful to others.

0
0
0.000
avatar

1


This post has been selected for upvote from our token accounts by @bhattg! Based on your tags you received upvotes from the following account(s):

- @dhedge.bonus
- @dhedge.leo
- @dhedge.ctp
- @dhedge.pob
- @dhedge.alive

@bhattg has 9 vote calls left today.

Hold 10 or more DHEDGE to unlock daily dividends and gain access to upvote rounds on your posts from @dhedge. Hold 100 or more DHEDGE to unlock thread votes. Calling in our curation accounts currently has a minimum holding requirement of 100 DHEDGE. The more DHEDGE you hold, the higher upvote you can call in. Buy DHEDGE on Tribaldex or earn some daily by joining one of our many delegation pools at app.dhedge.cc.

0
0
0.000
avatar

Congratulations @sagarkothari88! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You got more than 3250 replies.
Your next target is to reach 3500 replies.
You distributed more than 50000 upvotes.
Your next target is to reach 51000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Check out our last posts:

LEO Power Up Day - July 15, 2023
0
0
0.000
avatar

I'm not sure, but maybe one day your articles will be useful to me :)
!PIZZA

0
0
0.000
avatar

I find my articles useful to me. I keep notes for myself. If I start a new project from scratch, I will need those for sure. It's like you're keeping an open notebook on hive. It can be useful to anyone.

I recommend you to learn Quasar. It's best.

!PIZZA

!GIF Thank you

0
0
0.000
avatar

I hope I find time for this, thanks for the recommendation :)
!PIZZA

0
0
0.000
avatar

Time = Priority.
If it's in priority, you'll find time. If it isn't you won't find time.

0
0
0.000