Skip to content

Commit

Permalink
Add: スマホ用のヘッダーを追加 (#27)
Browse files Browse the repository at this point in the history
* Add: MobileHeaderBarを追加

* Code: 不要なimportを削除

* Change: ヘッダーの高さ周りを変更

* Change: メニューの中身を変更

* Discard changes to src/components/MenuItem.vue

* Add: TODOを追加
  • Loading branch information
sevenc-nanashi authored Jun 7, 2023
1 parent 7696153 commit 3792496
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 48 deletions.
5 changes: 1 addition & 4 deletions src/components/CharacterOrderDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -402,10 +402,7 @@ const closeDialog = () => {
}
.main {
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
);
height: calc(100vh - #{vars.$top-bar-height});
display: flex;
flex-direction: row;
Expand Down
5 changes: 1 addition & 4 deletions src/components/DefaultStyleListDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,7 @@ const openStyleSelectDialog = (characterInfo: CharacterInfo) => {
}
.main {
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
);
height: calc(100vh - #{vars.$top-bar-height});
display: flex;
flex-direction: row;
Expand Down
5 changes: 1 addition & 4 deletions src/components/DefaultStyleSelectDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,7 @@ const closeDialog = () => {
}
}
.q-page {
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
);
height: calc(100vh - #{vars.$top-bar-height});
overflow-y: scroll;
> :deep(.scroll) {
Expand Down
10 changes: 2 additions & 8 deletions src/components/DictionaryManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -747,10 +747,7 @@ const toDialogClosedState = () => {
.word-list {
// menubar-height + header-height + window-border-width +
// 82(title & buttons) + 30(margin 15x2)
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width + 82px + 30px}
);
height: calc(100vh - #{vars.$top-bar-height + 82px + 30px});
width: 100%;
overflow-y: auto;
}
Expand Down Expand Up @@ -788,10 +785,7 @@ const toDialogClosedState = () => {
.word-editor {
display: flex;
flex-flow: column;
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
) !important;
height: calc(100vh - #{vars.$top-bar-height}) !important;
overflow: auto;
}
Expand Down
10 changes: 2 additions & 8 deletions src/components/EngineManageDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -700,10 +700,7 @@ const toDialogClosedState = () => {
.engine-list {
// menubar-height + header-height + window-border-width +
// 82(title & buttons) + 30(margin 15x2)
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width + 82px + 30px}
);
height: calc(100vh - #{vars.$top-bar-height + 82px + 30px});
width: 100%;
overflow-y: auto;
}
Expand All @@ -727,10 +724,7 @@ const toDialogClosedState = () => {
.engine-detail {
display: flex;
flex-flow: column;
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
) !important;
height: calc(100vh - #{vars.$top-bar-height}) !important;
overflow: auto;
}
Expand Down
5 changes: 1 addition & 4 deletions src/components/HotkeySettingDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,7 @@ const resetHotkey = (action: string) => {
.hotkey-table {
width: calc(100vw - #{vars.$window-border-width * 2});
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
);
height: calc(100vh - #{vars.$top-bar-height});
> :deep(.scroll) {
overflow-y: scroll;
Expand Down
126 changes: 126 additions & 0 deletions src/components/MobileHeaderBar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<!-- TODO: PC版ヘッダーと統合する -->
<template>
<q-toolbar class="bg-primary text-white">
<q-btn flat round dense>
<q-icon name="menu" />
<q-menu transition-show="none" transition-hide="none">
<q-list dense>
<menu-item
v-for="(item, index) in menudata"
:key="item.label"
:menudata="item"
v-model:selected="subMenuOpenFlags[index]"
/>
</q-list>
</q-menu>
</q-btn>
<q-space />
<q-btn
v-for="button in headerButtons"
:key="button.icon"
:disable="button.disable"
flat
round
dense
@click="button.onClick"
:icon="button.icon"
/>
</q-toolbar>
</template>

<script setup lang="ts">
import { computed, ref } from "vue";
import { MenuItemData } from "./MenuBar.vue";
import MenuItem from "./MenuItem.vue";
import { useStore } from "@/store";
const store = useStore();

const uiLocked = computed(() => store.getters.UI_LOCKED);
const canUndo = computed(() => store.getters.CAN_UNDO);
const canRedo = computed(() => store.getters.CAN_REDO);

const headerButtons = computed(() => [
{
icon: "file_upload",
onClick: () => {
alert("TODO: 一つ保存する");
},
disable: uiLocked.value,
},
{
icon: "undo",
onClick: () => {
store.dispatch("UNDO");
},
disable: !canUndo.value,
},
{
icon: "redo",
onClick: () => {
store.dispatch("REDO");
},
disable: !canRedo.value,
},
]);

const menudata = ref<MenuItemData[]>([
{
type: "button",
label: "選択している音声を書き出し",
onClick: () => {
alert("TODO");
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "すべての音声を書き出し",
onClick: () => {
alert("TODO");
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "すべての音声を繋げて書き出し",
onClick: () => {
alert("TODO");
},
disableWhenUiLocked: true,
},
{
type: "separator",
},
{
type: "button",
label: "テキストを繋げて書き出し",
onClick: () => {
alert("TODO");
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "テキスト読み込み",
onClick: () => {
alert("TODO");
},
disableWhenUiLocked: true,
},
{
type: "separator",
},
{
type: "button",
label: "メニューに戻る",
onClick: () => {
alert("TODO");
},
disableWhenUiLocked: true,
},
]);

const subMenuOpenFlags = ref<boolean[]>(
[...Array(menudata.value.length)].map(() => false)
);
</script>
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ if (Capacitor.isNativePlatform()) {
console.log("Running in Electron");
}

document.body.setAttribute("data-target", import.meta.env.VITE_TARGET);

createApp(App)
.use(store, storeKey)
.use(router)
Expand Down
15 changes: 13 additions & 2 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
$window-border-width: 2px;

$header-height: 66px;
$menubar-height: 24px;
$header-height: var(--header-height);
$menubar-height: var(--menubar-height);
body {
&:not([data-target="mobile"]) {
--header-height: 66px;
--menubar-height: 24px;
}
&[data-target="mobile"] {
--header-height: 50px;
--menubar-height: 0px;
}
}
$top-bar-height: "(#{$header-height} + #{$menubar-height} + #{$window-border-width})";

$detail-view-splitter-cell-z-index: 2;
5 changes: 1 addition & 4 deletions src/views/EditorHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -858,10 +858,7 @@ watch(activeAudioKey, (audioKey) => {
display: flex;
.q-splitter--horizontal {
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
);
height: calc(100vh - #{vars.$top-bar-height});
}
}
Expand Down
13 changes: 3 additions & 10 deletions src/views/MobileEditorHome.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
<!-- FIXME: ロジックがEditorHome.vueからコピーされているので、良い感じに共通化する -->
<template>
<menu-bar />

<q-layout reveal elevated container class="layout-container">
<header-bar />
<mobile-header-bar />

<q-page-container>
<q-page class="main-row-panes">
<progress-dialog />

<!-- TODO: 複数エンジン対応 -->
<div
v-if="!isCompletedInitialStartup || allEngineState === 'STARTING'"
class="waiting-engine"
Expand Down Expand Up @@ -174,11 +171,10 @@ import draggable from "vuedraggable";
import { QResizeObserver, useQuasar } from "quasar";
import cloneDeep from "clone-deep";
import { useStore } from "@/store";
import HeaderBar from "@/components/HeaderBar.vue";
import MobileHeaderBar from "@/components/MobileHeaderBar.vue";
import AudioCell from "@/components/AudioCell.vue";
import AudioDetail from "@/components/AudioDetail.vue";
import AudioInfo from "@/components/AudioInfo.vue";
import MenuBar from "@/components/MenuBar.vue";
import HelpDialog from "@/components/HelpDialog.vue";
import SettingDialog from "@/components/SettingDialog.vue";
import HotkeySettingDialog from "@/components/HotkeySettingDialog.vue";
Expand Down Expand Up @@ -839,10 +835,7 @@ const loadDraggedFile = (event: { dataTransfer: DataTransfer | null }) => {
display: flex;

.q-splitter--horizontal {
height: calc(
100vh - #{vars.$menubar-height + vars.$header-height +
vars.$window-border-width}
);
height: calc(100vh - #{vars.$top-bar-height});
}
}

Expand Down

0 comments on commit 3792496

Please sign in to comment.