diff --git a/lib/app_config.dart b/lib/app_config.dart index 2d104db..a3afad5 100644 --- a/lib/app_config.dart +++ b/lib/app_config.dart @@ -1,34 +1,36 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -enum AppFlavor { - googleplay, - foss -} +enum AppFlavor { googleplay, foss } AppFlavor appFlavorFromString(String flavorStr) { - if (flavorStr == "googleplay") {return AppFlavor.googleplay;} - else if (flavorStr == 'foss') {return AppFlavor.foss;} + if (flavorStr == "googleplay") { + return AppFlavor.googleplay; + } else if (flavorStr == 'foss') { + return AppFlavor.foss; + } // default case: googleplay return AppFlavor.googleplay; } String versionCodeSuffixFromAppFlavor(AppFlavor flavor) { - if (flavor == AppFlavor.foss) {return " (f)";} + if (flavor == AppFlavor.foss) { + return " (f)"; + } // default case: googleplay return " (g)"; } -class AppConfig extends InheritedWidget{ +class AppConfig extends InheritedWidget { final Widget child; final AppFlavor buildFlavor; const AppConfig({ - required this.child, - required this.buildFlavor, - }): super(child: child); + required this.child, + required this.buildFlavor, + }) : super(child: child); static AppConfig of(BuildContext context) { var result = context.dependOnInheritedWidgetOfExactType(); diff --git a/lib/components/food_details_dialog.dart b/lib/components/food_details_dialog.dart index 907de26..680341b 100644 --- a/lib/components/food_details_dialog.dart +++ b/lib/components/food_details_dialog.dart @@ -27,12 +27,16 @@ class FoodDetailsState extends State { children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [for (var i = 0; i < 4; i += 1) getAvailabilityInfoCard(context, i)], + children: [ + for (var i = 0; i < 4; i += 1) getAvailabilityInfoCard(context, i) + ], ), SizedBox(height: 5), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [for (var i = 4; i < 8; i += 1) getAvailabilityInfoCard(context, i)], + children: [ + for (var i = 4; i < 8; i += 1) getAvailabilityInfoCard(context, i) + ], ), SizedBox(height: 5), Row( @@ -51,14 +55,16 @@ class FoodDetailsState extends State { if (isPortrait) { imgAndAvailabilities = Column( children: [ - widget._foodImage, SizedBox(height: 10), + widget._foodImage, + SizedBox(height: 10), SizedBox(width: 5), regionInfo, SizedBox(width: 5), availabilities, ], ); - } else { // isLandscape + } else { + // isLandscape imgAndAvailabilities = Row( children: [ Expanded( @@ -94,23 +100,19 @@ class FoodDetailsState extends State { Widget getAvailabilityInfoCard(BuildContext context, int monthIndex) { Widget containerChild; - int fstModeIdx = widget._allAvailabilities[monthIndex].indexWhere(( - mode) => mode != Availability.none); - int sndModeIdx = widget._allAvailabilities[monthIndex].indexWhere(( - mode) => mode != Availability.none, fstModeIdx + 1); + int fstModeIdx = widget._allAvailabilities[monthIndex] + .indexWhere((mode) => mode != Availability.none); + int sndModeIdx = widget._allAvailabilities[monthIndex] + .indexWhere((mode) => mode != Availability.none, fstModeIdx + 1); if (fstModeIdx == -1) { int iconAlpha = getIconAlphaFromAvailability(Availability.none); - containerChild = Icon( - availabilityModeIcons[fstModeIdx], + containerChild = Icon(availabilityModeIcons[fstModeIdx], color: Colors.black.withAlpha(iconAlpha)); - } - - else if (sndModeIdx == -1) { + } else if (sndModeIdx == -1) { int iconAlpha = getIconAlphaFromAvailability( widget._allAvailabilities[monthIndex][fstModeIdx]); - containerChild = Icon( - availabilityModeIcons[fstModeIdx], + containerChild = Icon(availabilityModeIcons[fstModeIdx], color: Colors.black.withAlpha(iconAlpha)); } else { int primaryIconAlpha = getIconAlphaFromAvailability( @@ -140,8 +142,9 @@ class FoodDetailsState extends State { padding: const EdgeInsets.all(2), child: Column( children: [ - Text(getMonthNameFromIndex(context, monthIndex).substring( - 0, 3), + Text( + getMonthNameFromIndex(context, monthIndex) + .substring(0, 3), style: TextStyle(fontWeight: FontWeight.bold)), FittedBox( fit: BoxFit.contain, @@ -153,4 +156,4 @@ class FoodDetailsState extends State { ), ); } -} \ No newline at end of file +} diff --git a/lib/components/food_tile.dart b/lib/components/food_tile.dart index 17804b2..4b0582a 100644 --- a/lib/components/food_tile.dart +++ b/lib/components/food_tile.dart @@ -18,10 +18,13 @@ class FoodTile extends StatefulWidget { FoodTile(Food foodToDisplay, int curMonthIndex) : _food = foodToDisplay, _curMonthIndex = curMonthIndex, - _allAvailabilities = List.generate(12, - (monthIndex) => foodToDisplay.getAvailabilitiesByMonth(monthIndex)) { + _allAvailabilities = List.generate( + 12, + (monthIndex) => + foodToDisplay.getAvailabilitiesByMonth(monthIndex)) { _curAvailabilities = _allAvailabilities[_curMonthIndex]; - int fstModeIdx = _curAvailabilities.indexWhere((mode) => mode != Availability.none); + int fstModeIdx = + _curAvailabilities.indexWhere((mode) => mode != Availability.none); _curAvailabilityColor = availabilityModeColor[fstModeIdx]!; } @@ -40,7 +43,7 @@ class FoodTileState extends State { builder: (context, AsyncSnapshot snapshot) { if (snapshot.hasData) { _isFavorite = - snapshot.hasData ? (snapshot.data! ? 1 : -1) : _isFavorite; + snapshot.hasData ? (snapshot.data! ? 1 : -1) : _isFavorite; } return _buildFoodTile(); }, @@ -84,8 +87,7 @@ class FoodTileState extends State { // TODO feature for editing availabilities if (false) { actions.add(MaterialButton( - onPressed: () async { - }, + onPressed: () async {}, child: Text("Edit"), // TODO l10n )); } @@ -116,12 +118,10 @@ class FoodTileState extends State { builder: (_) => AlertDialog( backgroundColor: Colors.white, content: FoodDetailsDialog( - widget._food, - foodImage, - widget._allAvailabilities), + widget._food, foodImage, widget._allAvailabilities), elevation: 10, actions: actions, - // actionsPadding: EdgeInsets.symmetric(horizontal: 4), + // actionsPadding: EdgeInsets.symmetric(horizontal: 4), ), barrierDismissible: true, ); @@ -161,7 +161,7 @@ class FoodTileState extends State { child: InkWell( onTap: tapCallback, child: - new LayoutBuilder(builder: (context, constraint) { + new LayoutBuilder(builder: (context, constraint) { return getFavIcon(context, constraint, _isFavorite); }), ), @@ -173,24 +173,24 @@ class FoodTileState extends State { flex: 2, child: Container( child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Expanded( - child: Container( - padding: const EdgeInsets.fromLTRB(5, 5, 5, 5), - child: FittedBox( - fit: BoxFit.contain, - child: Text( - widget._food.displayName, - style: foodText, - ), - ), + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Expanded( + child: Container( + padding: const EdgeInsets.fromLTRB(5, 5, 5, 5), + child: FittedBox( + fit: BoxFit.contain, + child: Text( + widget._food.displayName, + style: foodText, ), ), - availabilityIconContainer - ], - ))) + ), + ), + availabilityIconContainer + ], + ))) ], )); } @@ -207,24 +207,27 @@ Icon getFavIcon(context, constraint, int isFavorite) { Container getAvailabilityIconContainer( BuildContext context, constraint, List availabilities) { - Widget containerChild; - int fstModeIdx = availabilities.indexWhere((mode) => mode != Availability.none); - int sndModeIdx = availabilities.indexWhere((mode) => mode != Availability.none, fstModeIdx + 1); - + int fstModeIdx = + availabilities.indexWhere((mode) => mode != Availability.none); + int sndModeIdx = availabilities.indexWhere( + (mode) => mode != Availability.none, fstModeIdx + 1); if (fstModeIdx == -1) { int iconAlpha = getIconAlphaFromAvailability(Availability.none); containerChild = Icon(availabilityModeIcons[fstModeIdx], - size: constraint.biggest.height, color: Colors.black.withAlpha(iconAlpha)); - } - else if (sndModeIdx == -1) { + size: constraint.biggest.height, + color: Colors.black.withAlpha(iconAlpha)); + } else if (sndModeIdx == -1) { int iconAlpha = getIconAlphaFromAvailability(availabilities[fstModeIdx]); containerChild = Icon(availabilityModeIcons[fstModeIdx], - size: constraint.biggest.height, color: Colors.black.withAlpha(iconAlpha)); + size: constraint.biggest.height, + color: Colors.black.withAlpha(iconAlpha)); } else { - int primaryIconAlpha = getIconAlphaFromAvailability(availabilities[fstModeIdx]); - int secondaryIconAlpha = getIconAlphaFromAvailability(availabilities[sndModeIdx]); + int primaryIconAlpha = + getIconAlphaFromAvailability(availabilities[fstModeIdx]); + int secondaryIconAlpha = + getIconAlphaFromAvailability(availabilities[sndModeIdx]); containerChild = Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/components/month_selector.dart b/lib/components/month_selector.dart index 70caa08..19e7bbe 100644 --- a/lib/components/month_selector.dart +++ b/lib/components/month_selector.dart @@ -53,7 +53,9 @@ class MonthSelector extends StatelessWidget { itemBuilder: (context, i) { if (i % 2 == 0) { return ListTileTheme( - selectedTileColor: Theme.of(context).colorScheme.primary, + selectedTileColor: Theme.of(context) + .colorScheme + .primary, selectedColor: Colors.black, child: ListTile( title: Text( diff --git a/lib/helpers/availabilities.dart b/lib/helpers/availabilities.dart index 2ce26ab..6449490 100644 --- a/lib/helpers/availabilities.dart +++ b/lib/helpers/availabilities.dart @@ -21,4 +21,4 @@ final List avSettingsKeys = [ "showAvLand", "showAvSea", "showAvAir", -]; \ No newline at end of file +]; diff --git a/lib/helpers/db_provider.dart b/lib/helpers/db_provider.dart index 7d6870a..67bdfcb 100644 --- a/lib/helpers/db_provider.dart +++ b/lib/helpers/db_provider.dart @@ -134,7 +134,7 @@ class DBProvider { FROM foods AS f INNER JOIN food_region_availability AS fr ON (f.id == fr.food_id) WHERE fr.region_id = ?) - """, [region.id, fallbackRegion, region.id ]); + """, [region.id, fallbackRegion, region.id]); return results.map((item) { String foodId = item['id']; @@ -143,7 +143,8 @@ class DBProvider { String assetImgSourceUrl = item['assetImgSourceUrl']; String assetImgInfo = item['assetImgInfo']; - Region region = allRegions.firstWhere((region) => region.id == item['region_id']); + Region region = + allRegions.firstWhere((region) => region.id == item['region_id']); int isCommon = item['is_common']; String avLocal = item['avLocal']; String avLand = item['avLand']; @@ -153,8 +154,20 @@ class DBProvider { String foodNamesString = getTranslationByKey(foodId + "_names"); String infoUrl = getTranslationByKey(foodId + "_infoUrl"); - return Food(foodId, foodNamesString, type, isCommon, avLocal, avLand, - avSea, avAir, infoUrl, assetImgPath, assetImgSourceUrl, assetImgInfo, region); + return Food( + foodId, + foodNamesString, + type, + isCommon, + avLocal, + avLand, + avSea, + avAir, + infoUrl, + assetImgPath, + assetImgSourceUrl, + assetImgInfo, + region); }).toList(); } } diff --git a/lib/helpers/json_asset_loader.dart b/lib/helpers/json_asset_loader.dart index aeff418..f17f4f9 100644 --- a/lib/helpers/json_asset_loader.dart +++ b/lib/helpers/json_asset_loader.dart @@ -2,7 +2,8 @@ import 'dart:convert'; import 'package:flutter/services.dart' show rootBundle; -Future> loadAssetFromJson(String assetPath) async{ - return rootBundle.loadString(assetPath) - .then((String content) => json.decode(content)); +Future> loadAssetFromJson(String assetPath) async { + return rootBundle + .loadString(assetPath) + .then((String content) => json.decode(content)); } diff --git a/lib/helpers/text_selector.dart b/lib/helpers/text_selector.dart index 239de64..f3f2d16 100644 --- a/lib/helpers/text_selector.dart +++ b/lib/helpers/text_selector.dart @@ -33,4 +33,4 @@ String getMonthNameFromIndex(BuildContext context, int monthIndex) { default: return L10n.of(context).december; } -} \ No newline at end of file +} diff --git a/lib/helpers/user_db_provider.dart b/lib/helpers/user_db_provider.dart index 86a4e47..ad94fa4 100644 --- a/lib/helpers/user_db_provider.dart +++ b/lib/helpers/user_db_provider.dart @@ -67,44 +67,47 @@ class UserDBProvider { List allFoods = await DBProvider.db.getFoods(); - return results.map((item) { - String foodId = item['food_id']; - - //throws on error - Food dbFood = allFoods.firstWhere((element) => element.id == foodId); - - String type = dbFood.typeInfo; - String assetImgPath = dbFood.assetImgPath; - String assetImgSourceUrl = dbFood.assetImgSourceUrl; - String assetImgInfo = dbFood.assetImgInfo; - - int isCommon = dbFood.isCommon ? 1 : 0; - String avLocal = item['avLocal']; - String avLand = item['avLand']; - String avSea = item['avSea']; - String avAir = item['avAir']; - - String foodNamesString = dbFood.displayName; - for (String syn in dbFood.synonyms) { - foodNamesString += ",$syn"; - } - String infoUrl = dbFood.infoUrl; - - return Food( - foodId, - foodNamesString, - type, - isCommon, - avLocal, - avLand, - avSea, - avAir, - infoUrl, - assetImgPath, - assetImgSourceUrl, - assetImgInfo, - region); - }).whereNotNull().toList(); + return results + .map((item) { + String foodId = item['food_id']; + + //throws on error + Food dbFood = allFoods.firstWhere((element) => element.id == foodId); + + String type = dbFood.typeInfo; + String assetImgPath = dbFood.assetImgPath; + String assetImgSourceUrl = dbFood.assetImgSourceUrl; + String assetImgInfo = dbFood.assetImgInfo; + + int isCommon = dbFood.isCommon ? 1 : 0; + String avLocal = item['avLocal']; + String avLand = item['avLand']; + String avSea = item['avSea']; + String avAir = item['avAir']; + + String foodNamesString = dbFood.displayName; + for (String syn in dbFood.synonyms) { + foodNamesString += ",$syn"; + } + String infoUrl = dbFood.infoUrl; + + return Food( + foodId, + foodNamesString, + type, + isCommon, + avLocal, + avLand, + avSea, + avAir, + infoUrl, + assetImgPath, + assetImgSourceUrl, + assetImgInfo, + region); + }) + .whereNotNull() + .toList(); } addCustomFood(Food f) async { @@ -118,7 +121,6 @@ class UserDBProvider { var avSea = f.availabilities['seaTransport']; var avAir = f.availabilities['flightTransport']; - await db.rawQuery( """INSERT OR REPLACE INTO food_region_availability (food_id, avLocal, avLand, avSea, avAir, region_id) VALUES (?,?,?,?,?,?)""", [f.id, avLocal, avLand, avSea, avAir, regionCode]); diff --git a/lib/l10n/localizationsDelegates/material_localization_eo.dart b/lib/l10n/localizationsDelegates/material_localization_eo.dart index 495110c..1af6549 100644 --- a/lib/l10n/localizationsDelegates/material_localization_eo.dart +++ b/lib/l10n/localizationsDelegates/material_localization_eo.dart @@ -1,8 +1,7 @@ import 'package:flutter/material.dart'; - -class MaterialLocalizationEoDelegate extends LocalizationsDelegate { - +class MaterialLocalizationEoDelegate + extends LocalizationsDelegate { @override bool isSupported(Locale locale) { return locale.languageCode == "eo"; @@ -19,5 +18,4 @@ class MaterialLocalizationEoDelegate extends LocalizationsDelegate('getFlavor') .then((String? flavor) { - inferredFlavor = appFlavorFromString(flavor!); - }) - .catchError((error) { + inferredFlavor = appFlavorFromString(flavor!); + }).catchError((error) { print('Failed to load flavor, defaulting to googleplay flavor!'); }); @@ -67,7 +66,7 @@ class MyAppState extends State { var prefs = await SharedPreferences.getInstance(); var languageCode = prefs.getString('languageCode'); - if ( languageCode == null || languageCode == "null") { + if (languageCode == null || languageCode == "null") { return null; } return Locale(languageCode); @@ -77,19 +76,22 @@ class MyAppState extends State { Widget build(BuildContext context) { if (this.localeLoadedFromPrefs == false) { return CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation(Theme.of(context).colorScheme.secondary), + valueColor: AlwaysStoppedAnimation( + Theme.of(context).colorScheme.secondary), ); } else { return MaterialApp( localeListResolutionCallback: (deviceLocales, supportedLocales) { if (this.locale == null) { - this.locale = basicLocaleListResolution(deviceLocales, supportedLocales); + this.locale = + basicLocaleListResolution(deviceLocales, supportedLocales); } return this.locale; }, localeResolutionCallback: (deviceLocale, supportedLocales) { if (this.locale == null) { - this.locale = basicLocaleListResolution([deviceLocale!], supportedLocales); + this.locale = + basicLocaleListResolution([deviceLocale!], supportedLocales); } return this.locale; }, diff --git a/lib/models/food.dart b/lib/models/food.dart index 4cd9187..2fa9dbe 100644 --- a/lib/models/food.dart +++ b/lib/models/food.dart @@ -77,15 +77,13 @@ List getFoodsFromIds(List foodIds, List allFoods) { } List splitByCommaAndTrim(String stringifiedList) { - return stringifiedList.split(",").map( - (elem) => elem.trim() - ).toList(); + return stringifiedList.split(",").map((elem) => elem.trim()).toList(); } List availabilitiesFromStringList(List avStringList) { - return avStringList.map( - (str) => _fromDouble(double.tryParse(str) ?? 0.0) - ).toList(); + return avStringList + .map((str) => _fromDouble(double.tryParse(str) ?? 0.0)) + .toList(); } class Food { @@ -94,7 +92,8 @@ class Food { List synonyms = List.empty(); String typeInfo; bool isCommon; - LinkedHashMap> availabilities = new LinkedHashMap>(); + LinkedHashMap> availabilities = + new LinkedHashMap>(); String infoUrl; String assetImgPath; String assetImgSourceUrl; @@ -162,5 +161,4 @@ class Food { bool isFruit() => this.typeInfo.toLowerCase().contains("fruit"); bool isVegetable() => this.typeInfo.toLowerCase().contains("vegetable"); - } diff --git a/lib/routes.dart b/lib/routes.dart index 26c95e4..2246dd3 100644 --- a/lib/routes.dart +++ b/lib/routes.dart @@ -21,9 +21,9 @@ import 'package:seasoncalendar/screens/etc/imprint/imprint_screen.dart'; import 'package:seasoncalendar/screens/etc/imprint/imgsources/imgsources_screen.dart'; import 'package:seasoncalendar/screens/etc/support/support_screen.dart'; - final initial_settings = loadAssetFromJson("assets/initialsettings.json"); -final independent_text = loadAssetFromJson("assets/localization_independent_text.json"); +final independent_text = + loadAssetFromJson("assets/localization_independent_text.json"); final Map appRoutes = { "/": (context) => FutureBuilder( @@ -71,41 +71,41 @@ final Map appRoutes = { }, ), "/settings/language": (_) => FutureBuilder( - future: initial_settings, - builder: (context, AsyncSnapshot> snapshot) { - if (snapshot.hasData) { - final initialSettings = snapshot.data!; - return SettingsLanguagePage(initialSettings); - } else { - return LoadingScaffold(); - } - }, - ), + future: initial_settings, + builder: (context, AsyncSnapshot> snapshot) { + if (snapshot.hasData) { + final initialSettings = snapshot.data!; + return SettingsLanguagePage(initialSettings); + } else { + return LoadingScaffold(); + } + }, + ), "/etc": (_) => EtcPage(), "/etc/howto": (_) => HowToPage(), "/etc/about": (_) => AboutPage(), "/etc/contrib": (_) => FutureBuilder( - future: independent_text, - builder: (context, AsyncSnapshot> snapshot) { - if (snapshot.hasData) { - final l10nIndependentText = snapshot.data!; - return ContribPage(l10nIndependentText); - } else { - return LoadingScaffold(); - } - }, - ), + future: independent_text, + builder: (context, AsyncSnapshot> snapshot) { + if (snapshot.hasData) { + final l10nIndependentText = snapshot.data!; + return ContribPage(l10nIndependentText); + } else { + return LoadingScaffold(); + } + }, + ), "/etc/support": (_) => FutureBuilder( - future: independent_text, - builder: (context, AsyncSnapshot> snapshot) { - if (snapshot.hasData) { - final l10nIndependentText = snapshot.data!; - return SupportPage(l10nIndependentText); - } else { - return LoadingScaffold(); - } - }, - ), + future: independent_text, + builder: (context, AsyncSnapshot> snapshot) { + if (snapshot.hasData) { + final l10nIndependentText = snapshot.data!; + return SupportPage(l10nIndependentText); + } else { + return LoadingScaffold(); + } + }, + ), "/etc/imprint": (_) => FutureBuilder( future: independent_text, builder: (context, AsyncSnapshot> snapshot) { diff --git a/lib/screens/etc/about/about_screen.dart b/lib/screens/etc/about/about_screen.dart index 708a09e..5208ecd 100644 --- a/lib/screens/etc/about/about_screen.dart +++ b/lib/screens/etc/about/about_screen.dart @@ -2,7 +2,6 @@ import 'package:flutter/material.dart'; import 'package:seasoncalendar/generated/l10n.dart'; class AboutPage extends StatelessWidget { - @override Widget build(BuildContext context) { return Scaffold( @@ -55,7 +54,9 @@ class AboutPage extends StatelessWidget { textAlign: TextAlign.justify), SizedBox(height: 20), Text(L10n.of(context).aboutPageDisclaimer, - style: Theme.of(context).textTheme.bodyText1 + style: Theme.of(context) + .textTheme + .bodyText1 ?.copyWith(fontStyle: FontStyle.italic), textAlign: TextAlign.justify), ], diff --git a/lib/screens/etc/contrib/contrib_screen.dart b/lib/screens/etc/contrib/contrib_screen.dart index 4c870b3..4910a7b 100644 --- a/lib/screens/etc/contrib/contrib_screen.dart +++ b/lib/screens/etc/contrib/contrib_screen.dart @@ -3,7 +3,6 @@ import 'package:url_launcher/url_launcher.dart'; import 'package:seasoncalendar/generated/l10n.dart'; class ContribPage extends StatelessWidget { - final Map _l10nIndependentText; ContribPage(Map l10nIndependentText) @@ -25,14 +24,15 @@ class ContribPage extends StatelessWidget { textAlign: TextAlign.justify, text: TextSpan( text: L10n.of(context).contribPageContact, - style: Theme.of(context).textTheme.bodyText1 + style: Theme.of(context) + .textTheme + .bodyText1 ?.copyWith(color: Colors.black), ), ), SizedBox(height: 10), RaisedButton( - child: - Text(L10n.of(context).contribPageContactButtonText), + child: Text(L10n.of(context).contribPageContactButtonText), onPressed: () async { final url = _l10nIndependentText["websiteContactPage"]; if (await canLaunch(url)) { @@ -51,7 +51,9 @@ class ContribPage extends StatelessWidget { textAlign: TextAlign.justify, text: TextSpan( text: L10n.of(context).contribPageCode, - style: Theme.of(context).textTheme.bodyText1 + style: Theme.of(context) + .textTheme + .bodyText1 ?.copyWith(color: Colors.black), ), ), diff --git a/lib/screens/etc/etc_screen.dart b/lib/screens/etc/etc_screen.dart index 7d18b8f..9fece6d 100644 --- a/lib/screens/etc/etc_screen.dart +++ b/lib/screens/etc/etc_screen.dart @@ -16,7 +16,8 @@ class EtcPage extends StatelessWidget { } List getEtcPageItems(BuildContext context) { - bool isGooglePlay = AppConfig.of(context).buildFlavor == AppFlavor.googleplay; + bool isGooglePlay = + AppConfig.of(context).buildFlavor == AppFlavor.googleplay; List etcPageItems = List.empty(growable: true); etcPageItems.add(ListTile( @@ -43,8 +44,7 @@ class EtcPage extends StatelessWidget { etcPageItems.add(ListTile( leading: Icon(Icons.favorite), title: Text(L10n.of(context).supportPageTitle), - onTap: () => - Navigator.of(context).pushNamed("/etc/support"), + onTap: () => Navigator.of(context).pushNamed("/etc/support"), )); etcPageItems.add(const Divider()); } @@ -52,8 +52,7 @@ class EtcPage extends StatelessWidget { etcPageItems.add(ListTile( leading: Icon(Icons.account_balance), title: Text(L10n.of(context).imprintPageTitle), - onTap: () => - Navigator.of(context).pushNamed("/etc/imprint"), + onTap: () => Navigator.of(context).pushNamed("/etc/imprint"), )); return etcPageItems; diff --git a/lib/screens/etc/howto/howto_screen.dart b/lib/screens/etc/howto/howto_screen.dart index 6d1a971..2e3b7c0 100644 --- a/lib/screens/etc/howto/howto_screen.dart +++ b/lib/screens/etc/howto/howto_screen.dart @@ -3,7 +3,6 @@ import 'package:flutter/material.dart'; import 'package:seasoncalendar/generated/l10n.dart'; class HowToPage extends StatelessWidget { - @override Widget build(BuildContext context) { return Scaffold( diff --git a/lib/screens/etc/imprint/imgsources/imgsources_screen.dart b/lib/screens/etc/imprint/imgsources/imgsources_screen.dart index 0880911..3997cbf 100644 --- a/lib/screens/etc/imprint/imgsources/imgsources_screen.dart +++ b/lib/screens/etc/imprint/imgsources/imgsources_screen.dart @@ -15,8 +15,7 @@ class ImgSourcesScreen extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: - AppBar(title: Text(L10n.of(context).imprintPageImagesHeadline)), + appBar: AppBar(title: Text(L10n.of(context).imprintPageImagesHeadline)), body: Container( padding: const EdgeInsets.fromLTRB(0, 10, 0, 0), child: ListView.separated( diff --git a/lib/screens/etc/imprint/imprint_screen.dart b/lib/screens/etc/imprint/imprint_screen.dart index 891ea1e..7b0d0e1 100644 --- a/lib/screens/etc/imprint/imprint_screen.dart +++ b/lib/screens/etc/imprint/imprint_screen.dart @@ -4,7 +4,6 @@ import 'package:seasoncalendar/generated/l10n.dart'; import 'package:seasoncalendar/helpers/lang_helper.dart'; class ImprintPage extends StatelessWidget { - final Map _l10nIndependentText; ImprintPage(Map l10nIndependentText) @@ -26,10 +25,8 @@ class ImprintPage extends StatelessWidget { textAlign: TextAlign.left, ), SizedBox(height: 10), - Text( - _l10nIndependentText["developerAddress"], - textAlign: TextAlign.left - ), + Text(_l10nIndependentText["developerAddress"], + textAlign: TextAlign.left), SizedBox(height: 20), Text( L10n.of(context).imprintPageDisclaimerHeadline, @@ -62,10 +59,13 @@ class ImprintPage extends StatelessWidget { ), SizedBox(height: 10), Text( - languageNameFromCode["de"]! + ", " - + languageNameFromCode["en"]! + ", " - + languageNameFromCode["fr"]! + ": " - + L10n.of(context).imprintPageMyName, + languageNameFromCode["de"]! + + ", " + + languageNameFromCode["en"]! + + ", " + + languageNameFromCode["fr"]! + + ": " + + L10n.of(context).imprintPageMyName, textAlign: TextAlign.left, ), Text( @@ -90,14 +90,16 @@ class ImprintPage extends StatelessWidget { SizedBox(height: 10), Text(L10n.of(context).imprintPageDataText2, textAlign: TextAlign.left, - style: Theme.of(context).textTheme.bodyText1 + style: Theme.of(context) + .textTheme + .bodyText1 ?.copyWith(fontStyle: FontStyle.italic)), SizedBox(height: 20), GestureDetector( child: Text( L10n.of(context).imprintPageImagesHeadline, - style: Theme.of(context).textTheme.headline6 - ?.copyWith(color: Theme.of(context).colorScheme.secondary), + style: Theme.of(context).textTheme.headline6?.copyWith( + color: Theme.of(context).colorScheme.secondary), textAlign: TextAlign.left, ), onTap: () => diff --git a/lib/screens/etc/support/support_screen.dart b/lib/screens/etc/support/support_screen.dart index 3bd199f..9788842 100644 --- a/lib/screens/etc/support/support_screen.dart +++ b/lib/screens/etc/support/support_screen.dart @@ -5,7 +5,6 @@ import 'package:url_launcher/url_launcher.dart'; import 'package:seasoncalendar/generated/l10n.dart'; class SupportPage extends StatelessWidget { - final Map _l10nIndependentText; SupportPage(Map l10nIndependentText) diff --git a/lib/screens/home/home_screen.dart b/lib/screens/home/home_screen.dart index 01b66ed..7fa12e9 100644 --- a/lib/screens/home/home_screen.dart +++ b/lib/screens/home/home_screen.dart @@ -7,17 +7,15 @@ import 'package:seasoncalendar/models/food_display_configuration.dart'; import 'package:seasoncalendar/components/food_view.dart'; class HomeScreen extends StatelessWidget { - @override Widget build(BuildContext context) { - return Scaffold( appBar: AppBar( - title: Consumer( - builder: (context, fdc, child) { - return MonthSelector(fdc); - }, - ), + title: Consumer( + builder: (context, fdc, child) { + return MonthSelector(fdc); + }, + ), ), body: Consumer( builder: (context, fdc, child) { @@ -31,4 +29,4 @@ class HomeScreen extends StatelessWidget { ), ); } -} \ No newline at end of file +} diff --git a/lib/screens/search/search_screen.dart b/lib/screens/search/search_screen.dart index 26ac9dd..6a66e50 100644 --- a/lib/screens/search/search_screen.dart +++ b/lib/screens/search/search_screen.dart @@ -76,8 +76,8 @@ class SearchScreen extends SearchDelegate { .toList(); var startsWithMatches = dbFoods - .where((food) => food.synonyms.any((synonym) => - synonym.toLowerCase().startsWith(query.toLowerCase()))) + .where((food) => food.synonyms.any( + (synonym) => synonym.toLowerCase().startsWith(query.toLowerCase()))) .toList(); var innerMatches = dbFoods @@ -88,7 +88,9 @@ class SearchScreen extends SearchDelegate { var matches = exactMatches; - var tmp = []..addAll(startsWithMatches)..addAll(innerMatches); + var tmp = [] + ..addAll(startsWithMatches) + ..addAll(innerMatches); tmp.forEach((food) { if (!matches.contains(food)) { matches.add(food); @@ -99,7 +101,6 @@ class SearchScreen extends SearchDelegate { return FoodView.fromSearchResult(matches, _monthIndex); } - final Levenshtein lvs = new Levenshtein(); var lvsResults = dbFoods diff --git a/lib/screens/settings/filterfoods/settings_filterfoods_dialog.dart b/lib/screens/settings/filterfoods/settings_filterfoods_dialog.dart index 6217f38..a7124ab 100644 --- a/lib/screens/settings/filterfoods/settings_filterfoods_dialog.dart +++ b/lib/screens/settings/filterfoods/settings_filterfoods_dialog.dart @@ -18,7 +18,6 @@ class FilterfoodsDialog extends StatefulWidget { class FilterfoodsDialogState extends State { @override Widget build(BuildContext context) { - return SingleChildScrollView( child: Column( children: [ @@ -27,20 +26,23 @@ class FilterfoodsDialogState extends State { textAlign: TextAlign.center, style: Theme.of(context).textTheme.headline5, ), - SizedBox(height: 35,), + SizedBox( + height: 35, + ), ToggleButtons( - color: Colors.black38, - selectedColor: Colors.black, - fillColor: Theme.of(context).colorScheme.primary.withAlpha(150), - borderColor: Theme.of(context).colorScheme.secondary.withAlpha(0), - selectedBorderColor: Theme.of(context).colorScheme.secondary.withAlpha(150), - splashColor: Theme.of(context).colorScheme.primary, - highlightColor: Theme.of(context).colorScheme.primary, - children: avIcons, - isSelected: widget._selectedAvailabilities, - onPressed: (int i) { - toggleAvView(i); - }), + color: Colors.black38, + selectedColor: Colors.black, + fillColor: Theme.of(context).colorScheme.primary.withAlpha(150), + borderColor: Theme.of(context).colorScheme.secondary.withAlpha(0), + selectedBorderColor: + Theme.of(context).colorScheme.secondary.withAlpha(150), + splashColor: Theme.of(context).colorScheme.primary, + highlightColor: Theme.of(context).colorScheme.primary, + children: avIcons, + isSelected: widget._selectedAvailabilities, + onPressed: (int i) { + toggleAvView(i); + }), ], ), ); diff --git a/lib/screens/settings/language/settings_language_screen.dart b/lib/screens/settings/language/settings_language_screen.dart index 53c2035..12d4a99 100644 --- a/lib/screens/settings/language/settings_language_screen.dart +++ b/lib/screens/settings/language/settings_language_screen.dart @@ -46,9 +46,12 @@ class SettingsLanguagePageState extends State { padding: const EdgeInsets.fromLTRB(10, 0, 10, 0), child: Text(L10n.of(context).incompleteLanguageNotice, textAlign: TextAlign.left, - style: Theme.of(context).textTheme.bodyText1?.copyWith( - fontStyle: FontStyle.italic, - color: Colors.grey[600])), + style: Theme.of(context) + .textTheme + .bodyText1 + ?.copyWith( + fontStyle: FontStyle.italic, + color: Colors.grey[600])), ), const SizedBox( height: 20, @@ -124,8 +127,8 @@ class SettingsLanguagePageState extends State { .where((langCode) => !nonDisplayableLanguages.contains(langCode)) .toList(); localeLangCodes.sort(); - languageEntries.addAll( - localeLangCodes.map((langCode) => getLanguageRadioListTile(context, langCode))); + languageEntries.addAll(localeLangCodes + .map((langCode) => getLanguageRadioListTile(context, langCode))); return languageEntries; } diff --git a/lib/screens/settings/region/settings_region_screen.dart b/lib/screens/settings/region/settings_region_screen.dart index 4f7f167..d856b31 100644 --- a/lib/screens/settings/region/settings_region_screen.dart +++ b/lib/screens/settings/region/settings_region_screen.dart @@ -46,8 +46,7 @@ class SettingsRegionPageState extends State { selectedColor: defaultListTileTheme.selectedColor, child: regionListTiles[i]); }, - separatorBuilder: (context, i) => - const Divider( + separatorBuilder: (context, i) => const Divider( height: 10, ), ), diff --git a/lib/screens/settings/settings_screen.dart b/lib/screens/settings/settings_screen.dart index 0926ad0..10b41b0 100644 --- a/lib/screens/settings/settings_screen.dart +++ b/lib/screens/settings/settings_screen.dart @@ -71,14 +71,15 @@ class SettingsPageState extends State { [getSettingsI(widget._initialSettings), getVersionInfo()]), builder: (context, AsyncSnapshot> snapshot) { if (snapshot.hasData) { - widget._settings = snapshot.data![0] as Map; + widget._settings = + snapshot.data![0] as Map; widget._versionInfo = snapshot.data![1] as String; - return _buildSettings(context, widget._settings, widget._versionInfo); + return _buildSettings( + context, widget._settings, widget._versionInfo); } else { return Align( - alignment: Alignment.center, - child: CircularProgressIndicator() - ); + alignment: Alignment.center, + child: CircularProgressIndicator()); } }))); } @@ -105,11 +106,11 @@ class SettingsPageState extends State { child: Icon(Icons.help), ), MaterialButton( - onPressed: () { - Navigator.of(context).pop(); - }, - child: Text(L10n.of(context).back)), - ], + onPressed: () { + Navigator.of(context).pop(); + }, + child: Text(L10n.of(context).back)), + ], ), barrierDismissible: true, ); diff --git a/lib/theme/bullet_point.dart b/lib/theme/bullet_point.dart index 6176397..3a311e8 100644 --- a/lib/theme/bullet_point.dart +++ b/lib/theme/bullet_point.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -class BulletPoint extends StatelessWidget{ +class BulletPoint extends StatelessWidget { @override Widget build(BuildContext context) { return new Container( @@ -12,4 +12,4 @@ class BulletPoint extends StatelessWidget{ ), ); } -} \ No newline at end of file +} diff --git a/lib/theme/seasoncalendar_icons.dart b/lib/theme/seasoncalendar_icons.dart index 2b71cf1..1e3f8df 100644 --- a/lib/theme/seasoncalendar_icons.dart +++ b/lib/theme/seasoncalendar_icons.dart @@ -11,7 +11,7 @@ /// fonts: /// - asset: fonts/SeasonCalendar.ttf /// -/// +/// /// * Font Awesome 5, Copyright (C) 2016 by Dave Gandy /// Author: Dave Gandy /// License: SIL (https://github.com/FortAwesome/Font-Awesome/blob/master/LICENSE.txt) @@ -25,8 +25,12 @@ class SeasonCalendarIcons { static const _kFontFam = 'SeasonCalendar'; static const _kFontPkg = null; - static const IconData arrow_left = IconData(0xf060, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData arrow_right = IconData(0xf061, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData apple_alt = IconData(0xf5d1, fontFamily: _kFontFam, fontPackage: _kFontPkg); - static const IconData carrot = IconData(0xf787, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData arrow_left = + IconData(0xf060, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData arrow_right = + IconData(0xf061, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData apple_alt = + IconData(0xf5d1, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData carrot = + IconData(0xf787, fontFamily: _kFontFam, fontPackage: _kFontPkg); } diff --git a/lib/theme/themes.dart b/lib/theme/themes.dart index 1c7b958..feaf4b2 100644 --- a/lib/theme/themes.dart +++ b/lib/theme/themes.dart @@ -1,36 +1,34 @@ import 'package:flutter/material.dart'; final ThemeData defaultTheme = ThemeData( - // Define the default brightness and colors. - brightness: Brightness.light, + brightness: Brightness.light, + primarySwatch: Colors.lightGreen, + colorScheme: ColorScheme.fromSwatch( primarySwatch: Colors.lightGreen, - colorScheme: ColorScheme.fromSwatch( - primarySwatch: Colors.lightGreen, - accentColor: Colors.lightGreen[600], - brightness: Brightness.light, - ).copyWith(primary: Colors.lightGreen[200]), + accentColor: Colors.lightGreen[600], + brightness: Brightness.light, + ).copyWith(primary: Colors.lightGreen[200]), // Define the default font family. - fontFamily: 'Noto', + fontFamily: 'Noto', // Define the default TextTheme. Use this to specify the default // text styling for headlines, titles, bodies of text, and more. - textTheme: TextTheme( - headline1: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold), - headline2: TextStyle(fontSize: 48.0, fontWeight: FontWeight.bold), - headline3: TextStyle(fontSize: 36.0, fontWeight: FontWeight.bold), - headline4: TextStyle(fontSize: 28.0, fontWeight: FontWeight.bold), - headline5: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), - headline6: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), - - bodyText1: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal), - bodyText2: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal), - ), - + textTheme: TextTheme( + headline1: TextStyle(fontSize: 72.0, fontWeight: FontWeight.bold), + headline2: TextStyle(fontSize: 48.0, fontWeight: FontWeight.bold), + headline3: TextStyle(fontSize: 36.0, fontWeight: FontWeight.bold), + headline4: TextStyle(fontSize: 28.0, fontWeight: FontWeight.bold), + headline5: TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), + headline6: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold), + bodyText1: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal), + bodyText2: TextStyle(fontSize: 16.0, fontStyle: FontStyle.normal), + ), ); -const TextStyle foodText = TextStyle(fontSize: 1024.0, fontWeight: FontWeight.w600); +const TextStyle foodText = + TextStyle(fontSize: 1024.0, fontWeight: FontWeight.w600); final Color foodInfoViewBackgroundColor = Colors.lightGreen[50]!;