Google Fonts

This commit is contained in:
Hillel Coren 2020-02-09 15:05:04 +02:00
parent ad3e35d974
commit 075dbcd3ee
4 changed files with 64 additions and 13 deletions

View File

@ -0,0 +1,45 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:url_launcher/url_launcher.dart';
class HelpLink extends StatelessWidget {
const HelpLink({
@required this.url,
@required this.message,
});
final String url;
final String message;
@override
Widget build(BuildContext context) {
final localization = AppLocalization.of(context);
final ThemeData themeData = Theme.of(context);
final TextStyle aboutTextStyle = themeData.textTheme.bodyText1;
final TextStyle linkStyle =
themeData.textTheme.bodyText1.copyWith(color: themeData.accentColor);
return Padding(
padding: const EdgeInsets.only(top: 20, bottom: 30),
child: RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(
style: linkStyle,
recognizer: TapGestureRecognizer()
..onTap = () {
launch(url, forceSafariVC: false);
},
text: localization.clickHereCapital + ' ',
),
TextSpan(
style: aboutTextStyle,
text: message,
),
],
),
),
);
}
}

View File

@ -343,17 +343,6 @@ class _DrawerTileState extends State<DrawerTile> {
}
}
class _LinkTextSpan extends TextSpan {
_LinkTextSpan({TextStyle style, String url, String text})
: super(
style: style,
text: text ?? url,
recognizer: TapGestureRecognizer()
..onTap = () {
launch(url, forceSafariVC: false);
});
}
class SidebarFooter extends StatelessWidget {
@override
Widget build(BuildContext context) {
@ -529,9 +518,12 @@ void _showAbout(BuildContext context) {
'\n\n' +
localization.ifYouLikeIt,
),
_LinkTextSpan(
TextSpan(
style: linkStyle,
url: getAppURL(context),
recognizer: TapGestureRecognizer()
..onTap = () {
launch(getAppURL(context), forceSafariVC: false);
},
text: ' ' + localization.clickHere + ' ',
),
TextSpan(

View File

@ -10,6 +10,7 @@ import 'package:invoiceninja_flutter/ui/app/forms/app_dropdown_button.dart';
import 'package:invoiceninja_flutter/ui/app/forms/app_form.dart';
import 'package:invoiceninja_flutter/ui/app/forms/bool_dropdown_button.dart';
import 'package:invoiceninja_flutter/ui/app/forms/color_picker.dart';
import 'package:invoiceninja_flutter/ui/app/forms/help_link.dart';
import 'package:invoiceninja_flutter/ui/settings/invoice_design_vm.dart';
import 'package:invoiceninja_flutter/ui/app/edit_scaffold.dart';
import 'package:invoiceninja_flutter/utils/fonts.dart';
@ -137,6 +138,7 @@ class _InvoiceDesignState extends State<InvoiceDesign>
],
),
FormCard(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
EntityDropdown(
key: ValueKey('__primary_font_${settings.primaryFont}__'),
@ -158,6 +160,10 @@ class _InvoiceDesignState extends State<InvoiceDesign>
settings.rebuild((b) => b..secondaryFont = font?.id)),
allowClearing: state.settingsUIState.isFiltered,
),
HelpLink(
url: 'https://fonts.google.com',
message: localization.toLearnAboutGoogleFonts,
),
FormColorPicker(
labelText: localization.primaryColor,
onSelected: (value) => viewModel.onSettingsChanged(

View File

@ -14,6 +14,7 @@ abstract class LocaleCodeAware {
mixin LocalizationsProvider on LocaleCodeAware {
static final Map<String, Map<String, String>> _localizedValues = {
'en': {
'to_learn_about_gogle_fonts': 'to learn about Google Fonts',
'unpaid_invoice': 'Unpaid Invoice',
'paid_invoice': 'Paid Invoice',
'unapproved_quote': 'Unapproved Quote',
@ -492,6 +493,7 @@ mixin LocalizationsProvider on LocaleCodeAware {
'thank_you_for_using_our_app': 'Thank you for using our app!',
'if_you_like_it': 'If you like it please',
'click_here': 'click here',
'click_here_capital': 'Click here',
'to_rate_it': 'to rate it.',
'average': 'Average',
'unapproved': 'Unapproved',
@ -14135,6 +14137,8 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get clickHere => _localizedValues[localeCode]['click_here'];
String get clickHereCapital => _localizedValues[localeCode]['click_here_capital'];
String get toRateIt => _localizedValues[localeCode]['to_rate_it'];
String get average => _localizedValues[localeCode]['average'];
@ -15964,6 +15968,10 @@ mixin LocalizationsProvider on LocaleCodeAware {
String get unapprovedQuote =>
_localizedValues[localeCode]['unapproved_quote'];
String get toLearnAboutGoogleFonts =>
_localizedValues[localeCode]['to_learn_about_gogle_fonts'];
String lookup(String key) {
final lookupKey = toSnakeCase(key);
return _localizedValues[localeCode][lookupKey] ??