-Refactor -again- store theme calling

This commit is contained in:
Juan Carlos Ruvalcaba 2021-04-20 21:55:14 -07:00
parent bb44a800c9
commit 20ae42aacf
4 changed files with 30 additions and 29 deletions

View File

@ -8,27 +8,29 @@
</div>
</template>
<script>
export default (props, { $f7, $update, $store }) => {
// Login screen demo data
let username = '';
let password = '';
import store from './js/stores/index.js';
let theme = $store.getters.themeName.value;
export default (props, { $f7, $update }) => {
// Login screen demo data
let username = '';
let password = '';
const updateUsername = (e) => {
username = e.target.value;
$update();
}
const updatePassword = (e) => {
password = e.target.value;
$update();
}
const alertLoginData = () => {
$f7.dialog.alert('Username: ' + username + '<br/>Password: ' + password, () => {
$f7.loginScreen.close();
});
}
let theme = store.getters.themeName.value;
return $render;
const updateUsername = (e) => {
username = e.target.value;
$update();
}
const updatePassword = (e) => {
password = e.target.value;
$update();
}
const alertLoginData = () => {
$f7.dialog.alert('Username: ' + username + '<br/>Password: ' + password, () => {
$f7.loginScreen.close();
});
}
return $render;
}
</script>

View File

@ -12,8 +12,6 @@ import cordovaApp from './cordova-app.js';
// Import Routes
import routes from './routes.js';
// Import Store
import store from './stores/index.js';
// Import main app component
import App from '../app.f7.html';
@ -26,7 +24,6 @@ var app = new Framework7({
component: App, // App main component
id: 'com.comidacab.app', // App bundle ID
version: '2.0.0', // App version id
store: store, // App store
routes: routes, // App routes
// serviceWorker: { // Register service worker
// path: '/service-worker.js',

View File

@ -121,16 +121,17 @@
</div>
</template>
<script>
import $ from 'dom7';
import $ from 'dom7';
import store from '../../js/stores/index.js';
import User from '../../js/controllers/users.js';
export default (props, { $f7, $on, $update, $store }) => {
export default (props, { $f7, $on, $update, }) => {
let isLogged = false;
let isSeller = false;
let isCustomer = false;
let isDeliverer = false;
let theme = $store.getters.themeName.value;
let theme = store.getters.themeName.value;
const onPanelOpen = () => {
if (User.isLogged()){

View File

@ -61,12 +61,13 @@
</div>
</template>
<script>
import $ from 'dom7';
import $ from 'dom7';
import store from '../../js/stores/index.js';
import User from '../../js/controllers/users.js';
export default (props, { $f7, $on, $update, $store }) => {
export default (props, { $f7, $on, $update }) => {
let isLogged = false;
let theme = $store.getters.themeName.value;
let theme = store.getters.themeName.value;
const onPanelOpen = () => {
$('#light-theme').prop('checked', (theme != 'theme-dark') ? true : false );
@ -90,7 +91,7 @@ export default (props, { $f7, $on, $update, $store }) => {
$("#app, .panel-right").addClass("theme-dark");
}
theme = !$("#light-theme").prop('checked') ? 'theme-dark' : '';
$store.dispatch('changeTheme', theme);
store.dispatch('changeTheme', theme);
};
return $render;