Feature request: Turn off PDF / HTML invoice preview #361

This commit is contained in:
Hillel Coren 2021-12-01 18:32:10 +02:00
parent a09d7edcba
commit 971abbf293
6 changed files with 60 additions and 12 deletions

View File

@ -148,6 +148,7 @@ class UpdateUserPreferences implements PersistPrefs {
this.persistData, this.persistData,
this.persistUi, this.persistUi,
this.tapSelectedToEdit, this.tapSelectedToEdit,
this.showPdfPreview,
}); });
final AppLayout appLayout; final AppLayout appLayout;
@ -167,6 +168,7 @@ class UpdateUserPreferences implements PersistPrefs {
final bool persistData; final bool persistData;
final bool persistUi; final bool persistUi;
final bool tapSelectedToEdit; final bool tapSelectedToEdit;
final bool showPdfPreview;
final BuiltMap<String, String> customColors; final BuiltMap<String, String> customColors;
} }

View File

@ -33,6 +33,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
tapSelectedToEdit: false, tapSelectedToEdit: false,
hideDesktopWarning: false, hideDesktopWarning: false,
showKanban: false, showKanban: false,
showPdfPreview: true,
persistData: false, persistData: false,
persistUI: true, persistUI: true,
companyPrefs: BuiltMap<String, CompanyPrefState>(), companyPrefs: BuiltMap<String, CompanyPrefState>(),
@ -98,6 +99,8 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
bool get showKanban; bool get showKanban;
bool get showPdfPreview;
bool get isHistoryVisible; bool get isHistoryVisible;
bool get enableDarkMode; bool get enableDarkMode;
@ -186,6 +189,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
..tapSelectedToEdit = false ..tapSelectedToEdit = false
..persistData = false ..persistData = false
..persistUI = true ..persistUI = true
..showPdfPreview = true
..colorTheme = ..colorTheme =
builder.enableDarkMode == true ? kColorThemeLight : kColorThemeLight; builder.enableDarkMode == true ? kColorThemeLight : kColorThemeLight;

View File

