下タブバーの実装
This commit is contained in:
parent
d5ef4dff60
commit
d05a0c8fa3
@ -55,6 +55,8 @@ class Settings::PreferencesController < Settings::BaseController
|
|||||||
:setting_trends,
|
:setting_trends,
|
||||||
:setting_crop_images,
|
:setting_crop_images,
|
||||||
:setting_always_send_emails,
|
:setting_always_send_emails,
|
||||||
|
:setting_place_tab_bar_at_bottom,
|
||||||
|
:setting_show_tab_bar_label,
|
||||||
notification_emails: %i(follow follow_request reblog favourite mention report pending_account trending_tag appeal),
|
notification_emails: %i(follow follow_request reblog favourite mention report pending_account trending_tag appeal),
|
||||||
interactions: %i(must_be_follower must_be_following must_be_following_dm)
|
interactions: %i(must_be_follower must_be_following must_be_following_dm)
|
||||||
)
|
)
|
||||||
|
@ -21,8 +21,15 @@ import {
|
|||||||
} from '../../ui/util/async-components';
|
} from '../../ui/util/async-components';
|
||||||
import ComposePanel from './compose_panel';
|
import ComposePanel from './compose_panel';
|
||||||
import NavigationPanel from './navigation_panel';
|
import NavigationPanel from './navigation_panel';
|
||||||
|
import TabsBar from './tabs_bar';
|
||||||
|
import { place_tab_bar_at_bottom } from 'mastodon/initial_state';
|
||||||
import { supportsPassiveEvents } from 'detect-passive-events';
|
import { supportsPassiveEvents } from 'detect-passive-events';
|
||||||
import { scrollRight } from '../../../scroll';
|
import { scrollRight } from '../../../scroll';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import Icon from 'mastodon/components/icon';
|
||||||
|
|
||||||
|
const shouldHideFAB = path => path.match(/^\/statuses\/|^\/search|^\/getting-started/);
|
||||||
|
|
||||||
const componentMap = {
|
const componentMap = {
|
||||||
'COMPOSE': Compose,
|
'COMPOSE': Compose,
|
||||||
@ -138,26 +145,49 @@ export default class ColumnsArea extends ImmutablePureComponent {
|
|||||||
const { renderComposePanel } = this.state;
|
const { renderComposePanel } = this.state;
|
||||||
|
|
||||||
if (singleColumn) {
|
if (singleColumn) {
|
||||||
return (
|
if (place_tab_bar_at_bottom) {
|
||||||
<div className='columns-area__panels'>
|
return (
|
||||||
<div className='columns-area__panels__pane columns-area__panels__pane--compositional'>
|
<div className='columns-area__panels tab-ber-bottom'>
|
||||||
<div className='columns-area__panels__pane__inner'>
|
<div className='columns-area__panels__pane columns-area__panels__pane--compositional'>
|
||||||
{renderComposePanel && <ComposePanel />}
|
<div className='columns-area__panels__pane__inner'>
|
||||||
|
{renderComposePanel && <ComposePanel />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='columns-area__panels__main timeline'>
|
||||||
|
<div className='tabs-bar__wrapper'><div id='tabs-bar__portal' /></div>
|
||||||
|
<div className='columns-area columns-area--mobile'>{children}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='columns-area__panels__main navber'>
|
||||||
|
{location.pathname !== '/publish' && <Link to='/publish' className='button bottom_right'><Icon id='pencil' fixedWidth /></Link>}
|
||||||
|
<TabsBar key='tabs' />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<div className='columns-area__panels'>
|
||||||
|
<div className='columns-area__panels__pane columns-area__panels__pane--compositional'>
|
||||||
|
<div className='columns-area__panels__pane__inner'>
|
||||||
|
{renderComposePanel && <ComposePanel />}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='columns-area__panels__main'>
|
||||||
|
<div className='tabs-bar__wrapper'><div id='tabs-bar__portal' /></div>
|
||||||
|
<div className='columns-area columns-area--mobile'>{children}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className='columns-area__panels__pane columns-area__panels__pane--start columns-area__panels__pane--navigational'>
|
||||||
|
<div className='columns-area__panels__pane__inner'>
|
||||||
|
<NavigationPanel />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
<div className='columns-area__panels__main'>
|
}
|
||||||
<div className='tabs-bar__wrapper'><div id='tabs-bar__portal' /></div>
|
|
||||||
<div className='columns-area columns-area--mobile'>{children}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className='columns-area__panels__pane columns-area__panels__pane--start columns-area__panels__pane--navigational'>
|
|
||||||
<div className='columns-area__panels__pane__inner'>
|
|
||||||
<NavigationPanel />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
96
app/javascript/mastodon/features/ui/components/tabs_bar.js
Normal file
96
app/javascript/mastodon/features/ui/components/tabs_bar.js
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
import { NavLink, withRouter } from 'react-router-dom';
|
||||||
|
import { FormattedMessage, injectIntl } from 'react-intl';
|
||||||
|
import NotificationsCounterIcon from './notifications_counter_icon';
|
||||||
|
import { place_tab_bar_at_bottom, show_tab_bar_label } from 'mastodon/initial_state';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
import { debounce } from 'lodash';
|
||||||
|
import { isUserTouching } from '../../../is_mobile';
|
||||||
|
import Icon from 'mastodon/components/icon';
|
||||||
|
|
||||||
|
export const links = [
|
||||||
|
<NavLink className='tabs-bar__link' to='/home' data-preview-title-id='column.home' data-preview-icon='home' ><Icon id='home' fixedWidth /><span className='tabs-bar__link__full-label'><FormattedMessage id='tabs_bar.home' defaultMessage='Home' /></span><span className='tabs-bar__link__short-label'><FormattedMessage id='navigation_bar.short.home' defaultMessage='Home' /></span></NavLink>,
|
||||||
|
<NavLink className='tabs-bar__link' to='/notifications' data-preview-title-id='column.notifications' data-preview-icon='bell' ><NotificationsCounterIcon /><span className='tabs-bar__link__full-label'><FormattedMessage id='tabs_bar.notifications' defaultMessage='Notifications' /></span><span className='tabs-bar__link__short-label'><FormattedMessage id='navigation_bar.short.notifications' defaultMessage='Notif.' /></span></NavLink>,
|
||||||
|
<NavLink className='tabs-bar__link' to='/public/local' data-preview-title-id='column.community' data-preview-icon='users' ><Icon id='users' fixedWidth /><span className='tabs-bar__link__full-label'><FormattedMessage id='tabs_bar.local_timeline' defaultMessage='Federated' /></span><span className='tabs-bar__link__short-label'><FormattedMessage id='navigation_bar.short.local_timeline' defaultMessage='LTL' /></span></NavLink>,
|
||||||
|
<NavLink className='tabs-bar__link' exact to='/public' data-preview-title-id='column.public' data-preview-icon='globe' ><Icon id='globe' fixedWidth /><span className='tabs-bar__link__full-label'><FormattedMessage id='tabs_bar.federated_timeline' defaultMessage='Federated' /></span><span className='tabs-bar__link__short-label'><FormattedMessage id='navigation_bar.short.public_timeline' defaultMessage='FTL' /></span></NavLink>,
|
||||||
|
<NavLink className='tabs-bar__link optional' to='/search' data-preview-title-id='tabs_bar.search' data-preview-icon='bell' ><Icon id='search' fixedWidth /><span className='tabs-bar__link__full-label'><FormattedMessage id='tabs_bar.search' defaultMessage='Search' /></span><span className='tabs-bar__link__short-label'><FormattedMessage id='navigation_bar.short.search' defaultMessage='Search' /></span></NavLink>,
|
||||||
|
<NavLink className='tabs-bar__link hamburger' to='/getting-started' data-preview-title-id='getting_started.heading' data-preview-icon='bars' ><Icon id='bars' fixedWidth /></NavLink>,
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getIndex (path) {
|
||||||
|
return links.findIndex(link => link.props.to === path);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getLink (index) {
|
||||||
|
return links[index].props.to;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default @injectIntl
|
||||||
|
@withRouter
|
||||||
|
class TabsBar extends React.PureComponent {
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
history: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
setRef = ref => {
|
||||||
|
this.node = ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
handleClick = (e) => {
|
||||||
|
// Only apply optimization for touch devices, which we assume are slower
|
||||||
|
// We thus avoid the 250ms delay for non-touch devices and the lag for touch devices
|
||||||
|
if (isUserTouching()) {
|
||||||
|
e.preventDefault();
|
||||||
|
e.persist();
|
||||||
|
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
const tabs = Array(...this.node.querySelectorAll('.tabs-bar__link'));
|
||||||
|
const currentTab = tabs.find(tab => tab.classList.contains('active'));
|
||||||
|
const nextTab = tabs.find(tab => tab.contains(e.target));
|
||||||
|
const { props: { to } } = links[Array(...this.node.childNodes).indexOf(nextTab)];
|
||||||
|
|
||||||
|
|
||||||
|
if (currentTab !== nextTab) {
|
||||||
|
if (currentTab) {
|
||||||
|
currentTab.classList.remove('active');
|
||||||
|
}
|
||||||
|
|
||||||
|
const listener = debounce(() => {
|
||||||
|
nextTab.removeEventListener('transitionend', listener);
|
||||||
|
this.props.history.push(to);
|
||||||
|
}, 50);
|
||||||
|
|
||||||
|
nextTab.addEventListener('transitionend', listener);
|
||||||
|
nextTab.classList.add('active');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static contextTypes = {
|
||||||
|
router: PropTypes.object.isRequired,
|
||||||
|
identity: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
static propTypes = {
|
||||||
|
intl: PropTypes.object.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
render () {
|
||||||
|
const { intl: { formatMessage } } = this.props;
|
||||||
|
return (
|
||||||
|
<div className='tabs-bar__wrapper'>
|
||||||
|
<nav className={classNames('tabs-bar', { 'bottom-bar': place_tab_bar_at_bottom })} ref={this.setRef}>
|
||||||
|
{links.map(link => React.cloneElement(link, { key: link.props.to, className: classNames(link.props.className, { 'short-label': show_tab_bar_label }), onClick: this.handleClick, 'aria-label': formatMessage({ id: link.props['data-preview-title-id'] }) }))}
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div id='tabs-bar__portal' />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -135,5 +135,7 @@ export const version = getMeta('version');
|
|||||||
export const translationEnabled = getMeta('translation_enabled');
|
export const translationEnabled = getMeta('translation_enabled');
|
||||||
export const languages = initialState?.languages;
|
export const languages = initialState?.languages;
|
||||||
export const statusPageUrl = getMeta('status_page_url');
|
export const statusPageUrl = getMeta('status_page_url');
|
||||||
|
export const place_tab_bar_at_bottom = getMeta('place_tab_bar_at_bottom');
|
||||||
|
export const show_tab_bar_label = getMeta('show_tab_bar_label');
|
||||||
|
|
||||||
export default initialState;
|
export default initialState;
|
||||||
|
@ -23,3 +23,5 @@
|
|||||||
@import 'mastodon/dashboard';
|
@import 'mastodon/dashboard';
|
||||||
@import 'mastodon/rtl';
|
@import 'mastodon/rtl';
|
||||||
@import 'mastodon/accessibility';
|
@import 'mastodon/accessibility';
|
||||||
|
|
||||||
|
@import 'plugin';
|
34
app/javascript/styles/plugin.scss
Normal file
34
app/javascript/styles/plugin.scss
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// ここから下タブバーの実装
|
||||||
|
|
||||||
|
//投稿ボタン
|
||||||
|
.columns-area__panels__main .button.bottom_right {
|
||||||
|
position: fixed;
|
||||||
|
right: 18px;
|
||||||
|
bottom: 65px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 64px;
|
||||||
|
height: 64px;
|
||||||
|
font-size: 24px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-ber-bottom .timeline{
|
||||||
|
width:100%;
|
||||||
|
height: calc(100% - 55px);
|
||||||
|
margin: 0 0 50px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-ber-bottom .navber{
|
||||||
|
width:100%;
|
||||||
|
bottom: 0;
|
||||||
|
position: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.tab-ber-bottom .navber .tabs-bar__wrapper{
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
//ここまで下タブバーの実装
|
@ -39,6 +39,7 @@ class UserSettingsDecorator
|
|||||||
user.settings['trends'] = trends_preference if change?('setting_trends')
|
user.settings['trends'] = trends_preference if change?('setting_trends')
|
||||||
user.settings['crop_images'] = crop_images_preference if change?('setting_crop_images')
|
user.settings['crop_images'] = crop_images_preference if change?('setting_crop_images')
|
||||||
user.settings['always_send_emails'] = always_send_emails_preference if change?('setting_always_send_emails')
|
user.settings['always_send_emails'] = always_send_emails_preference if change?('setting_always_send_emails')
|
||||||
|
user.settings['place_tab_bar_at_bottom'] = place_tab_bar_at_bottom_preference if change?('setting_place_tab_bar_at_bottom')
|
||||||
end
|
end
|
||||||
|
|
||||||
def merged_notification_emails
|
def merged_notification_emails
|
||||||
@ -137,6 +138,14 @@ class UserSettingsDecorator
|
|||||||
boolean_cast_setting 'setting_always_send_emails'
|
boolean_cast_setting 'setting_always_send_emails'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def place_tab_bar_at_bottom_preference
|
||||||
|
boolean_cast_setting 'setting_place_tab_bar_at_bottom'
|
||||||
|
end
|
||||||
|
|
||||||
|
def show_tab_bar_label_preference
|
||||||
|
boolean_cast_setting 'setting_show_tab_bar_label'
|
||||||
|
end
|
||||||
|
|
||||||
def boolean_cast_setting(key)
|
def boolean_cast_setting(key)
|
||||||
ActiveModel::Type::Boolean.new.cast(settings[key])
|
ActiveModel::Type::Boolean.new.cast(settings[key])
|
||||||
end
|
end
|
||||||
|
@ -136,6 +136,7 @@ class User < ApplicationRecord
|
|||||||
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
:expand_spoilers, :default_language, :aggregate_reblogs, :show_application,
|
||||||
:advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
|
:advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images,
|
||||||
:disable_swiping, :always_send_emails,
|
:disable_swiping, :always_send_emails,
|
||||||
|
:place_tab_bar_at_bottom,
|
||||||
to: :settings, prefix: :setting, allow_nil: false
|
to: :settings, prefix: :setting, allow_nil: false
|
||||||
|
|
||||||
delegate :can?, to: :role
|
delegate :can?, to: :role
|
||||||
|
@ -51,6 +51,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
|||||||
store[:use_pending_items] = object.current_account.user.setting_use_pending_items
|
store[:use_pending_items] = object.current_account.user.setting_use_pending_items
|
||||||
store[:trends] = Setting.trends && object.current_account.user.setting_trends
|
store[:trends] = Setting.trends && object.current_account.user.setting_trends
|
||||||
store[:crop_images] = object.current_account.user.setting_crop_images
|
store[:crop_images] = object.current_account.user.setting_crop_images
|
||||||
|
store[:place_tab_bar_at_bottom] = object.current_account.user.setting_place_tab_bar_at_bottom
|
||||||
else
|
else
|
||||||
store[:auto_play_gif] = Setting.auto_play_gif
|
store[:auto_play_gif] = Setting.auto_play_gif
|
||||||
store[:display_media] = Setting.display_media
|
store[:display_media] = Setting.display_media
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
%html{ lang: I18n.locale }
|
%html{ lang: I18n.locale }
|
||||||
%head
|
%head
|
||||||
%meta{ charset: 'utf-8' }/
|
%meta{ charset: 'utf-8' }/
|
||||||
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1' }/
|
%meta{ name: 'viewport', content: 'width=device-width, initial-scale=1, viewport-fit=cover'}/
|
||||||
|
|
||||||
- if cdn_host?
|
- if cdn_host?
|
||||||
%link{ rel: 'dns-prefetch', href: cdn_host }/
|
%link{ rel: 'dns-prefetch', href: cdn_host }/
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
|
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
|
||||||
= f.input :setting_disable_swiping, as: :boolean, wrapper: :with_label
|
= f.input :setting_disable_swiping, as: :boolean, wrapper: :with_label
|
||||||
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
|
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
|
||||||
|
= f.input :setting_place_tab_bar_at_bottom, as: :boolean, wrapper: :with_label
|
||||||
|
|
||||||
%h4= t 'appearance.toot_layout'
|
%h4= t 'appearance.toot_layout'
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ en:
|
|||||||
setting_display_media_show_all: Always show media
|
setting_display_media_show_all: Always show media
|
||||||
setting_hide_network: Who you follow and who follows you will be hidden on your profile
|
setting_hide_network: Who you follow and who follows you will be hidden on your profile
|
||||||
setting_noindex: Affects your public profile and post pages
|
setting_noindex: Affects your public profile and post pages
|
||||||
|
setting_place_tab_bar_at_bottom: Place the tab bar at the bottom
|
||||||
setting_show_application: The application you use to post will be displayed in the detailed view of your posts
|
setting_show_application: The application you use to post will be displayed in the detailed view of your posts
|
||||||
setting_use_blurhash: Gradients are based on the colors of the hidden visuals but obfuscate any details
|
setting_use_blurhash: Gradients are based on the colors of the hidden visuals but obfuscate any details
|
||||||
setting_use_pending_items: Hide timeline updates behind a click instead of automatically scrolling the feed
|
setting_use_pending_items: Hide timeline updates behind a click instead of automatically scrolling the feed
|
||||||
|
@ -209,6 +209,7 @@ ja:
|
|||||||
setting_expand_spoilers: 閲覧注意としてマークされたトゥートを常に展開する
|
setting_expand_spoilers: 閲覧注意としてマークされたトゥートを常に展開する
|
||||||
setting_hide_network: 繋がりを隠す
|
setting_hide_network: 繋がりを隠す
|
||||||
setting_noindex: 検索エンジンによるインデックスを拒否する
|
setting_noindex: 検索エンジンによるインデックスを拒否する
|
||||||
|
setting_place_tab_bar_at_bottom: タブバーを下に配置する
|
||||||
setting_reduce_motion: アニメーションの動きを減らす
|
setting_reduce_motion: アニメーションの動きを減らす
|
||||||
setting_show_application: 送信したアプリを開示する
|
setting_show_application: 送信したアプリを開示する
|
||||||
setting_system_font_ui: システムのデフォルトフォントを使う
|
setting_system_font_ui: システムのデフォルトフォントを使う
|
||||||
|
@ -38,6 +38,7 @@ defaults: &defaults
|
|||||||
trends_as_landing_page: true
|
trends_as_landing_page: true
|
||||||
trendable_by_default: false
|
trendable_by_default: false
|
||||||
crop_images: true
|
crop_images: true
|
||||||
|
place_tab_bar_at_bottom: false
|
||||||
notification_emails:
|
notification_emails:
|
||||||
follow: true
|
follow: true
|
||||||
reblog: false
|
reblog: false
|
||||||
|
Loading…
Reference in New Issue
Block a user