refactor: ui improvement in appearance (#3553)

This commit is contained in:
Mayur Mahajan 2023-10-05 07:18:19 +05:30 committed by GitHub
parent eb20c7c117
commit 40dcd13394
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 35 deletions

View File

@ -17,36 +17,37 @@ class BrightnessSetting extends StatelessWidget {
const BrightnessSetting({required this.currentThemeMode, super.key}); const BrightnessSetting({required this.currentThemeMode, super.key});
@override @override
Widget build(BuildContext context) => FlowyTooltip.delayed( Widget build(BuildContext context) {
richMessage: themeModeTooltipTextSpan( return FlowyTooltip.delayed(
context, margin: const EdgeInsets.only(left: 180),
LocaleKeys.settings_appearance_themeMode_label.tr(), richMessage: themeModeTooltipTextSpan(
), LocaleKeys.settings_appearance_themeMode_label.tr(),
child: ThemeSettingEntryTemplateWidget( ),
label: LocaleKeys.settings_appearance_themeMode_label.tr(), child: ThemeSettingEntryTemplateWidget(
onResetRequested: label: LocaleKeys.settings_appearance_themeMode_label.tr(),
context.read<AppearanceSettingsCubit>().resetThemeMode, onResetRequested:
trailing: [ context.read<AppearanceSettingsCubit>().resetThemeMode,
ThemeValueDropDown( trailing: [
currentValue: _themeModeLabelText(currentThemeMode), ThemeValueDropDown(
popupBuilder: (context) => Column( currentValue: _themeModeLabelText(currentThemeMode),
mainAxisSize: MainAxisSize.min, popupBuilder: (context) => Column(
children: [ mainAxisSize: MainAxisSize.min,
_themeModeItemButton(context, ThemeMode.light), children: [
_themeModeItemButton(context, ThemeMode.dark), _themeModeItemButton(context, ThemeMode.light),
_themeModeItemButton(context, ThemeMode.system), _themeModeItemButton(context, ThemeMode.dark),
], _themeModeItemButton(context, ThemeMode.system),
), ],
), ),
], ),
), ],
); ),
);
}
TextSpan themeModeTooltipTextSpan(BuildContext context, String hintText) => TextSpan themeModeTooltipTextSpan(String hintText) => TextSpan(
TextSpan(
children: [ children: [
TextSpan( TextSpan(
text: "$hintText\n", text: "${LocaleKeys.settings_files_change.tr()} $hintText\n",
), ),
TextSpan( TextSpan(
text: Platform.isMacOS ? "⌘+Shift+L" : "Ctrl+Shift+L", text: Platform.isMacOS ? "⌘+Shift+L" : "Ctrl+Shift+L",

View File

@ -25,17 +25,27 @@ class SettingsAppearanceView extends StatelessWidget {
currentTheme: state.appTheme.themeName, currentTheme: state.appTheme.themeName,
bloc: context.read<DynamicPluginBloc>(), bloc: context.read<DynamicPluginBloc>(),
), ),
BrightnessSetting(currentThemeMode: state.themeMode), BrightnessSetting(
currentThemeMode: state.themeMode,
),
const Divider(), const Divider(),
ThemeFontFamilySetting(currentFontFamily: state.font), ThemeFontFamilySetting(
currentFontFamily: state.font,
),
const Divider(), const Divider(),
LayoutDirectionSetting( LayoutDirectionSetting(
currentLayoutDirection: state.layoutDirection, currentLayoutDirection: state.layoutDirection,
), ),
TextDirectionSetting(currentTextDirection: state.textDirection), TextDirectionSetting(
currentTextDirection: state.textDirection,
),
const Divider(), const Divider(),
DateFormatSetting(currentFormat: state.dateFormat), DateFormatSetting(
TimeFormatSetting(currentFormat: state.timeFormat), currentFormat: state.dateFormat,
),
TimeFormatSetting(
currentFormat: state.timeFormat,
),
const Divider(), const Divider(),
CreateFileSettings(), CreateFileSettings(),
], ],

View File

@ -19,6 +19,9 @@ class SettingsMenu extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final bool showSyncSetting = isCloudEnabled &&
context.read<SettingsDialogBloc>().state.userProfile.authType !=
AuthTypePB.Local;
return Column( return Column(
children: [ children: [
SettingsMenuElement( SettingsMenuElement(
@ -58,11 +61,12 @@ class SettingsMenu extends StatelessWidget {
icon: Icons.account_box_outlined, icon: Icons.account_box_outlined,
changeSelectedPage: changeSelectedPage, changeSelectedPage: changeSelectedPage,
), ),
if (showSyncSetting)
const SizedBox(
height: 10,
),
// Only show supabase setting if supabase is enabled and the current auth type is not local // Only show supabase setting if supabase is enabled and the current auth type is not local
if (isCloudEnabled && if (showSyncSetting)
context.read<SettingsDialogBloc>().state.userProfile.authType !=
AuthTypePB.Local)
SettingsMenuElement( SettingsMenuElement(
page: SettingsPage.syncSetting, page: SettingsPage.syncSetting,
selectedPage: currentPage, selectedPage: currentPage,

View File

@ -9,8 +9,10 @@ class FlowyTooltip {
bool? preferBelow, bool? preferBelow,
Duration? showDuration, Duration? showDuration,
Widget? child, Widget? child,
EdgeInsetsGeometry? margin,
}) { }) {
return Tooltip( return Tooltip(
margin: margin,
waitDuration: _tooltipWaitDuration, waitDuration: _tooltipWaitDuration,
message: message, message: message,
richMessage: richMessage, richMessage: richMessage,