@ -142,6 +142,9 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
'showKanban', 'showKanban',
serializers.serialize(object.showKanban, serializers.serialize(object.showKanban,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
'showPdfPreview',
serializers.serialize(object.showPdfPreview,
specifiedType: const FullType(bool)),
'isHistoryVisible', 'isHistoryVisible',
serializers.serialize(object.isHistoryVisible, serializers.serialize(object.isHistoryVisible,
specifiedType: const FullType(bool)), specifiedType: const FullType(bool)),
@ -241,6 +244,10 @@ class _$PrefStateSerializer implements StructuredSerializer<PrefState> {
result.showKanban = serializers.deserialize(value, result.showKanban = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
break; break;
case 'showPdfPreview':
result.showPdfPreview = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool;
break;
case 'isHistoryVisible': case 'isHistoryVisible':
result.isHistoryVisible = serializers.deserialize(value, result.isHistoryVisible = serializers.deserialize(value,
specifiedType: const FullType(bool)) as bool; specifiedType: const FullType(bool)) as bool;
@ -548,6 +555,8 @@ class _$PrefState extends PrefState {
@override @override
final bool showKanban; final bool showKanban;
@override @override
final bool showPdfPreview;
@override
final bool isHistoryVisible; final bool isHistoryVisible;
@override @override
final bool enableDarkMode; final bool enableDarkMode;
@ -587,6 +596,7 @@ class _$PrefState extends PrefState {
this.isPreviewVisible, this.isPreviewVisible,
this.isMenuVisible, this.isMenuVisible,
this.showKanban, this.showKanban,
this.showPdfPreview,
this.isHistoryVisible, this.isHistoryVisible,
this.enableDarkMode, this.enableDarkMode,
this.isFilterVisible, this.isFilterVisible,
@ -618,6 +628,8 @@ class _$PrefState extends PrefState {
isMenuVisible, 'PrefState', 'isMenuVisible'); isMenuVisible, 'PrefState', 'isMenuVisible');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
showKanban, 'PrefState', 'showKanban'); showKanban, 'PrefState', 'showKanban');
BuiltValueNullFieldError.checkNotNull(
showPdfPreview, 'PrefState', 'showPdfPreview');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
isHistoryVisible, 'PrefState', 'isHistoryVisible'); isHistoryVisible, 'PrefState', 'isHistoryVisible');
BuiltValueNullFieldError.checkNotNull( BuiltValueNullFieldError.checkNotNull(
@ -665,6 +677,7 @@ class _$PrefState extends PrefState {
isPreviewVisible == other.isPreviewVisible && isPreviewVisible == other.isPreviewVisible &&
isMenuVisible == other.isMenuVisible && isMenuVisible == other.isMenuVisible &&
showKanban == other.showKanban && showKanban == other.showKanban &&
showPdfPreview == other.showPdfPreview &&
isHistoryVisible == other.isHistoryVisible && isHistoryVisible == other.isHistoryVisible &&
enableDarkMode == other.enableDarkMode && enableDarkMode == other.enableDarkMode &&
isFilterVisible == other.isFilterVisible && isFilterVisible == other.isFilterVisible &&
@ -701,13 +714,13 @@ class _$PrefState extends PrefState {
$jc( $jc(
$jc( $jc(
$jc( $jc(
$jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), $jc($jc($jc($jc($jc(0, appLayout.hashCode), moduleLayout.hashCode), menuSidebarMode.hashCode), historySidebarMode.hashCode),
historySidebarMode.hashCode),
useSidebarEditor.hashCode), useSidebarEditor.hashCode),
customColors.hashCode), customColors.hashCode),
isPreviewVisible.hashCode), isPreviewVisible.hashCode),
isMenuVisible.hashCode), isMenuVisible.hashCode),
showKanban.hashCode), showKanban.hashCode),
showPdfPreview.hashCode),
isHistoryVisible.hashCode), isHistoryVisible.hashCode),
enableDarkMode.hashCode), enableDarkMode.hashCode),
isFilterVisible.hashCode), isFilterVisible.hashCode),
@ -735,6 +748,7 @@ class _$PrefState extends PrefState {
..add('isPreviewVisible', isPreviewVisible) ..add('isPreviewVisible', isPreviewVisible)
..add('isMenuVisible', isMenuVisible) ..add('isMenuVisible', isMenuVisible)
..add('showKanban', showKanban) ..add('showKanban', showKanban)
..add('showPdfPreview', showPdfPreview)
..add('isHistoryVisible', isHistoryVisible) ..add('isHistoryVisible', isHistoryVisible)
..add('enableDarkMode', enableDarkMode) ..add('enableDarkMode', enableDarkMode)
..add('isFilterVisible', isFilterVisible) ..add('isFilterVisible', isFilterVisible)
@ -800,6 +814,11 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
bool get showKanban => _$this._showKanban; bool get showKanban => _$this._showKanban;
set showKanban(bool showKanban) => _$this._showKanban = showKanban; set showKanban(bool showKanban) => _$this._showKanban = showKanban;
bool _showPdfPreview;
bool get showPdfPreview => _$this._showPdfPreview;
set showPdfPreview(bool showPdfPreview) =>
_$this._showPdfPreview = showPdfPreview;
bool _isHistoryVisible; bool _isHistoryVisible;
bool get isHistoryVisible => _$this._isHistoryVisible; bool get isHistoryVisible => _$this._isHistoryVisible;
set isHistoryVisible(bool isHistoryVisible) => set isHistoryVisible(bool isHistoryVisible) =>
@ -879,6 +898,7 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
_isPreviewVisible = $v.isPreviewVisible; _isPreviewVisible = $v.isPreviewVisible;
_isMenuVisible = $v.isMenuVisible; _isMenuVisible = $v.isMenuVisible;
_showKanban = $v.showKanban; _showKanban = $v.showKanban;
_showPdfPreview = $v.showPdfPreview;
_isHistoryVisible = $v.isHistoryVisible; _isHistoryVisible = $v.isHistoryVisible;
_enableDarkMode = $v.enableDarkMode; _enableDarkMode = $v.enableDarkMode;
_isFilterVisible = $v.isFilterVisible; _isFilterVisible = $v.isFilterVisible;
@ -930,8 +950,9 @@ class PrefStateBuilder implements Builder<PrefState, PrefStateBuilder> {
isMenuVisible, 'PrefState', 'isMenuVisible'), isMenuVisible, 'PrefState', 'isMenuVisible'),
showKanban: BuiltValueNullFieldError.checkNotNull( showKanban: BuiltValueNullFieldError.checkNotNull(
showKanban, 'PrefState', 'showKanban'), showKanban, 'PrefState', 'showKanban'),
isHistoryVisible: BuiltValueNullFieldError.checkNotNull( showPdfPreview: BuiltValueNullFieldError.checkNotNull(
isHistoryVisible, 'PrefState', 'isHistoryVisible'), showPdfPreview, 'PrefState', 'showPdfPreview'),
isHistoryVisible: BuiltValueNullFieldError.checkNotNull(isHistoryVisible, 'PrefState', 'isHistoryVisible'),
enableDarkMode: BuiltValueNullFieldError.checkNotNull(enableDarkMode, 'PrefState', 'enableDarkMode'), enableDarkMode: BuiltValueNullFieldError.checkNotNull(enableDarkMode, 'PrefState', 'enableDarkMode'),
isFilterVisible: BuiltValueNullFieldError.checkNotNull(isFilterVisible, 'PrefState', 'isFilterVisible'), isFilterVisible: BuiltValueNullFieldError.checkNotNull(isFilterVisible, 'PrefState', 'isFilterVisible'),
persistData: BuiltValueNullFieldError.checkNotNull(persistData, 'PrefState', 'persistData'), persistData: BuiltValueNullFieldError.checkNotNull(persistData, 'PrefState', 'persistData'),

