Skip to content

Commit

Permalink
feat: show tab header in one line (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
poppingmoon authored Oct 20, 2024
1 parent 8c03dcb commit c051c31
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/i18n/aria/aria.i18n.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ showShowPostFormFAB: "Show mini post form floating action button"
showStackTrace: "Show stack trace"
showSubNoteFooter: "Show action buttons in subnotes"
showSubNoteReactionsViewer: "Show reactions viewers in subnotes"
showTabHeaderInOneLine: "Show tab info in one line"
showTimelineLastViewedAt: "Show last viewed date of timelines"
showTimelineTabBarAtBottom: "Show timeline tab bar at the bottom"
showTranslateButtonInNoteFooter: "Add \"Translate\" to note action menu"
Expand Down
2 changes: 1 addition & 1 deletion lib/i18n/strings.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/// To regenerate, run: `dart run slang`
///
/// Locales: 31
/// Strings: 54605 (1761 per locale)
/// Strings: 54606 (1761 per locale)
// coverage:ignore-file
// ignore_for_file: type=lint
Expand Down
1 change: 1 addition & 0 deletions lib/i18n/strings_en_US.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class _StringsAriaEnUs {
String get showStackTrace => 'Show stack trace';
String get showSubNoteFooter => 'Show action buttons in subnotes';
String get showSubNoteReactionsViewer => 'Show reactions viewers in subnotes';
String get showTabHeaderInOneLine => 'Show tab info in one line';
String get showTimelineLastViewedAt => 'Show last viewed date of timelines';
String get showTimelineTabBarAtBottom => 'Show timeline tab bar at the bottom';
String get showTranslateButtonInNoteFooter => 'Add "Translate" to note action menu';
Expand Down
1 change: 1 addition & 0 deletions lib/model/general_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class GeneralSettings with _$GeneralSettings {
@Default(true) bool showHomeFAB,
@Default(true) bool showNotificationsFAB,
@Default(true) bool showShowPostFormFAB,
@Default(true) bool showTabHeaderInOneLine,
@Default(false) bool alwaysShowTabHeader,
@Default(true) bool showTimelineLastViewedAt,
@Default(true) bool showPopupOnNewNote,
Expand Down
24 changes: 23 additions & 1 deletion lib/model/general_settings.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ mixin _$GeneralSettings {
bool get showHomeFAB => throw _privateConstructorUsedError;
bool get showNotificationsFAB => throw _privateConstructorUsedError;
bool get showShowPostFormFAB => throw _privateConstructorUsedError;
bool get showTabHeaderInOneLine => throw _privateConstructorUsedError;
bool get alwaysShowTabHeader => throw _privateConstructorUsedError;
bool get showTimelineLastViewedAt => throw _privateConstructorUsedError;
bool get showPopupOnNewNote => throw _privateConstructorUsedError;
Expand Down Expand Up @@ -190,6 +191,7 @@ abstract class $GeneralSettingsCopyWith<$Res> {
bool showHomeFAB,
bool showNotificationsFAB,
bool showShowPostFormFAB,
bool showTabHeaderInOneLine,
bool alwaysShowTabHeader,
bool showTimelineLastViewedAt,
bool showPopupOnNewNote,
Expand Down Expand Up @@ -286,6 +288,7 @@ class _$GeneralSettingsCopyWithImpl<$Res, $Val extends GeneralSettings>
Object? showHomeFAB = null,
Object? showNotificationsFAB = null,
Object? showShowPostFormFAB = null,
Object? showTabHeaderInOneLine = null,
Object? alwaysShowTabHeader = null,
Object? showTimelineLastViewedAt = null,
Object? showPopupOnNewNote = null,
Expand Down Expand Up @@ -545,6 +548,10 @@ class _$GeneralSettingsCopyWithImpl<$Res, $Val extends GeneralSettings>
? _value.showShowPostFormFAB
: showShowPostFormFAB // ignore: cast_nullable_to_non_nullable
as bool,
showTabHeaderInOneLine: null == showTabHeaderInOneLine
? _value.showTabHeaderInOneLine
: showTabHeaderInOneLine // ignore: cast_nullable_to_non_nullable
as bool,
alwaysShowTabHeader: null == alwaysShowTabHeader
? _value.alwaysShowTabHeader
: alwaysShowTabHeader // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -699,6 +706,7 @@ abstract class _$$GeneralSettingsImplCopyWith<$Res>
bool showHomeFAB,
bool showNotificationsFAB,
bool showShowPostFormFAB,
bool showTabHeaderInOneLine,
bool alwaysShowTabHeader,
bool showTimelineLastViewedAt,
bool showPopupOnNewNote,
Expand Down Expand Up @@ -793,6 +801,7 @@ class __$$GeneralSettingsImplCopyWithImpl<$Res>
Object? showHomeFAB = null,
Object? showNotificationsFAB = null,
Object? showShowPostFormFAB = null,
Object? showTabHeaderInOneLine = null,
Object? alwaysShowTabHeader = null,
Object? showTimelineLastViewedAt = null,
Object? showPopupOnNewNote = null,
Expand Down Expand Up @@ -1052,6 +1061,10 @@ class __$$GeneralSettingsImplCopyWithImpl<$Res>
? _value.showShowPostFormFAB
: showShowPostFormFAB // ignore: cast_nullable_to_non_nullable
as bool,
showTabHeaderInOneLine: null == showTabHeaderInOneLine
? _value.showTabHeaderInOneLine
: showTabHeaderInOneLine // ignore: cast_nullable_to_non_nullable
as bool,
alwaysShowTabHeader: null == alwaysShowTabHeader
? _value.alwaysShowTabHeader
: alwaysShowTabHeader // ignore: cast_nullable_to_non_nullable
Expand Down Expand Up @@ -1201,6 +1214,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings {
this.showHomeFAB = true,
this.showNotificationsFAB = true,
this.showShowPostFormFAB = true,
this.showTabHeaderInOneLine = true,
this.alwaysShowTabHeader = false,
this.showTimelineLastViewedAt = true,
this.showPopupOnNewNote = true,
Expand Down Expand Up @@ -1407,6 +1421,9 @@ class _$GeneralSettingsImpl implements _GeneralSettings {
final bool showShowPostFormFAB;
@override
@JsonKey()
final bool showTabHeaderInOneLine;
@override
@JsonKey()
final bool alwaysShowTabHeader;
@override
@JsonKey()
Expand Down Expand Up @@ -1470,7 +1487,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings {

@override
String toString() {
return 'GeneralSettings(locale: $locale, collapseRenotes: $collapseRenotes, sensitive: $sensitive, highlightSensitiveMedia: $highlightSensitiveMedia, animatedMfm: $animatedMfm, advancedMfm: $advancedMfm, showReactionsCount: $showReactionsCount, loadRawImages: $loadRawImages, instanceTicker: $instanceTicker, showNoteCreatedAt: $showNoteCreatedAt, showAvatarsInNote: $showAvatarsInNote, showAvatarsInSubNote: $showAvatarsInSubNote, squareAvatars: $squareAvatars, showAvatarDecorations: $showAvatarDecorations, showQuoteButtonInNoteFooter: $showQuoteButtonInNoteFooter, showLikeButtonInNoteFooter: $showLikeButtonInNoteFooter, showClipButtonInNoteFooter: $showClipButtonInNoteFooter, showTranslateButtonInNoteFooter: $showTranslateButtonInNoteFooter, showNoteReactionsViewer: $showNoteReactionsViewer, showSubNoteReactionsViewer: $showSubNoteReactionsViewer, showNoteFooter: $showNoteFooter, showSubNoteFooter: $showSubNoteFooter, alwaysExpandCw: $alwaysExpandCw, alwaysExpandLongNote: $alwaysExpandLongNote, alwaysExpandMediaInSubNote: $alwaysExpandMediaInSubNote, mediaListWithOneImageAppearance: $mediaListWithOneImageAppearance, thumbnailBoxFit: $thumbnailBoxFit, emojiStyle: $emojiStyle, fontFamily: $fontFamily, fontSize: $fontSize, lineHeight: $lineHeight, avatarScale: $avatarScale, reactionsDisplayScale: $reactionsDisplayScale, limitWidthOfReaction: $limitWidthOfReaction, noteFooterScale: $noteFooterScale, noteVerticalPadding: $noteVerticalPadding, noteHorizontalPadding: $noteHorizontalPadding, publicNoteBackgroundColor: $publicNoteBackgroundColor, homeNoteBackgroundColor: $homeNoteBackgroundColor, followersNoteBackgroundColor: $followersNoteBackgroundColor, specifiedNoteBackgroundColor: $specifiedNoteBackgroundColor, emojiPickerUseDialog: $emojiPickerUseDialog, emojiPickerScale: $emojiPickerScale, emojiPickerAutofocus: $emojiPickerAutofocus, emojiPickerKeepOpen: $emojiPickerKeepOpen, dataSaverMedia: $dataSaverMedia, dataSaverAvatar: $dataSaverAvatar, dataSaverUrlPreview: $dataSaverUrlPreview, disableDataSaverWhenOnWifi: $disableDataSaverWhenOnWifi, reduceAnimation: $reduceAnimation, disableShowingAnimatedImages: $disableShowingAnimatedImages, enableEmojiFadeIn: $enableEmojiFadeIn, forceShowAds: $forceShowAds, useGroupedNotifications: $useGroupedNotifications, showTimelineTabBarAtBottom: $showTimelineTabBarAtBottom, showMenuButtonInTabBar: $showMenuButtonInTabBar, showHomeFAB: $showHomeFAB, showNotificationsFAB: $showNotificationsFAB, showShowPostFormFAB: $showShowPostFormFAB, alwaysShowTabHeader: $alwaysShowTabHeader, showTimelineLastViewedAt: $showTimelineLastViewedAt, showPopupOnNewNote: $showPopupOnNewNote, vibrateNote: $vibrateNote, vibrateNotification: $vibrateNotification, enableInfiniteScroll: $enableInfiniteScroll, keepScreenOn: $keepScreenOn, enableHorizontalSwipe: $enableHorizontalSwipe, openSensitiveMediaOnDoubleTap: $openSensitiveMediaOnDoubleTap, noteTapAction: $noteTapAction, noteDoubleTapAction: $noteDoubleTapAction, noteLongPressAction: $noteLongPressAction, confirmBeforePost: $confirmBeforePost, confirmBeforeReact: $confirmBeforeReact, confirmBeforeFollow: $confirmBeforeFollow, confirmWhenRevealingSensitiveMedia: $confirmWhenRevealingSensitiveMedia, launchMode: $launchMode, themeMode: $themeMode, lightThemeId: $lightThemeId, darkThemeId: $darkThemeId)';
return 'GeneralSettings(locale: $locale, collapseRenotes: $collapseRenotes, sensitive: $sensitive, highlightSensitiveMedia: $highlightSensitiveMedia, animatedMfm: $animatedMfm, advancedMfm: $advancedMfm, showReactionsCount: $showReactionsCount, loadRawImages: $loadRawImages, instanceTicker: $instanceTicker, showNoteCreatedAt: $showNoteCreatedAt, showAvatarsInNote: $showAvatarsInNote, showAvatarsInSubNote: $showAvatarsInSubNote, squareAvatars: $squareAvatars, showAvatarDecorations: $showAvatarDecorations, showQuoteButtonInNoteFooter: $showQuoteButtonInNoteFooter, showLikeButtonInNoteFooter: $showLikeButtonInNoteFooter, showClipButtonInNoteFooter: $showClipButtonInNoteFooter, showTranslateButtonInNoteFooter: $showTranslateButtonInNoteFooter, showNoteReactionsViewer: $showNoteReactionsViewer, showSubNoteReactionsViewer: $showSubNoteReactionsViewer, showNoteFooter: $showNoteFooter, showSubNoteFooter: $showSubNoteFooter, alwaysExpandCw: $alwaysExpandCw, alwaysExpandLongNote: $alwaysExpandLongNote, alwaysExpandMediaInSubNote: $alwaysExpandMediaInSubNote, mediaListWithOneImageAppearance: $mediaListWithOneImageAppearance, thumbnailBoxFit: $thumbnailBoxFit, emojiStyle: $emojiStyle, fontFamily: $fontFamily, fontSize: $fontSize, lineHeight: $lineHeight, avatarScale: $avatarScale, reactionsDisplayScale: $reactionsDisplayScale, limitWidthOfReaction: $limitWidthOfReaction, noteFooterScale: $noteFooterScale, noteVerticalPadding: $noteVerticalPadding, noteHorizontalPadding: $noteHorizontalPadding, publicNoteBackgroundColor: $publicNoteBackgroundColor, homeNoteBackgroundColor: $homeNoteBackgroundColor, followersNoteBackgroundColor: $followersNoteBackgroundColor, specifiedNoteBackgroundColor: $specifiedNoteBackgroundColor, emojiPickerUseDialog: $emojiPickerUseDialog, emojiPickerScale: $emojiPickerScale, emojiPickerAutofocus: $emojiPickerAutofocus, emojiPickerKeepOpen: $emojiPickerKeepOpen, dataSaverMedia: $dataSaverMedia, dataSaverAvatar: $dataSaverAvatar, dataSaverUrlPreview: $dataSaverUrlPreview, disableDataSaverWhenOnWifi: $disableDataSaverWhenOnWifi, reduceAnimation: $reduceAnimation, disableShowingAnimatedImages: $disableShowingAnimatedImages, enableEmojiFadeIn: $enableEmojiFadeIn, forceShowAds: $forceShowAds, useGroupedNotifications: $useGroupedNotifications, showTimelineTabBarAtBottom: $showTimelineTabBarAtBottom, showMenuButtonInTabBar: $showMenuButtonInTabBar, showHomeFAB: $showHomeFAB, showNotificationsFAB: $showNotificationsFAB, showShowPostFormFAB: $showShowPostFormFAB, showTabHeaderInOneLine: $showTabHeaderInOneLine, alwaysShowTabHeader: $alwaysShowTabHeader, showTimelineLastViewedAt: $showTimelineLastViewedAt, showPopupOnNewNote: $showPopupOnNewNote, vibrateNote: $vibrateNote, vibrateNotification: $vibrateNotification, enableInfiniteScroll: $enableInfiniteScroll, keepScreenOn: $keepScreenOn, enableHorizontalSwipe: $enableHorizontalSwipe, openSensitiveMediaOnDoubleTap: $openSensitiveMediaOnDoubleTap, noteTapAction: $noteTapAction, noteDoubleTapAction: $noteDoubleTapAction, noteLongPressAction: $noteLongPressAction, confirmBeforePost: $confirmBeforePost, confirmBeforeReact: $confirmBeforeReact, confirmBeforeFollow: $confirmBeforeFollow, confirmWhenRevealingSensitiveMedia: $confirmWhenRevealingSensitiveMedia, launchMode: $launchMode, themeMode: $themeMode, lightThemeId: $lightThemeId, darkThemeId: $darkThemeId)';
}

@override
Expand Down Expand Up @@ -1567,6 +1584,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings {
(identical(other.showHomeFAB, showHomeFAB) || other.showHomeFAB == showHomeFAB) &&
(identical(other.showNotificationsFAB, showNotificationsFAB) || other.showNotificationsFAB == showNotificationsFAB) &&
(identical(other.showShowPostFormFAB, showShowPostFormFAB) || other.showShowPostFormFAB == showShowPostFormFAB) &&
(identical(other.showTabHeaderInOneLine, showTabHeaderInOneLine) || other.showTabHeaderInOneLine == showTabHeaderInOneLine) &&
(identical(other.alwaysShowTabHeader, alwaysShowTabHeader) || other.alwaysShowTabHeader == alwaysShowTabHeader) &&
(identical(other.showTimelineLastViewedAt, showTimelineLastViewedAt) || other.showTimelineLastViewedAt == showTimelineLastViewedAt) &&
(identical(other.showPopupOnNewNote, showPopupOnNewNote) || other.showPopupOnNewNote == showPopupOnNewNote) &&
Expand Down Expand Up @@ -1652,6 +1670,7 @@ class _$GeneralSettingsImpl implements _GeneralSettings {
showHomeFAB,
showNotificationsFAB,
showShowPostFormFAB,
showTabHeaderInOneLine,
alwaysShowTabHeader,
showTimelineLastViewedAt,
showPopupOnNewNote,
Expand Down Expand Up @@ -1753,6 +1772,7 @@ abstract class _GeneralSettings implements GeneralSettings {
final bool showHomeFAB,
final bool showNotificationsFAB,
final bool showShowPostFormFAB,
final bool showTabHeaderInOneLine,
final bool alwaysShowTabHeader,
final bool showTimelineLastViewedAt,
final bool showPopupOnNewNote,
Expand Down Expand Up @@ -1903,6 +1923,8 @@ abstract class _GeneralSettings implements GeneralSettings {
@override
bool get showShowPostFormFAB;
@override
bool get showTabHeaderInOneLine;
@override
bool get alwaysShowTabHeader;
@override
bool get showTimelineLastViewedAt;
Expand Down
2 changes: 2 additions & 0 deletions lib/model/general_settings.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/provider/general_settings_notifier_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,11 @@ class GeneralSettingsNotifier extends _$GeneralSettingsNotifier {
await _save();
}

Future<void> setShowTabHeaderInOneLine(bool showTabHeaderInOneLine) async {
state = state.copyWith(showTabHeaderInOneLine: showTabHeaderInOneLine);
await _save();
}

Future<void> setAlwaysShowTabHeader(bool alwaysShowTabHeader) async {
state = state.copyWith(alwaysShowTabHeader: alwaysShowTabHeader);
await _save();
Expand Down
2 changes: 1 addition & 1 deletion lib/provider/general_settings_notifier_provider.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions lib/view/page/settings/appearance_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,13 @@ class AppearancePage extends HookConsumerWidget {
.read(generalSettingsNotifierProvider.notifier)
.setShowShowPostFormFAB(value),
),
SwitchListTile(
title: Text(t.aria.showTabHeaderInOneLine),
value: settings.showTabHeaderInOneLine,
onChanged: (value) => ref
.read(generalSettingsNotifierProvider.notifier)
.setShowTabHeaderInOneLine(value),
),
SwitchListTile(
title: Text(t.aria.alwaysShowTabHeader),
value: settings.alwaysShowTabHeader,
Expand Down
53 changes: 48 additions & 5 deletions lib/view/widget/timeline_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import 'package:tinycolor2/tinycolor2.dart';

import '../../i18n/strings.g.dart';
import '../../model/tab_settings.dart';
import '../../model/tab_type.dart';
import '../../provider/api/i_notifier_provider.dart';
import '../../provider/api/online_users_count_provider.dart';
import '../../provider/general_settings_notifier_provider.dart';
import '../../provider/timeline_scroll_controller_provider.dart';
import 'ad_widget.dart';
import 'streaming_error_icon.dart';
import 'tab_icon_widget.dart';
import 'tab_name_widget.dart';
import 'timeline_menu.dart';

class TimelineHeader extends HookConsumerWidget {
Expand All @@ -34,6 +34,10 @@ class TimelineHeader extends HookConsumerWidget {
generalSettingsNotifierProvider
.select((settings) => settings.alwaysShowTabHeader),
);
final oneLine = ref.watch(
generalSettingsNotifierProvider
.select((settings) => settings.showTabHeaderInOneLine),
);
final isMenuExpanded = useState(false);
final sizeFactor = useState(1.0);
useEffect(
Expand Down Expand Up @@ -92,12 +96,51 @@ class TimelineHeader extends HookConsumerWidget {
),
],
),
title: TabNameWidget(tabSettings: tabSettings),
subtitle: Text(
tabSettings.account.toString(),
title: Text.rich(
TextSpan(
children: [
TextSpan(
text: tabSettings.name ??
switch (tabSettings.tabType) {
TabType.homeTimeline => t.misskey.timelines_.home,
TabType.localTimeline => t.misskey.timelines_.local,
TabType.hybridTimeline => t.misskey.timelines_.social,
TabType.globalTimeline => t.misskey.timelines_.global,
TabType.roleTimeline => t.misskey.role,
TabType.userList => t.misskey.userList,
TabType.antenna => t.misskey.antennas,
TabType.channel => t.misskey.channel,
TabType.mention => t.misskey.mentions,
TabType.direct => t.misskey.directNotes,
TabType.user => t.misskey.user,
TabType.notifications => t.misskey.notifications,
TabType.custom => t.aria.custom,
},
),
if (oneLine) ...[
const WidgetSpan(child: SizedBox(width: 8.0)),
TextSpan(
text: tabSettings.account.toString(),
style: DefaultTextStyle.of(context).style.apply(
color: Theme.of(context)
.colorScheme
.onSurface
.withOpacity(0.85),
),
),
],
],
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
maxLines: oneLine ? 1 : null,
),
subtitle: !oneLine
? Text(
tabSettings.account.toString(),
overflow: TextOverflow.ellipsis,
maxLines: 1,
)
: null,
onExpansionChanged: (value) {
isMenuExpanded.value = value;
if (value) {
Expand Down
Loading

0 comments on commit c051c31

Please sign in to comment.