Add option to hide tooltips

This commit is contained in:
Hillel Coren 2022-05-12 18:39:43 +03:00
parent cfb0d8ded7
commit ffe2a300e4
8 changed files with 89 additions and 26 deletions

View File

@ -150,6 +150,7 @@ class UpdateUserPreferences implements PersistPrefs {
this.showPdfPreview, this.showPdfPreview,
this.editAfterSaving, this.editAfterSaving,
this.enableTouchEvents, this.enableTouchEvents,
this.enableTooltips,
}); });
final AppLayout appLayout; final AppLayout appLayout;
@ -175,6 +176,7 @@ class UpdateUserPreferences implements PersistPrefs {
final BuiltMap<String, String> customColors; final BuiltMap<String, String> customColors;
final bool editAfterSaving; final bool editAfterSaving;
final bool enableTouchEvents; final bool enableTouchEvents;
final bool enableTooltips;
} }
class LoadAccountSuccess implements StopLoading { class LoadAccountSuccess implements StopLoading {

View File

@ -62,6 +62,7 @@ PrefState prefReducer(
..isHistoryVisible = historyVisibleReducer(state.isHistoryVisible, action) ..isHistoryVisible = historyVisibleReducer(state.isHistoryVisible, action)
..enableDarkMode = darkModeReducer(state.enableDarkMode, action) ..enableDarkMode = darkModeReducer(state.enableDarkMode, action)
..enableJSPDF = enableJspdfReducer(state.enableJSPDF, action) ..enableJSPDF = enableJspdfReducer(state.enableJSPDF, action)
..enableTooltips = enableTooltipsReducer(state.enableTooltips, action)
..persistData = persistDataReducer(state.persistData, action) ..persistData = persistDataReducer(state.persistData, action)
..persistUI = persistUIReducer(state.persistUI, action) ..persistUI = persistUIReducer(state.persistUI, action)
..showKanban = showKanbanReducer(state.showKanban, action) ..showKanban = showKanbanReducer(state.showKanban, action)
@ -282,6 +283,12 @@ Reducer<bool> enableJspdfReducer = combineReducers([
}), }),
]); ]);
Reducer<bool> enableTooltipsReducer = combineReducers([
TypedReducer<bool, UpdateUserPreferences>((enableTooltips, action) {
return action.enableTooltips ?? enableTooltips;
}),
]);
Reducer<bool> persistDataReducer = combineReducers([ Reducer<bool> persistDataReducer = combineReducers([
TypedReducer<bool, UpdateUserPreferences>((persistData, action) { TypedReducer<bool, UpdateUserPreferences>((persistData, action) {
return action.persistData ?? persistData; return action.persistData ?? persistData;

View File

@ -30,6 +30,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
requireAuthentication: false, requireAuthentication: false,
colorTheme: kColorThemeLight, colorTheme: kColorThemeLight,
enableTouchEvents: true, enableTouchEvents: true,
enableTooltips: true,
enableJSPDF: false, enableJSPDF: false,
isFilterVisible: false, isFilterVisible: false,
textScaleFactor: 1, textScaleFactor: 1,
@ -132,6 +133,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
int get rowsPerPage; int get rowsPerPage;
bool get enableTooltips;
String get colorTheme; String get colorTheme;
bool get hideDesktopWarning; bool get hideDesktopWarning;
@ -210,6 +213,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
..showPdfPreview = true ..showPdfPreview = true
..enableTouchEvents = true ..enableTouchEvents = true
..enableJSPDF = false ..enableJSPDF = false
..enableTooltips = true
..textScaleFactor = 1 ..textScaleFactor = 1
..colorTheme = ..colorTheme =
builder.enableDarkMode == true ? kColorThemeLight : kColorThemeLight; builder.enableDarkMode == true ? kColorThemeLight : kColorThemeLight;

View File

@ -178,6 +178,9 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
'rowsPerPage', 'rowsPerPage',
serializers.serialize(object.rowsPerPage, serializers.serialize(object.rowsPerPage,
specifiedType: const FullType(int)), specifiedType: const FullType(int)),
'enableTooltips',
serializers.serialize(object.enableTooltips,
specifiedType: const FullType(bool)),
'colorTheme', 'colorTheme',
serializers.serialize(object.colorTheme, serializers.serialize(object.colorTheme,
specifiedType: const FullType(String)), specifiedType: const FullType(String)),
@ -304,6 +307,10 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
result.rowsPerPage = serializers.deserialize(value, result.rowsPerPage = serializers.deserialize(value,
specifiedType: const FullType(int)) as int; specifiedType: const FullType(int)) as int;
break; break;
case 'enableTooltips':
result.enableTooltips = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'colorTheme': case 'colorTheme':
result.colorTheme = serializers.deserialize(value, result.colorTheme = serializers.deserialize(value,
specifiedType: const FullType(String)) as String; specifiedType: const FullType(String)) as String;
@ -607,6 +614,8 @@ class _$PrefState extends PrefState {
@override @override
final int rowsPerPage; final int rowsPerPage;
@override @override
final bool enableTooltips;
@override
final String colorTheme; final String colorTheme;
@override @override
final bool hideDesktopWarning; final bool hideDesktopWarning;
@ -644,6 +653,7 @@ class _$PrefState extends PrefState {
this.tapSelectedToEdit, this.tapSelectedToEdit,
this.enableJSPDF, this.enableJSPDF,
this.rowsPerPage, this.rowsPerPage,
this.enableTooltips,
this.colorTheme, this.colorTheme,
this.hideDesktopWarning, this.hideDesktopWarning,
this.editAfterSaving, this.editAfterSaving,
@ -691,6 +701,8 @@ class _$PrefState extends PrefState {
enableJSPDF, 'PrefState', 'enableJSPDF'); enableJSPDF, 'PrefState', 'enableJSPDF');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
rowsPerPage, 'PrefState', 'rowsPerPage'); rowsPerPage, 'PrefState', 'rowsPerPage');
BuiltValueNullFieldError.checkNotNull(
enableTooltips, 'PrefState', 'enableTooltips');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
colorTheme, 'PrefState', 'colorTheme'); colorTheme, 'PrefState', 'colorTheme');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -737,6 +749,7 @@ class _$PrefState extends PrefState {
tapSelectedToEdit == other.tapSelectedToEdit && tapSelectedToEdit == other.tapSelectedToEdit &&
enableJSPDF == other.enableJSPDF && enableJSPDF == other.enableJSPDF &&
rowsPerPage == other.rowsPerPage && rowsPerPage == other.rowsPerPage &&
enableTooltips == other.enableTooltips &&
colorTheme == other.colorTheme && colorTheme == other.colorTheme &&
hideDesktopWarning == other.hideDesktopWarning && hideDesktopWarning == other.hideDesktopWarning &&
editAfterSaving == other.editAfterSaving && editAfterSaving == other.editAfterSaving &&
@ -766,20 +779,20 @@ class _$PrefState extends PrefState {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc($jc($jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), historySidebarMode.hashCode), useSidebarEditor.hashCode), customColors.hashCode), isPreviewVisible.hashCode), isMenuVisible.hashCode), $jc($jc($jc($jc($jc($jc($jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), historySidebarMode.hashCode), useSidebarEditor.hashCode), customColors.hashCode), isPreviewVisible.hashCode), isMenuVisible.hashCode), showKanban.hashCode),
showKanban.hashCode), showPdfPreview.hashCode),
showPdfPreview.hashCode), enableTouchEvents.hashCode),
enableTouchEvents.hashCode), isHistoryVisible.hashCode),
isHistoryVisible.hashCode), enableDarkMode.hashCode),
enableDarkMode.hashCode), isFilterVisible.hashCode),
isFilterVisible.hashCode), persistData.hashCode),
persistData.hashCode), persistUI.hashCode),
persistUI.hashCode), longPressSelectionIsDefault.hashCode),
longPressSelectionIsDefault.hashCode), requireAuthentication.hashCode),
requireAuthentication.hashCode), tapSelectedToEdit.hashCode),
tapSelectedToEdit.hashCode), enableJSPDF.hashCode),
enableJSPDF.hashCode), rowsPerPage.hashCode),
rowsPerPage.hashCode), enableTooltips.hashCode),
colorTheme.hashCode), colorTheme.hashCode),
hideDesktopWarning.hashCode), hideDesktopWarning.hashCode),
editAfterSaving.hashCode), editAfterSaving.hashCode),
@ -812,6 +825,7 @@ class _$PrefState extends PrefState {
..add('tapSelectedToEdit', tapSelectedToEdit) ..add('tapSelectedToEdit', tapSelectedToEdit)
..add('enableJSPDF', enableJSPDF) ..add('enableJSPDF', enableJSPDF)
..add('rowsPerPage', rowsPerPage) ..add('rowsPerPage', rowsPerPage)
..add('enableTooltips', enableTooltips)
..add('colorTheme', colorTheme) ..add('colorTheme', colorTheme)
..add('hideDesktopWarning', hideDesktopWarning) ..add('hideDesktopWarning', hideDesktopWarning)
..add('editAfterSaving', editAfterSaving) ..add('editAfterSaving', editAfterSaving)
@ -926,6 +940,11 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
int get rowsPerPage => _$this._rowsPerPage; int get rowsPerPage => _$this._rowsPerPage;
set rowsPerPage(int rowsPerPage) => _$this._rowsPerPage = rowsPerPage; set rowsPerPage(int rowsPerPage) => _$this._rowsPerPage = rowsPerPage;
bool _enableTooltips;
bool get enableTooltips => _$this._enableTooltips;
set enableTooltips(bool enableTooltips) =>
_$this._enableTooltips = enableTooltips;
String _colorTheme; String _colorTheme;
String get colorTheme => _$this._colorTheme; String get colorTheme => _$this._colorTheme;
set colorTheme(String colorTheme) => _$this._colorTheme = colorTheme; set colorTheme(String colorTheme) => _$this._colorTheme = colorTheme;
@ -985,6 +1004,7 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
_tapSelectedToEdit = $v.tapSelectedToEdit; _tapSelectedToEdit = $v.tapSelectedToEdit;
_enableJSPDF = $v.enableJSPDF; _enableJSPDF = $v.enableJSPDF;
_rowsPerPage = $v.rowsPerPage; _rowsPerPage = $v.rowsPerPage;
_enableTooltips = $v.enableTooltips;
_colorTheme = $v.colorTheme; _colorTheme = $v.colorTheme;
_hideDesktopWarning = $v.hideDesktopWarning; _hideDesktopWarning = $v.hideDesktopWarning;
_editAfterSaving = $v.editAfterSaving; _editAfterSaving = $v.editAfterSaving;
@ -1042,6 +1062,7 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
tapSelectedToEdit: BuiltValueNullFieldError.checkNotNull(tapSelectedToEdit, 'PrefState', 'tapSelectedToEdit'), tapSelectedToEdit: BuiltValueNullFieldError.checkNotNull(tapSelectedToEdit, 'PrefState', 'tapSelectedToEdit'),
enableJSPDF: BuiltValueNullFieldError.checkNotNull(enableJSPDF, 'PrefState', 'enableJSPDF'), enableJSPDF: BuiltValueNullFieldError.checkNotNull(enableJSPDF, 'PrefState', 'enableJSPDF'),
rowsPerPage: BuiltValueNullFieldError.checkNotNull(rowsPerPage, 'PrefState', 'rowsPerPage'), rowsPerPage: BuiltValueNullFieldError.checkNotNull(rowsPerPage, 'PrefState', 'rowsPerPage'),
enableTooltips: BuiltValueNullFieldError.checkNotNull(enableTooltips, 'PrefState', 'enableTooltips'),
colorTheme: BuiltValueNullFieldError.checkNotNull(colorTheme, 'PrefState', 'colorTheme'), colorTheme: BuiltValueNullFieldError.checkNotNull(colorTheme, 'PrefState', 'colorTheme'),
hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, 'PrefState', 'hideDesktopWarning'), hideDesktopWarning: BuiltValueNullFieldError.checkNotNull(hideDesktopWarning, 'PrefState', 'hideDesktopWarning'),
editAfterSaving: BuiltValueNullFieldError.checkNotNull(editAfterSaving, 'PrefState', 'editAfterSaving'), editAfterSaving: BuiltValueNullFieldError.checkNotNull(editAfterSaving, 'PrefState', 'editAfterSaving'),