View File

@ -149,7 +149,7 @@ class _DeviceSettingsState extends State<DeviceSettings>
disabledLabel: localization.showOrHide, disabledLabel: localization.showOrHide,
), ),
], ],
if (isDesktop(context)) if (isDesktop(context)) ...[
BoolDropdownButton( BoolDropdownButton(
label: localization.clickSelected, label: localization.clickSelected,
value: prefState.tapSelectedToEdit, value: prefState.tapSelectedToEdit,
@ -158,8 +158,19 @@ class _DeviceSettingsState extends State<DeviceSettings>
}, },
enabledLabel: localization.editRecord, enabledLabel: localization.editRecord,
disabledLabel: localization.hidePreview, disabledLabel: localization.hidePreview,
) ),
else Padding(
padding: const EdgeInsets.only(top: 10),
child: SwitchListTile(
title: Text(localization.showPdfPreview),
value: prefState.showPdfPreview,
onChanged: (value) =>
viewModel.onShowPdfChanged(context, value),
activeColor: Theme.of(context).colorScheme.secondary,
secondary: Icon(MdiIcons.filePdfBox),
),
),
] else
BoolDropdownButton( BoolDropdownButton(
label: localization.listLongPress, label: localization.listLongPress,
value: !prefState.longPressSelectionIsDefault, value: !prefState.longPressSelectionIsDefault,

View File

@ -54,6 +54,7 @@ class DeviceSettingsVM {
@required this.onCustomColorsChanged, @required this.onCustomColorsChanged,
@required this.onPersistDataChanged, @required this.onPersistDataChanged,
@required this.onPersistUiChanged, @required this.onPersistUiChanged,
@required this.onShowPdfChanged,
@required this.onTapSelectedChanged, @required this.onTapSelectedChanged,
}); });
@ -98,6 +99,9 @@ class DeviceSettingsVM {
onTapSelectedChanged: (context, value) async { onTapSelectedChanged: (context, value) async {
store.dispatch(UpdateUserPreferences(tapSelectedToEdit: value)); store.dispatch(UpdateUserPreferences(tapSelectedToEdit: value));
}, },
onShowPdfChanged: (context, value) {
store.dispatch(UpdateUserPreferences(showPdfPreview: 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));
@ -182,5 +186,6 @@ class DeviceSettingsVM {
final Function(BuildContext, bool) onRequireAuthenticationChanged; final Function(BuildContext, bool) onRequireAuthenticationChanged;
final Function(BuildContext, bool) onPersistDataChanged; final Function(BuildContext, bool) onPersistDataChanged;
final Function(BuildContext, bool) onPersistUiChanged; final Function(BuildContext, bool) onPersistUiChanged;
final Function(BuildContext, bool) onShowPdfChanged;
final Future<bool> authenticationSupported; final Future<bool> authenticationSupported;
} }

View File

@ -16,6 +16,7 @@ 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
'show_pdf_preview': 'Show PDF Preview',
'print_pdf': 'Print PDF', 'print_pdf': 'Print PDF',
'remind_me': 'Remind Me', 'remind_me': 'Remind Me',
'instant_bank_pay': 'Instant Bank Pay', 'instant_bank_pay': 'Instant Bank Pay',
@ -62844,6 +62845,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
_localizedValues[localeCode]['print_pdf'] ?? _localizedValues[localeCode]['print_pdf'] ??
_localizedValues['en']['print_pdf']; _localizedValues['en']['print_pdf'];
String get showPdfPreview =>
_localizedValues[localeCode]['show_pdf_preview'] ??
_localizedValues['en']['show_pdf_preview'];
// STARTER: lang field - do not remove comment // STARTER: lang field - do not remove comment
String lookup(String key) { String lookup(String key) {