Skip to content

Commit

Permalink
feat: adding sleep mode feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyri1 committed Feb 21, 2023
1 parent 04609a1 commit d98d6dd
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 28 deletions.
41 changes: 41 additions & 0 deletions src/composables/listStoryNodes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { useStoryStore } from '../stores/StoryStores';
import { detectTypeOfStageNode } from './handleSlideClick';

export function useListStoryNodes() {
var nodeList = [];
const storyStore = useStoryStore();
for (var story of storyStore.stories) {
for (var stageNode of story.stageNodes) {
if (stageNode.image) {
if (detectTypeOfStageNode(stageNode)?.type === 'displaySlideSet') {
var okTransition = detectTypeOfStageNode(stageNode)?.okTransition;
for (var actionNode of story.actionNodes) {
if (actionNode.id === okTransition.actionNode) {
var nextStageNodes =
actionNode.options[
okTransition.optionIndex < 0 ? 0 : okTransition.optionIndex
];
for (var stageNodedisplaySlideSet of story.stageNodes) {
if (stageNodedisplaySlideSet.uuid === nextStageNodes) {
if (
detectTypeOfStageNode(stageNodedisplaySlideSet)?.type ===
'audioStory'
) {
stageNodedisplaySlideSet.name = story.name;
stageNodedisplaySlideSet.icon = stageNode.image;
nodeList.push(stageNodedisplaySlideSet);
}
}
}
}
}
}
}
}
}
var parsednodeList = [];
for (var node of nodeList) {
parsednodeList.push({'name': node.name, 'node': node})
}
console.log(parsednodeList);
}
10 changes: 2 additions & 8 deletions src/stores/StoryStores.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const useStoryStore = defineStore('StoryStore', {
theme: null,
contributorPwd: null,
timelineVisible: null,
sleepModeModalIsOpen: false,
unofficialStore: [],
downloadedPacks: [],
installedPacks: [],
Expand Down Expand Up @@ -60,14 +61,7 @@ export const useStoryStore = defineStore('StoryStore', {
}
}
}
//remove unfavorited stories from indexSlides
var indexSlidesWithoutUnfavorited = [];
for(let storySlide of indexSlides) {
if(!this.unfavoriteStories.includes(storySlide.name)) {
indexSlidesWithoutUnfavorited.push(storySlide);
}
}
this.activeSlides = indexSlidesWithoutUnfavorited;
this.activeSlides = indexSlides;
},
setPreferences() {
Preferences.get({ key: 'theme' }).then((result) => {
Expand Down
1 change: 0 additions & 1 deletion src/views/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ onMounted(() => {
router.afterEach((to) => {
if (to.name === 'Home') {
storyStore.fillStoriesIndex()
homeButton()
}
})
Expand Down
44 changes: 25 additions & 19 deletions src/views/PrefTab3.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</ion-select>
</ion-item>
</ion-list>
<ion-button v-show="false" slot="start" @click="setOpen(true)">Activer le mode sommeil</ion-button>
<ion-button v-show="true" slot="start" @click="setOpen(true)">Activer le mode sommeil</ion-button>
</ion-card-content>
</ion-card>
<ion-card>
Expand All @@ -37,23 +37,23 @@
</ion-list>
</ion-card-content>
</ion-card>
<ion-modal :is-open="isOpen">
<ion-header>
<ion-toolbar>
<ion-title>Mode sommeil</ion-title>
<ion-buttons slot="end">
<ion-button @click="setOpen(false)">Fermer</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni illum quidem recusandae ducimus quos
reprehenderit. Veniam, molestias quos, dolorum consequuntur nisi deserunt omnis id illo sit cum qui. Eaque,
dicta.
</p>
</ion-content>
</ion-modal>
<ion-modal :is-open="storyStore.sleepModeModalIsOpen">
<ion-header>
<ion-toolbar>
<ion-title>Mode sommeil</ion-title>
<ion-buttons slot="end">
<ion-button @click="setOpen(false)">Fermer</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-header>
<ion-content class="ion-padding">
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Magni illum quidem recusandae ducimus quos
reprehenderit. Veniam, molestias quos, dolorum consequuntur nisi deserunt omnis id illo sit cum qui. Eaque,
dicta.
</p>
</ion-content>
</ion-modal>
</ion-content>
</ion-page>
</template>
Expand Down Expand Up @@ -83,6 +83,8 @@ import {
import { onMounted } from "vue";
import { Preferences } from '@capacitor/preferences';
import { useStoryStore } from '../stores/StoryStores';
import { useListStoryNodes } from '../composables/listStoryNodes';
const storyStore = useStoryStore();
onMounted(() => {
Expand Down Expand Up @@ -112,13 +114,17 @@ function changeContributorPwd(event) {
}
function activeTimeline(event) {
function activeTimeline(event) {
Preferences.set({
key: 'timelineVisible',
value: String(event.detail.checked),
})
storyStore.timelineVisible = event.detail.checked
}
function setOpen(isOpen) {
storyStore.sleepModeModalIsOpen = isOpen;
console.log(useListStoryNodes());
}
</script>

0 comments on commit d98d6dd

Please sign in to comment.