View File

@ -663,7 +663,7 @@ class _DrawerTileState extends State<DrawerTile> {
); );
} else if (userCompany.canCreate(widget.entityType)) { } else if (userCompany.canCreate(widget.entityType)) {
trailingWidget = IconButton( trailingWidget = IconButton(
tooltip: widget.iconTooltip, tooltip: prefState.enableTooltips ? widget.iconTooltip : null,
icon: Icon( icon: Icon(
Icons.add_circle_outline, Icons.add_circle_outline,
color: textColor, color: textColor,
@ -769,6 +769,7 @@ class SidebarFooter extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final store = StoreProvider.of<AppState>(context); final store = StoreProvider.of<AppState>(context);
final state = store.state; final state = store.state;
final prefState = state.prefState;
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
final account = state.userCompany.account; final account = state.userCompany.account;
@ -784,7 +785,7 @@ class SidebarFooter extends StatelessWidget {
if (!Config.DEMO_MODE && !state.isDemo) if (!Config.DEMO_MODE && !state.isDemo)
if (state.isSelfHosted && !account.isSchedulerRunning) if (state.isSelfHosted && !account.isSchedulerRunning)
IconButton( IconButton(
tooltip: localization.error, tooltip: prefState.enableTooltips ? localization.error : '',
icon: Icon( icon: Icon(
Icons.warning, Icons.warning,
color: Colors.red, color: Colors.red,
@ -811,7 +812,7 @@ class SidebarFooter extends StatelessWidget {
) )
else if (state.credentials.token.isEmpty) else if (state.credentials.token.isEmpty)
IconButton( IconButton(
tooltip: localization.error, tooltip: prefState.enableTooltips ? localization.error : '',
icon: Icon( icon: Icon(
Icons.warning, Icons.warning,
color: Colors.red, color: Colors.red,
@ -823,7 +824,9 @@ class SidebarFooter extends StatelessWidget {
) )
else if (state.isSelfHosted && state.isUpdateAvailable) else if (state.isSelfHosted && state.isUpdateAvailable)
IconButton( IconButton(
tooltip: localization.updateAvailable, tooltip: prefState.enableTooltips
? localization.updateAvailable
: '',
icon: Icon( icon: Icon(
Icons.warning, Icons.warning,
color: Theme.of(context).colorScheme.secondary, color: Theme.of(context).colorScheme.secondary,
@ -881,12 +884,13 @@ class SidebarFooter extends StatelessWidget {
IconButton( IconButton(
icon: Icon(Icons.mail), icon: Icon(Icons.mail),
onPressed: () => _showContactUs(context), onPressed: () => _showContactUs(context),
tooltip: localization.contactUs, tooltip: prefState.enableTooltips ? localization.contactUs : '',
), ),
IconButton( IconButton(
icon: Icon(Icons.forum), icon: Icon(Icons.forum),
onPressed: () => launch(kForumUrl), onPressed: () => launch(kForumUrl),
tooltip: localization.supportForum, tooltip:
prefState.enableTooltips ? localization.supportForum : '',
), ),
IconButton( IconButton(
icon: Icon(Icons.help_outline), icon: Icon(Icons.help_outline),
@ -912,13 +916,13 @@ class SidebarFooter extends StatelessWidget {
launch(url); launch(url);
}, },
tooltip: localization.userGuide, tooltip: prefState.enableTooltips ? localization.userGuide : '',
), ),
IconButton( IconButton(
icon: Icon(Icons.info_outline), icon: Icon(Icons.info_outline),
// prevent the modal from being stuck over the pdf // prevent the modal from being stuck over the pdf
onPressed: () => _showAbout(context), onPressed: () => _showAbout(context),
tooltip: localization.about, tooltip: prefState.enableTooltips ? localization.about : '',
), ),
/* /*
if (kDebugMode) if (kDebugMode)
@ -937,7 +941,7 @@ class SidebarFooter extends StatelessWidget {
Icons.warning, Icons.warning,
color: Colors.red, color: Colors.red,
), ),
tooltip: localization.error, tooltip: prefState.enableTooltips ? localization.error : '',
onPressed: () => showDialog<ErrorDialog>( onPressed: () => showDialog<ErrorDialog>(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@ -953,7 +957,8 @@ class SidebarFooter extends StatelessWidget {
AppBorder( AppBorder(
isLeft: true, isLeft: true,
child: Tooltip( child: Tooltip(
message: localization.hideMenu, message:
prefState.enableTooltips ? localization.hideMenu : '',
child: InkWell( child: InkWell(
onTap: () => store.dispatch( onTap: () => store.dispatch(
UpdateUserPreferences(sidebar: AppSidebar.menu)), UpdateUserPreferences(sidebar: AppSidebar.menu)),
@ -1047,7 +1052,8 @@ class SidebarFooterCollapsed extends StatelessWidget {
Icons.chevron_right, Icons.chevron_right,
color: state.isUpdateAvailable ? state.accentColor : null, color: state.isUpdateAvailable ? state.accentColor : null,
), ),
tooltip: localization.showMenu, tooltip:
state.prefState.enableTooltips ? localization.showMenu : null,
onPressed: () { onPressed: () {
store.dispatch(UpdateUserPreferences(sidebar: AppSidebar.menu)); store.dispatch(UpdateUserPreferences(sidebar: AppSidebar.menu));
}, },

View File

@ -233,6 +233,15 @@ class _DeviceSettingsState extends State<DeviceSettings>
}, },
), ),
if (isDesktop(context)) ...[ if (isDesktop(context)) ...[
SwitchListTile(
title: Text(localization.enableTooltips),
subtitle: Text(localization.enableTooltipsHelp),
value: prefState.enableTooltips,
onChanged: (value) =>
viewModel.onEnableTooltipsChanged(context, value),
activeColor: Theme.of(context).colorScheme.secondary,
secondary: Icon(MdiIcons.tooltip),
),
SwitchListTile( SwitchListTile(
title: Text(localization.enableTouchEvents), title: Text(localization.enableTouchEvents),
subtitle: Text(localization.enableTouchEventsHelp), subtitle: Text(localization.enableTouchEventsHelp),

View File

@ -59,6 +59,7 @@ class DeviceSettingsVM {
@required this.onTextScaleFactorChanged, @required this.onTextScaleFactorChanged,
@required this.onEditAfterSavingChanged, @required this.onEditAfterSavingChanged,
@required this.onEnableTouchEventsChanged, @required this.onEnableTouchEventsChanged,
@required this.onEnableTooltipsChanged,
}); });
static DeviceSettingsVM fromStore(Store<AppState> store) { static DeviceSettingsVM fromStore(Store<AppState> store) {
@ -116,6 +117,9 @@ class DeviceSettingsVM {
onTextScaleFactorChanged: (context, value) { onTextScaleFactorChanged: (context, value) {
store.dispatch(UpdateUserPreferences(textScaleFactor: value)); store.dispatch(UpdateUserPreferences(textScaleFactor: value));
}, },
onEnableTooltipsChanged: (context, value) {
store.dispatch(UpdateUserPreferences(enableTooltips: value));
},
onColorThemeChanged: (context, value) async { onColorThemeChanged: (context, value) async {
if (store.state.prefState.colorTheme != value) { if (store.state.prefState.colorTheme != value) {
store.dispatch(UpdateUserPreferences(colorTheme: value)); store.dispatch(UpdateUserPreferences(colorTheme: value));
@ -207,6 +211,7 @@ class DeviceSettingsVM {
final Function(BuildContext, bool) onShowPdfChanged; final Function(BuildContext, bool) onShowPdfChanged;
final Function(BuildContext, bool) onEnableJSPDFChanged; final Function(BuildContext, bool) onEnableJSPDFChanged;
final Function(BuildContext, bool) onEnableTouchEventsChanged; final Function(BuildContext, bool) onEnableTouchEventsChanged;
final Function(BuildContext, bool) onEnableTooltipsChanged;
final Function(BuildContext, double) onTextScaleFactorChanged; final Function(BuildContext, double) onTextScaleFactorChanged;
final Future<bool> authenticationSupported; final Future<bool> authenticationSupported;
} }

View File

@ -16,6 +16,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = { static final Map<String, Map<String, String>> _localizedValues = {
'en': { 'en': {
// STARTER: lang key - do not remove comment // STARTER: lang key - do not remove comment
'enable_tooltips': 'Enable Tooltips',
'enable_tooltips_help': 'Show tooltips when hovering the mouse',
'multiple_client_error': 'Error: records belong to more than one client', 'multiple_client_error': 'Error: records belong to more than one client',
'register_label': 'Create your account in seconds', 'register_label': 'Create your account in seconds',
'login_label': 'Login to an existing account', 'login_label': 'Login to an existing account',
@ -69670,11 +69672,18 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['login_label'] ?? _localizedValues[localeCode]['login_label'] ??
_localizedValues[localeCode]['login_label']; _localizedValues[localeCode]['login_label'];
String get multipleClientError => String get multipleClientError =>
_localizedValues[localeCode]['multiple_client_error'] ?? _localizedValues[localeCode]['multiple_client_error'] ??
_localizedValues[localeCode]['multiple_client_error']; _localizedValues[localeCode]['multiple_client_error'];
String get enableTooltips =>
_localizedValues[localeCode]['enable_tooltips'] ??
_localizedValues[localeCode]['enable_tooltips'];
String get enableTooltipsHelp =>
_localizedValues[localeCode]['enable_tooltips_help'] ??
_localizedValues[localeCode]['enable_tooltips_help'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {