Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: Able to change desktop/mobile mode on top #1063

Merged
merged 1 commit into from
Dec 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ common:
explore: "Explore"
following: "Following"
followers: "Followers"
desktop-mode: 'Desktop mode'
mobile-mode: 'Mobile mode'
favorites: "Bookmarks"
flush: "Clear cache"
permissions:
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ common:
explore: "ใฟใคใ‘ใ‚‹"
following: "ใƒ•ใ‚ฉใƒญใƒผไธญ"
followers: "ใƒ•ใ‚ฉใƒญใƒฏใƒผ"
desktop-mode: 'ใƒ‡ใ‚นใ‚ฏใƒˆใƒƒใƒ—็‰ˆ'
mobile-mode: 'ใƒขใƒใ‚คใƒซ็‰ˆ'
favorites: "ใƒ–ใƒƒใ‚ฏใƒžใƒผใ‚ฏ"
flush: "ใ‚ญใƒฃใƒƒใ‚ทใƒฅใ‚’ใ‚ฏใƒชใ‚ข"

Expand Down
13 changes: 10 additions & 3 deletions src/client/app/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,20 @@
// Detect the user agent
const ua = navigator.userAgent.toLowerCase();
let isMobile = /mobile|iphone|ipad|android/.test(ua) || window.innerWidth < 576;
if (settings && settings.device.appTypeForce) {
if (settings.device.appTypeForce === 'mobile') {
if (settings && settings.device.appType) {
if (settings.device.appType === 'mobile') {
isMobile = true;
} else if (settings.device.appTypeForce === 'desktop') {
} else if (settings.device.appType === 'desktop') {
isMobile = false;
}
}
if (settings && settings.device.appTypeForce) {
if (settings.device.appTypeForce === 'mobile') {
isMobile = true;
} else if (settings.device.appTypeForce === 'desktop') {
isMobile = false;
}
}

// Get the <head> element
const head = document.getElementsByTagName('head')[0];
Expand Down
14 changes: 12 additions & 2 deletions src/client/app/desktop/views/components/ui.header.account.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@
<template v-else><span>{{ $t('@.deck') }}</span><i><fa :icon="faColumns"/></i></template>
</p>
</li>
<li v-if="$store.state.device.appTypeForce == 'auto'" @click="toggleAppType">
<p>
<template v-if="$root.isMobile"><span>{{ $t('@.desktop-mode') }}</span><i><fa :icon="faDesktop"/></i></template>
<template v-else><span>{{ $t('@.mobile-mode') }}</span><i><fa :icon="faMobileAlt" style="margin-right: 3px"/></i></template>
</p>
</li>
<li @click="dark">
<p>
<span>{{ $store.state.device.darkmode ? $t('@.turn-off-darkmode') : $t('@.turn-on-darkmode') }}</span>
Expand All @@ -113,15 +119,15 @@ import i18n from '../../../i18n';
// import MkSettingsWindow from './settings-window.vue';
import MkDriveWindow from './drive-window.vue';
import contains from '../../../common/scripts/contains';
import { faHome, faColumns, faUsers, faDoorOpen } from '@fortawesome/free-solid-svg-icons';
import { faHome, faColumns, faUsers, faDoorOpen, faDesktop, faMobileAlt } from '@fortawesome/free-solid-svg-icons';
import { faMoon, faSun, faStickyNote } from '@fortawesome/free-regular-svg-icons';

export default Vue.extend({
i18n: i18n('desktop/views/components/ui.header.account.vue'),
data() {
return {
isOpen: false,
faHome, faColumns, faMoon, faSun, faStickyNote, faUsers, faDoorOpen
faHome, faColumns, faMoon, faSun, faStickyNote, faUsers, faDoorOpen, faDesktop, faMobileAlt
};
},
computed: {
Expand Down Expand Up @@ -168,6 +174,10 @@ export default Vue.extend({
value: !this.$store.state.device.darkmode
});
},
toggleAppType() {
this.$store.commit('device/set', { key: 'appType', value: this.$root.isMobile ? 'desktop' : 'mobile' });
location.replace('/');
},
toggleDeckMode() {
this.$store.commit('device/set', { key: 'deckMode', value: !this.$store.state.device.inDeckMode });
location.replace('/');
Expand Down
13 changes: 11 additions & 2 deletions src/client/app/mobile/views/components/ui.nav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
</ul>
<ul>
<li @click="toggleDeckMode"><p><i><fa :icon="$store.state.device.inDeckMode ? faHome : faColumns" fixed-width/></i><span>{{ $store.state.device.inDeckMode ? $t('@.home') : $t('@.deck') }}</span></p></li>
<li v-if="$store.state.device.appTypeForce == 'auto'" @click="toggleAppType">
<p><i><fa :icon="$root.isMobile ? faDesktop : faMobileAlt" fixed-width/></i>
<span>{{ $root.isMobile ? $t('@.desktop-mode') : $t('@.mobile-mode') }}</span></p>
</li>
<li @click="dark"><p><i><fa :icon="$store.state.device.darkmode ? faSun : faMoon" fixed-width/></i><span>{{ $store.state.device.darkmode ? $t('@.turn-off-darkmode') : $t('@.turn-on-darkmode') }}</span></p></li>
</ul>
</div>
Expand Down Expand Up @@ -67,7 +71,7 @@
import Vue from 'vue';
import i18n from '../../../i18n';
import { lang, version, codename } from '../../../config';
import { faNewspaper, faHashtag, faHome, faColumns, faUsers } from '@fortawesome/free-solid-svg-icons';
import { faNewspaper, faHashtag, faHome, faColumns, faUsers, faDesktop, faMobileAlt } from '@fortawesome/free-solid-svg-icons';
import { faMoon, faSun, faStickyNote, faBell } from '@fortawesome/free-regular-svg-icons';
import { search } from '../../../common/scripts/search';

Expand All @@ -89,7 +93,7 @@ export default Vue.extend({
searching: false,
showNotifications: false,
version, codename,
faNewspaper, faHashtag, faMoon, faSun, faHome, faColumns, faStickyNote, faUsers, faBell,
faNewspaper, faHashtag, faMoon, faSun, faHome, faColumns, faStickyNote, faUsers, faBell, faDesktop, faMobileAlt
};
},

Expand Down Expand Up @@ -160,6 +164,11 @@ export default Vue.extend({
});
},

toggleAppType() {
this.$store.commit('device/set', { key: 'appType', value: this.$root.isMobile ? 'desktop' : 'mobile' });
location.replace('/');
},

toggleDeckMode() {
this.$store.commit('device/set', { key: 'deckMode', value: !this.$store.state.device.inDeckMode });
location.replace('/');
Expand Down
1 change: 1 addition & 0 deletions src/client/app/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const defaultDeviceSettings = {
roomUseOrthographicCamera: true,
activeEmojiCategoryName: undefined,
recentEmojis: [],
appType: 'auto',
};

export default (os: MiOS) => new Vuex.Store({
Expand Down