diff options
Diffstat (limited to 'lib/views')
-rw-r--r-- | lib/views/favorites_view.dart | 10 | ||||
-rw-r--r-- | lib/views/file_info.dart | 10 | ||||
-rw-r--r-- | lib/views/image_view.dart | 18 | ||||
-rw-r--r-- | lib/views/info_view.dart | 19 | ||||
-rw-r--r-- | lib/views/main_view.dart | 16 | ||||
-rw-r--r-- | lib/views/recipe_view.dart | 24 | ||||
-rw-r--r-- | lib/views/settings_view.dart | 20 | ||||
-rw-r--r-- | lib/views/shoplist_view.dart | 10 | ||||
-rw-r--r-- | lib/views/vote_view.dart | 8 | ||||
-rw-r--r-- | lib/views/week_view.dart | 27 |
10 files changed, 77 insertions, 85 deletions
diff --git a/lib/views/favorites_view.dart b/lib/views/favorites_view.dart index bb0f7fb..97f784c 100644 --- a/lib/views/favorites_view.dart +++ b/lib/views/favorites_view.dart @@ -14,17 +14,17 @@ class FavoritesView extends StatefulWidget { const FavoritesView({Key? key}) : super(key: key); @override - _FavoritesViewState createState() => _FavoritesViewState(); + FavoritesViewState createState() => FavoritesViewState(); } -class _FavoritesViewState extends State<FavoritesView> { +class FavoritesViewState extends State<FavoritesView> { BuildContext? _toastyContext; @override Widget build(BuildContext context) { return Scaffold( appBar: _buildAppBar(context), - drawer: CustomDrawer(initalIndex: 1), + drawer: const CustomDrawer(initialIndex: 1), body: Container( width: double.infinity, child: Builder( @@ -51,7 +51,7 @@ class _FavoritesViewState extends State<FavoritesView> { title: Text(AppLocalizations.of(context)!.category4), actions: [ IconButton( - icon: Icon(Icons.search), + icon: const Icon(Icons.search), onPressed: () async { await showSearch( context: context, @@ -68,7 +68,7 @@ class _FavoritesViewState extends State<FavoritesView> { Widget _buildListView() { List<Recipe> _filteredRecipeList = RecipeData.recipeList.where((element) => element.favorite).toList(); - if (_filteredRecipeList.isEmpty) return NoContentError(); + if (_filteredRecipeList.isEmpty) return const NoContentError(); return ListView.builder( itemCount: _filteredRecipeList.length, diff --git a/lib/views/file_info.dart b/lib/views/file_info.dart index e032716..28c45f9 100644 --- a/lib/views/file_info.dart +++ b/lib/views/file_info.dart @@ -9,15 +9,15 @@ import 'package:kulinar_app/widgets/error_widgets.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class FileInfo extends StatefulWidget { - FileInfo({Key? key, required this.filePath}) : super(key: key); + const FileInfo({Key? key, required this.filePath}) : super(key: key); final String filePath; @override - _FileInfoState createState() => _FileInfoState(); + FileInfoState createState() => FileInfoState(); } -class _FileInfoState extends State<FileInfo> { +class FileInfoState extends State<FileInfo> { @override Widget build(BuildContext context) { final File _file = File(widget.filePath.split(":")[1]); @@ -27,8 +27,8 @@ class _FileInfoState extends State<FileInfo> { body: FutureBuilder( future: FileHandler.deserializeFileInformation(_file), builder: (BuildContext context, AsyncSnapshot<Map<String, String>> snapshot) { - if (snapshot.connectionState != ConnectionState.done) return CircularProgressIndicator(); - if (snapshot.hasError || !snapshot.hasData) return UnknownError(); + if (snapshot.connectionState != ConnectionState.done) return const CircularProgressIndicator(); + if (snapshot.hasError || !snapshot.hasData) return const UnknownError(); return _buildFileInfoTable(_getSortedSnapshotData(snapshot), _file); }, diff --git a/lib/views/image_view.dart b/lib/views/image_view.dart index 615aa26..1363268 100644 --- a/lib/views/image_view.dart +++ b/lib/views/image_view.dart @@ -15,18 +15,16 @@ class ImageView extends StatelessWidget { child: Scaffold( backgroundColor: _averageImageColor(image), body: Center( - child: Container( - child: GestureDetector( - child: Hero( - tag: "image", - child: Image( - image: FileImage(File(image)), - ), + child: GestureDetector( + child: Hero( + tag: "image", + child: Image( + image: FileImage(File(image)), ), - onTap: () { - Navigator.pop(context); - }, ), + onTap: () { + Navigator.pop(context); + }, ), ), ), diff --git a/lib/views/info_view.dart b/lib/views/info_view.dart index bda2d14..0d0897d 100644 --- a/lib/views/info_view.dart +++ b/lib/views/info_view.dart @@ -10,10 +10,10 @@ class InfoView extends StatefulWidget { const InfoView({Key? key}) : super(key: key); @override - _InfoViewState createState() => _InfoViewState(); + InfoViewState createState() => InfoViewState(); } -class _InfoViewState extends State<InfoView> { +class InfoViewState extends State<InfoView> { String name = "David Penkowoj"; String websiteURL = "https://davidpenkowoj.de"; String sourceCodeURL = "https://git.davidpenkowoj.de/kulinar_app.git"; @@ -23,7 +23,7 @@ class _InfoViewState extends State<InfoView> { Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(AppLocalizations.of(context)!.category9)), - drawer: CustomDrawer(initalIndex: 6), + drawer: const CustomDrawer(initialIndex: 6), body: ListView( children: <Widget>[ Padding( @@ -32,7 +32,7 @@ class _InfoViewState extends State<InfoView> { ), ListTile( title: Text(AppLocalizations.of(context)!.info1, style: cDefaultTextStyle), - subtitle: Text(cVersion, style: cDetailsTextStyle), + subtitle: const Text(cVersion, style: cDetailsTextStyle), ), ListTile( title: Text(AppLocalizations.of(context)!.info2, style: cDefaultTextStyle), @@ -42,7 +42,7 @@ class _InfoViewState extends State<InfoView> { title: Text(AppLocalizations.of(context)!.info3, style: cDefaultTextStyle), subtitle: Text(websiteURL, style: cDetailsTextStyle, overflow: TextOverflow.ellipsis), trailing: IconButton( - icon: Icon(Icons.north_east_rounded), + icon: const Icon(Icons.north_east_rounded), onPressed: () { _launchURL(Uri.parse(websiteURL)); }, @@ -52,7 +52,7 @@ class _InfoViewState extends State<InfoView> { title: Text(AppLocalizations.of(context)!.info4, style: cDefaultTextStyle), subtitle: Text(sourceCodeURL, style: cDetailsTextStyle, overflow: TextOverflow.ellipsis), trailing: IconButton( - icon: Icon(Icons.north_east_rounded), + icon: const Icon(Icons.north_east_rounded), onPressed: () { _launchURL(Uri.parse(sourceCodeURL)); }, @@ -62,7 +62,7 @@ class _InfoViewState extends State<InfoView> { title: Text(AppLocalizations.of(context)!.info5, style: cDefaultTextStyle), subtitle: Text(privacyNoticeURL, style: cDetailsTextStyle, overflow: TextOverflow.ellipsis), trailing: IconButton( - icon: Icon(Icons.north_east_rounded), + icon: const Icon(Icons.north_east_rounded), onPressed: () { _launchURL(Uri.parse(privacyNoticeURL)); }, @@ -71,7 +71,7 @@ class _InfoViewState extends State<InfoView> { ListTile( title: Text(AppLocalizations.of(context)!.info6, style: cDefaultTextStyle), trailing: IconButton( - icon: Icon(Icons.launch_rounded), + icon: const Icon(Icons.launch_rounded), onPressed: () { _showDialog(); }, @@ -95,7 +95,8 @@ class _InfoViewState extends State<InfoView> { if (await canLaunchUrl(url)) { await launchUrl(url, mode: LaunchMode.externalApplication); } else { - print('Could not launch $url'); + debugPrint("Could not launch $url"); + // TODO: maybe add toastbar } } } diff --git a/lib/views/main_view.dart b/lib/views/main_view.dart index 759e423..3db3e97 100644 --- a/lib/views/main_view.dart +++ b/lib/views/main_view.dart @@ -19,11 +19,11 @@ class MainView extends StatefulWidget { const MainView({Key? key}) : super(key: key); @override - _MainViewState createState() => _MainViewState(); + MainViewState createState() => MainViewState(); } -class _MainViewState extends State<MainView> with SingleTickerProviderStateMixin, WidgetsBindingObserver { - static const platform = const MethodChannel("com.davidpenkowoj.kulinar.openfile"); +class MainViewState extends State<MainView> with SingleTickerProviderStateMixin, WidgetsBindingObserver { + static const platform = MethodChannel("com.davidpenkowoj.kulinar.openfile"); TabController? _tabController; BuildContext? _toastyContext; @@ -55,7 +55,7 @@ class _MainViewState extends State<MainView> with SingleTickerProviderStateMixin Widget build(BuildContext context) { return Scaffold( appBar: _buildAppBar(context, _tabController!), - drawer: CustomDrawer(initalIndex: 0), + drawer: const CustomDrawer(initialIndex: 0), floatingActionButton: _buildFloatingActionButton(), body: Builder(builder: (BuildContext context) { _toastyContext = context; @@ -87,11 +87,11 @@ class _MainViewState extends State<MainView> with SingleTickerProviderStateMixin Widget _buildFloatingActionButton() { return FloatingActionButton( - child: Icon(Icons.add, color: cIconColor), + child: const Icon(Icons.add, color: cIconColor), onPressed: () async { await Navigator.push( context, - SlideFromBottomRoute(child: RecipeView()), + SlideFromBottomRoute(child: const RecipeView()), ); setState(() {}); @@ -100,7 +100,7 @@ class _MainViewState extends State<MainView> with SingleTickerProviderStateMixin } Widget _buildListView(List<Recipe> filteredRecipeList) { - if (filteredRecipeList.isEmpty) return NoContentError(); + if (filteredRecipeList.isEmpty) return const NoContentError(); return ListView.builder( itemCount: filteredRecipeList.length, @@ -113,7 +113,7 @@ class _MainViewState extends State<MainView> with SingleTickerProviderStateMixin title: Text(AppLocalizations.of(context)!.category1), actions: [ IconButton( - icon: Icon( + icon: const Icon( Icons.search, ), onPressed: () async { diff --git a/lib/views/recipe_view.dart b/lib/views/recipe_view.dart index f512770..faaa0ca 100644 --- a/lib/views/recipe_view.dart +++ b/lib/views/recipe_view.dart @@ -28,10 +28,10 @@ class RecipeView extends StatefulWidget { final Function? showToastCallback; @override - _RecipeViewState createState() => _RecipeViewState(); + RecipeViewState createState() => RecipeViewState(); } -class _RecipeViewState extends State<RecipeView> { +class RecipeViewState extends State<RecipeView> { final GlobalKey<FormState> _formKey = GlobalKey<FormState>(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); final TextEditingController _controller1 = TextEditingController(); @@ -170,7 +170,7 @@ class _RecipeViewState extends State<RecipeView> { Widget _buildUtilityRow() { if (widget.remote) { - return SizedBox( + return const SizedBox( height: 10.0, width: double.infinity, ); @@ -248,11 +248,11 @@ class _RecipeViewState extends State<RecipeView> { Widget _buildDescriptionInput() { return Padding( padding: const EdgeInsets.all(18.0), - child: _isEditModeEnabled ? _buildInputDescriptuion() : _buildMarkdownDescription(), + child: _isEditModeEnabled ? _buildInputDescription() : _buildMarkdownDescription(), ); } - TextField _buildInputDescriptuion() { + TextField _buildInputDescription() { return TextField( expands: true, maxLines: null, @@ -263,7 +263,7 @@ class _RecipeViewState extends State<RecipeView> { focusNode: _detailsTextFocus, style: cRecipeDescriptionStyle, enableInteractiveSelection: true, - toolbarOptions: ToolbarOptions( + toolbarOptions: const ToolbarOptions( copy: true, cut: true, paste: true, @@ -276,7 +276,7 @@ class _RecipeViewState extends State<RecipeView> { return MarkdownBody( data: _controller2.text, selectable: true, - onTapLink: (text, href, title) => null, + onTapLink: (text, href, title) => {}, imageBuilder: (uri, title, alt) => Container(), // styleSheet: CustomMarkdownStyle(), ); @@ -333,7 +333,7 @@ class _RecipeViewState extends State<RecipeView> { List<Widget> _remoteDownloadAction = [ IconButton( - icon: Icon(Icons.save_alt_rounded), + icon: const Icon(Icons.save_alt_rounded), onPressed: () { downloadRecipe(context, recipe); }, @@ -341,7 +341,7 @@ class _RecipeViewState extends State<RecipeView> { ]; List<Widget> _remoteLookupAction = [ - IconButton( + const IconButton( icon: Icon(Icons.menu_open_rounded), onPressed: null, ), @@ -361,7 +361,7 @@ class _RecipeViewState extends State<RecipeView> { return AppBar( title: Text(_title), leading: IconButton( - icon: Icon(Icons.close), + icon: const Icon(Icons.close), onPressed: () { Navigator.pop(context); }, @@ -373,12 +373,12 @@ class _RecipeViewState extends State<RecipeView> { Widget _buildAppBarCheckActions() { if (_isEditModeEnabled) { return IconButton( - icon: Icon(Icons.check), + icon: const Icon(Icons.check), onPressed: _addRecipe, ); } else { return IconButton( - icon: Icon(Icons.edit), + icon: const Icon(Icons.edit), onPressed: () { _isEditModeEnabled = true; diff --git a/lib/views/settings_view.dart b/lib/views/settings_view.dart index 367c1a6..7268acf 100644 --- a/lib/views/settings_view.dart +++ b/lib/views/settings_view.dart @@ -12,10 +12,10 @@ class SettingsView extends StatefulWidget { const SettingsView({Key? key}) : super(key: key); @override - _SettingsViewState createState() => _SettingsViewState(); + SettingsViewState createState() => SettingsViewState(); } -class _SettingsViewState extends State<SettingsView> { +class SettingsViewState extends State<SettingsView> { final TextEditingController _controller = TextEditingController(); final FocusNode _focusNode = FocusNode(); @@ -29,7 +29,7 @@ class _SettingsViewState extends State<SettingsView> { Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(AppLocalizations.of(context)!.category8)), - drawer: CustomDrawer(initalIndex: 5), + drawer: const CustomDrawer(initialIndex: 5), body: Builder( builder: (BuildContext context) => ListView( children: [ @@ -54,7 +54,7 @@ class _SettingsViewState extends State<SettingsView> { ListTile( title: Text(AppLocalizations.of(context)!.setting22, style: cDefaultTextStyle), subtitle: Text(AppLocalizations.of(context)!.explanation3, style: cDetailsTextStyle), - trailing: IconButton( + trailing: const IconButton( icon: Icon(Icons.arrow_forward_rounded), onPressed: null, ), @@ -134,12 +134,12 @@ class _SettingsViewState extends State<SettingsView> { value: int.parse(SettingsData.settings["photoSource"]!), items: [ DropdownMenuItem( - child: Text(AppLocalizations.of(context)!.option111, style: cOptionTextStyle), value: 0, + child: Text(AppLocalizations.of(context)!.option111, style: cOptionTextStyle), ), DropdownMenuItem( - child: Text(AppLocalizations.of(context)!.option112, style: cOptionTextStyle), value: 1, + child: Text(AppLocalizations.of(context)!.option112, style: cOptionTextStyle), ), ], onChanged: (value) { @@ -156,20 +156,20 @@ class _SettingsViewState extends State<SettingsView> { value: int.parse(SettingsData.settings["showPhotos"]!), items: [ DropdownMenuItem( - child: Text(AppLocalizations.of(context)!.option211, style: cOptionTextStyle), value: 0, + child: Text(AppLocalizations.of(context)!.option211, style: cOptionTextStyle), ), DropdownMenuItem( - child: Text(AppLocalizations.of(context)!.option212, style: cOptionTextStyle), value: 1, + child: Text(AppLocalizations.of(context)!.option212, style: cOptionTextStyle), ), DropdownMenuItem( - child: Text(AppLocalizations.of(context)!.option213, style: cOptionTextStyle), value: 2, + child: Text(AppLocalizations.of(context)!.option213, style: cOptionTextStyle), ), DropdownMenuItem( - child: Text(AppLocalizations.of(context)!.option214, style: cOptionTextStyle), value: 3, + child: Text(AppLocalizations.of(context)!.option214, style: cOptionTextStyle), ), ], onChanged: (value) { diff --git a/lib/views/shoplist_view.dart b/lib/views/shoplist_view.dart index 500b8fc..e13ef21 100644 --- a/lib/views/shoplist_view.dart +++ b/lib/views/shoplist_view.dart @@ -14,10 +14,10 @@ class ShoplistView extends StatefulWidget { const ShoplistView({Key? key}) : super(key: key); @override - _ShoplistView createState() => _ShoplistView(); + ShoplistViewState createState() => ShoplistViewState(); } -class _ShoplistView extends State<ShoplistView> { +class ShoplistViewState extends State<ShoplistView> { final FocusNode _focusNode = FocusNode(); final TextEditingController _controller = TextEditingController(); final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); @@ -30,7 +30,7 @@ class _ShoplistView extends State<ShoplistView> { return Scaffold( key: _scaffoldKey, appBar: AppBar(title: Text(AppLocalizations.of(context)!.category7)), - drawer: CustomDrawer(initalIndex: 4), + drawer: const CustomDrawer(initialIndex: 4), floatingActionButton: _buildFloatingActionButton(), body: _buildAnimatedList(), ); @@ -54,14 +54,14 @@ class _ShoplistView extends State<ShoplistView> { // TODO: FIXME: Sometimes exception "cant call insertItem of null" is thrown when first item is added or last is removed Widget _buildAnimatedList() { - if (ShoplistData.shoplist.length == 0) return NoContentError(); + if (ShoplistData.shoplist.isEmpty) return const NoContentError(); return AnimatedList( key: _listKey, initialItemCount: ShoplistData.shoplist.length, itemBuilder: (BuildContext context, int index, Animation<double> animation) { return SlideTransition( - position: animation.drive(Tween(begin: Offset(1.0, 0.0), end: Offset(0.0, 0.0))), + position: animation.drive(Tween(begin: const Offset(1.0, 0.0), end: const Offset(0.0, 0.0))), child: Dismissible( key: Key(_getUniqueKeyString(ShoplistData.shoplist[index])), background: _buildDimissibleBackground(true), diff --git a/lib/views/vote_view.dart b/lib/views/vote_view.dart index 86ddc0b..9c5721e 100644 --- a/lib/views/vote_view.dart +++ b/lib/views/vote_view.dart @@ -9,16 +9,16 @@ class VoteView extends StatefulWidget { const VoteView({Key? key}) : super(key: key); @override - _VoteViewState createState() => _VoteViewState(); + VoteViewState createState() => VoteViewState(); } -class _VoteViewState extends State<VoteView> { +class VoteViewState extends State<VoteView> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(AppLocalizations.of(context)!.category6)), - drawer: CustomDrawer(initalIndex: 3), - body: NoContentError(), + drawer: const CustomDrawer(initialIndex: 3), + body: const NoContentError(), ); } } diff --git a/lib/views/week_view.dart b/lib/views/week_view.dart index 23d71b8..de6ebcf 100644 --- a/lib/views/week_view.dart +++ b/lib/views/week_view.dart @@ -1,12 +1,7 @@ -import 'dart:convert'; - import 'package:flutter/material.dart'; -import 'package:kulinar_app/models/recipe_class.dart'; import 'package:kulinar_app/widgets/error_widgets.dart'; -import 'package:kulinar_app/widgets/recipe_card_widget.dart'; import 'package:kulinar_app/widgets/custom_drawer_widget.dart'; -import 'package:kulinar_app/models/data/recipe_data_class.dart'; import 'package:kulinar_app/models/data/settings_data_class.dart'; import 'package:http/http.dart'; @@ -16,19 +11,19 @@ class WeekView extends StatefulWidget { const WeekView({Key? key}) : super(key: key); @override - _WeekViewState createState() => _WeekViewState(); + WeekViewState createState() => WeekViewState(); } -class _WeekViewState extends State<WeekView> { +class WeekViewState extends State<WeekView> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text(AppLocalizations.of(context)!.category5)), - drawer: CustomDrawer(initalIndex: 2), + drawer: const CustomDrawer(initialIndex: 2), body: FutureBuilder( future: _getWeeklyRecipes(), builder: (BuildContext context, AsyncSnapshot snapshot) { - if (snapshot.connectionState != ConnectionState.done) return LinearProgressIndicator(); + if (snapshot.connectionState != ConnectionState.done) return const LinearProgressIndicator(); if (snapshot.hasError || !snapshot.hasData) return NetworkContentError(refreshCallback: _retry); return RefreshIndicator( @@ -36,7 +31,7 @@ class _WeekViewState extends State<WeekView> { setState(() {}); }, child: ListView( - children: [ + children: const [ Text("Not implemented"), // TODO: Not implemented ], ), @@ -50,21 +45,19 @@ class _WeekViewState extends State<WeekView> { Map<String, String> _headers = {"Content-Type": "application/json; charset=UTF-8"}; try { - return await Future.delayed(Duration(milliseconds: 500), () { - print(SettingsData.settings["serverURL"]); + return await Future.delayed(const Duration(milliseconds: 500), () { + debugPrint("${SettingsData.settings['serverURL']}"); return get(Uri.https(SettingsData.settings["serverURL"]!, "/weekly"), headers: _headers); }); } catch (e) { - print(e); + debugPrint("$e"); return null; } } - Future<Null> _retry() async { - await Future.delayed(Duration(milliseconds: 300)); + Future<void> _retry() async { + await Future.delayed(const Duration(milliseconds: 300)); setState(() {}); - - return null; } } |