Change UI font size #359
This commit is contained in:
parent
9100eed376
commit
def138f173
|
|
@ -136,6 +136,7 @@ class UpdateUserPreferences implements PersistPrefs {
|
|||
this.enableDarkMode,
|
||||
this.requireAuthentication,
|
||||
this.longPressSelectionIsDefault,
|
||||
this.textScaleFactor,
|
||||
this.isPreviewVisible,
|
||||
this.accentColor,
|
||||
this.menuMode,
|
||||
|
|
@ -168,6 +169,7 @@ class UpdateUserPreferences implements PersistPrefs {
|
|||
final bool persistData;
|
||||
final bool persistUi;
|
||||
final bool tapSelectedToEdit;
|
||||
final double textScaleFactor;
|
||||
final bool showPdfPreview;
|
||||
final BuiltMap<String, String> customColors;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ PrefState prefReducer(
|
|||
historySidebarReducer(state.historySidebarMode, action)
|
||||
..hideDesktopWarning =
|
||||
hideDesktopWarningReducer(state.hideDesktopWarning, action)
|
||||
..textScaleFactor = textScaleFactorReducer(state.textScaleFactor, action)
|
||||
..isMenuVisible = menuVisibleReducer(state.isMenuVisible, action)
|
||||
..isHistoryVisible = historyVisibleReducer(state.isHistoryVisible, action)
|
||||
..enableDarkMode = darkModeReducer(state.enableDarkMode, action)
|
||||
|
|
@ -181,6 +182,12 @@ Reducer<bool> menuVisibleReducer = combineReducers([
|
|||
}),
|
||||
]);
|
||||
|
||||
Reducer<double> textScaleFactorReducer = combineReducers([
|
||||
TypedReducer<double, UpdateUserPreferences>((value, action) {
|
||||
return action.textScaleFactor ?? value;
|
||||
}),
|
||||
]);
|
||||
|
||||
Reducer<bool> historyVisibleReducer = combineReducers([
|
||||
TypedReducer<bool, UpdateUserPreferences>((value, action) {
|
||||
return action.sidebar == AppSidebar.history ? !value : value;
|
||||
|
|
|
|||
|
|
@ -47,8 +47,7 @@ abstract class PrefState implements Built<PrefState, PrefStateBuilder> {
|
|||
|
||||
static const TEXT_SCALING_NORMAL = 1.0;
|
||||
static const TEXT_SCALING_LARGE = 1.2;
|
||||
static const TEXT_SCALING_LARGER = 1.4;
|
||||
static const TEXT_SCALING_LARGEST = 1.6;
|
||||
static const TEXT_SCALING_EXTRA_LARGE = 1.4;
|
||||
|
||||
static const THEME_SIDEBAR_ACTIVE_BACKGROUND_COLOR =
|
||||
'sidebar_active_background_color';
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import 'package:flutter/services.dart';
|
|||
// Package imports:
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:flutter_styled_toast/flutter_styled_toast.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/app_builder.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
import 'package:timeago/timeago.dart' as timeago;
|
||||
|
||||
|
|
@ -174,6 +175,30 @@ class _DeviceSettingsState extends State<DeviceSettings>
|
|||
),
|
||||
FormCard(
|
||||
children: <Widget>[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: AppDropdownButton<double>(
|
||||
labelText: localization.fontSize,
|
||||
value: prefState.textScaleFactor,
|
||||
onChanged: (dynamic value) {
|
||||
viewModel.onTextScaleFactorChanged(context, value);
|
||||
AppBuilder.of(context).rebuild();
|
||||
},
|
||||
items: [
|
||||
DropdownMenuItem(
|
||||
child: Text(localization.normal),
|
||||
value: PrefState.TEXT_SCALING_NORMAL,
|
||||
),
|
||||
DropdownMenuItem(
|
||||
child: Text(localization.large),
|
||||
value: PrefState.TEXT_SCALING_LARGE,
|
||||
),
|
||||
DropdownMenuItem(
|
||||
child: Text(localization.extraLarge),
|
||||
value: PrefState.TEXT_SCALING_EXTRA_LARGE,
|
||||
),
|
||||
]),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: viewModel.authenticationSupported,
|
||||
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ class DeviceSettingsVM {
|
|||
@required this.onPersistUiChanged,
|
||||
@required this.onShowPdfChanged,
|
||||
@required this.onTapSelectedChanged,
|
||||
@required this.onTextScaleFactorChanged,
|
||||
});
|
||||
|
||||
static DeviceSettingsVM fromStore(Store<AppState> store) {
|
||||
|
|
@ -102,6 +103,9 @@ class DeviceSettingsVM {
|
|||
onShowPdfChanged: (context, value) {
|
||||
store.dispatch(UpdateUserPreferences(showPdfPreview: value));
|
||||
},
|
||||
onTextScaleFactorChanged: (context, value) {
|
||||
store.dispatch(UpdateUserPreferences(textScaleFactor: value));
|
||||
},
|
||||
onColorThemeChanged: (context, value) async {
|
||||
if (store.state.prefState.colorTheme != value) {
|
||||
store.dispatch(UpdateUserPreferences(colorTheme: value));
|
||||
|
|
@ -187,5 +191,6 @@ class DeviceSettingsVM {
|
|||
final Function(BuildContext, bool) onPersistDataChanged;
|
||||
final Function(BuildContext, bool) onPersistUiChanged;
|
||||
final Function(BuildContext, bool) onShowPdfChanged;
|
||||
final Function(BuildContext, double) onTextScaleFactorChanged;
|
||||
final Future<bool> authenticationSupported;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
static final Map<String, Map<String, String>> _localizedValues = {
|
||||
'en': {
|
||||
// STARTER: lang key - do not remove comment
|
||||
'normal': 'Normal',
|
||||
'large': 'Large',
|
||||
'extra_large': 'Extra Large',
|
||||
'show_pdf_preview': 'Show PDF Preview',
|
||||
'show_pdf_preview_help': 'Display PDF preview while editing invoices',
|
||||
'print_pdf': 'Print PDF',
|
||||
|
|
@ -62854,6 +62857,18 @@ mixin LocalizationsProvider on LocaleCodeAware {
|
|||
_localizedValues[localeCode]['show_pdf_preview_help'] ??
|
||||
_localizedValues['en']['show_pdf_preview_help'];
|
||||
|
||||
String get normal =>
|
||||
_localizedValues[localeCode]['normal'] ??
|
||||
_localizedValues['en']['normal'];
|
||||
|
||||
String get large =>
|
||||
_localizedValues[localeCode]['large'] ??
|
||||
_localizedValues['en']['large'];
|
||||
|
||||
String get extraLarge =>
|
||||
_localizedValues[localeCode]['extra_large'] ??
|
||||
_localizedValues['en']['extra_large'];
|
||||
|
||||
// STARTER: lang field - do not remove comment
|
||||
|
||||
String lookup(String key) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue