From 0a2c68a1b62df8a9371d46d5b59752ff96a7fd18 Mon Sep 17 00:00:00 2001 From: Roopak Bedekar Date: Fri, 10 Sep 2021 01:31:16 +0530 Subject: [PATCH 1/2] fix - failed to load widget/error widget --- lib/ui/views/groups/assignment_details_view.dart | 9 +++++++++ lib/ui/views/groups/group_details_view.dart | 8 ++++++++ lib/ui/views/groups/my_groups_view.dart | 15 +++++++++++++++ lib/ui/views/ib/ib_landing_view.dart | 5 +++-- lib/ui/views/profile/user_favourites_view.dart | 8 ++++++++ lib/ui/views/profile/user_projects_view.dart | 9 +++++++++ lib/ui/views/projects/featured_projects_view.dart | 8 ++++++++ lib/ui/views/projects/project_details_view.dart | 10 ++++++++++ lib/utils/cv_exception.dart | 12 ++++++++++++ 9 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 lib/utils/cv_exception.dart diff --git a/lib/ui/views/groups/assignment_details_view.dart b/lib/ui/views/groups/assignment_details_view.dart index 1ee9e6d3..700f7910 100644 --- a/lib/ui/views/groups/assignment_details_view.dart +++ b/lib/ui/views/groups/assignment_details_view.dart @@ -14,6 +14,7 @@ import 'package:mobile_app/ui/components/cv_primary_button.dart'; import 'package:mobile_app/ui/components/cv_text_field.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/groups/update_assignment_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/utils/validators.dart'; import 'package:mobile_app/viewmodels/groups/assignment_details_viewmodel.dart'; @@ -463,6 +464,14 @@ class _AssignmentDetailsViewState extends State { _buildGrades(), ], ), + if (_model.isError(_model.FETCH_ASSIGNMENT_DETAILS)) + Column( + children: [ + CVException( + _model.errorMessageFor(_model.FETCH_ASSIGNMENT_DETAILS), + ), + ], + ), ], ); }), diff --git a/lib/ui/views/groups/group_details_view.dart b/lib/ui/views/groups/group_details_view.dart index b662a3fb..a86a7c19 100644 --- a/lib/ui/views/groups/group_details_view.dart +++ b/lib/ui/views/groups/group_details_view.dart @@ -12,6 +12,7 @@ import 'package:mobile_app/ui/views/groups/components/assignment_card.dart'; import 'package:mobile_app/ui/views/groups/components/member_card.dart'; import 'package:mobile_app/ui/views/groups/edit_group_view.dart'; import 'package:mobile_app/ui/views/groups/update_assignment_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/utils/validators.dart'; import 'package:mobile_app/ui/components/cv_flat_button.dart'; @@ -407,6 +408,13 @@ class _GroupDetailsViewState extends State { ); }); } + if (_model.isError(_model.FETCH_GROUP_DETAILS)) { + _items.add( + CVException( + _model.errorMessageFor(_model.FETCH_GROUP_DETAILS), + ), + ); + } return ListView( padding: const EdgeInsets.all(8), diff --git a/lib/ui/views/groups/my_groups_view.dart b/lib/ui/views/groups/my_groups_view.dart index bf6e0ef7..a7545638 100644 --- a/lib/ui/views/groups/my_groups_view.dart +++ b/lib/ui/views/groups/my_groups_view.dart @@ -11,6 +11,7 @@ import 'package:mobile_app/ui/views/groups/components/group_member_card.dart'; import 'package:mobile_app/ui/views/groups/components/group_mentor_card.dart'; import 'package:mobile_app/ui/views/groups/edit_group_view.dart'; import 'package:mobile_app/ui/views/groups/new_group_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/viewmodels/groups/my_groups_viewmodel.dart'; @@ -135,6 +136,13 @@ class _MyGroupsViewState extends State { ); } } + if (_model.isError(_model.FETCH_MENTORED_GROUPS)) { + _items.add( + CVException( + _model.errorMessageFor(_model.FETCH_MENTORED_GROUPS), + ), + ); + } _items.add(SizedBox(height: 24)); @@ -153,6 +161,13 @@ class _MyGroupsViewState extends State { ); } } + if (_model.isError(_model.FETCH_MEMBER_GROUPS)) { + _items.add( + CVException( + _model.errorMessageFor(_model.FETCH_MEMBER_GROUPS), + ), + ); + } return ListView( padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16), diff --git a/lib/ui/views/ib/ib_landing_view.dart b/lib/ui/views/ib/ib_landing_view.dart index a091f51c..6b8373a6 100644 --- a/lib/ui/views/ib/ib_landing_view.dart +++ b/lib/ui/views/ib/ib_landing_view.dart @@ -6,6 +6,7 @@ import 'package:mobile_app/models/ib/ib_chapter.dart'; import 'package:mobile_app/ui/components/cv_drawer_tile.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/ib/ib_page_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/viewmodels/ib/ib_landing_viewmodel.dart'; import 'package:theme_provider/theme_provider.dart'; @@ -159,8 +160,8 @@ class _IbLandingViewState extends State { ), !_model.isSuccess(_model.IB_FETCH_CHAPTERS) ? InkWell( - child: CVDrawerTile( - title: 'Loading...', + child: CVException( + _model.errorMessageFor(_model.IB_FETCH_CHAPTERS), ), ) : _buildChapters(_model.chapters), diff --git a/lib/ui/views/profile/user_favourites_view.dart b/lib/ui/views/profile/user_favourites_view.dart index fb33990f..f4e0c2af 100644 --- a/lib/ui/views/profile/user_favourites_view.dart +++ b/lib/ui/views/profile/user_favourites_view.dart @@ -5,6 +5,7 @@ import 'package:mobile_app/ui/components/cv_add_icon_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/projects/components/project_card.dart'; import 'package:mobile_app/ui/views/projects/project_details_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/viewmodels/profile/user_favourites_viewmodel.dart'; class UserFavouritesView extends StatefulWidget { @@ -46,6 +47,13 @@ class _UserFavouritesViewState extends State ); }); } + if (model.isError(model.FETCH_USER_FAVOURITES)) { + _items.add( + CVException( + model.errorMessageFor(model.FETCH_USER_FAVOURITES), + ), + ); + } if (model?.previousUserFavouritesBatch?.links?.next != null) { _items.add( diff --git a/lib/ui/views/profile/user_projects_view.dart b/lib/ui/views/profile/user_projects_view.dart index ecf3c7d9..319f5ff8 100644 --- a/lib/ui/views/profile/user_projects_view.dart +++ b/lib/ui/views/profile/user_projects_view.dart @@ -4,6 +4,7 @@ import 'package:mobile_app/ui/components/cv_add_icon_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/projects/components/project_card.dart'; import 'package:mobile_app/ui/views/projects/project_details_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/viewmodels/profile/user_projects_viewmodel.dart'; class UserProjectsView extends StatefulWidget { @@ -44,6 +45,14 @@ class _UserProjectsViewState extends State }); } + if (model.isError(model.FETCH_USER_PROJECTS)) { + _items.add( + CVException( + model.errorMessageFor(model.FETCH_USER_PROJECTS), + ), + ); + } + if (model?.previousUserProjectsBatch?.links?.next != null) { _items.add( CVAddIconButton( diff --git a/lib/ui/views/projects/featured_projects_view.dart b/lib/ui/views/projects/featured_projects_view.dart index c827be72..a48446a0 100644 --- a/lib/ui/views/projects/featured_projects_view.dart +++ b/lib/ui/views/projects/featured_projects_view.dart @@ -5,6 +5,7 @@ import 'package:mobile_app/ui/components/cv_primary_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/projects/components/featured_project_card.dart'; import 'package:mobile_app/ui/views/projects/project_details_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/viewmodels/projects/featured_projects_viewmodel.dart'; class FeaturedProjectsView extends StatefulWidget { @@ -42,6 +43,13 @@ class _FeaturedProjectsViewState extends State { ); }); } + if (model.isError(model.FETCH_FEATURED_PROJECTS)) { + _items.add( + CVException( + model.errorMessageFor(model.FETCH_FEATURED_PROJECTS), + ), + ); + } if (!widget.embed && model?.previousFeaturedProjectsBatch?.links?.next != null) { diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index 72770e90..9aa02f7c 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -14,6 +14,7 @@ import 'package:mobile_app/ui/components/cv_flat_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/profile/profile_view.dart'; import 'package:mobile_app/ui/views/projects/edit_project_view.dart'; +import 'package:mobile_app/utils/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/utils/validators.dart'; import 'package:mobile_app/viewmodels/projects/project_details_viewmodel.dart'; @@ -624,6 +625,15 @@ class _ProjectDetailsViewState extends State { ); }); } + if (_model.isError(_model.FETCH_PROJECT_DETAILS)) { + _items.add(Divider()); + + _items.add( + CVException( + _model.errorMessageFor(_model.FETCH_PROJECT_DETAILS), + ), + ); + } return ListView( shrinkWrap: true, padding: const EdgeInsets.all(16), diff --git a/lib/utils/cv_exception.dart b/lib/utils/cv_exception.dart new file mode 100644 index 00000000..897ee709 --- /dev/null +++ b/lib/utils/cv_exception.dart @@ -0,0 +1,12 @@ +import 'package:flutter/material.dart'; + +class CVException extends StatelessWidget { + final String message; + CVException(this.message); + @override + Widget build(BuildContext context) { + return Container( + child: Text(message), + ); + } +} From 402bdbf4fc151ac117ffb223f424fc707b06f915 Mon Sep 17 00:00:00 2001 From: Roopak Bedekar Date: Fri, 10 Sep 2021 14:02:32 +0530 Subject: [PATCH 2/2] fix : failed to load / error widget --- lib/{utils => ui/components}/cv_exception.dart | 0 lib/ui/views/groups/assignment_details_view.dart | 2 +- lib/ui/views/groups/group_details_view.dart | 2 +- lib/ui/views/groups/my_groups_view.dart | 2 +- lib/ui/views/ib/ib_landing_view.dart | 2 +- lib/ui/views/profile/user_favourites_view.dart | 2 +- lib/ui/views/profile/user_projects_view.dart | 2 +- lib/ui/views/projects/featured_projects_view.dart | 2 +- lib/ui/views/projects/project_details_view.dart | 2 +- 9 files changed, 8 insertions(+), 8 deletions(-) rename lib/{utils => ui/components}/cv_exception.dart (100%) diff --git a/lib/utils/cv_exception.dart b/lib/ui/components/cv_exception.dart similarity index 100% rename from lib/utils/cv_exception.dart rename to lib/ui/components/cv_exception.dart diff --git a/lib/ui/views/groups/assignment_details_view.dart b/lib/ui/views/groups/assignment_details_view.dart index 700f7910..0aa44540 100644 --- a/lib/ui/views/groups/assignment_details_view.dart +++ b/lib/ui/views/groups/assignment_details_view.dart @@ -14,7 +14,7 @@ import 'package:mobile_app/ui/components/cv_primary_button.dart'; import 'package:mobile_app/ui/components/cv_text_field.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/groups/update_assignment_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/utils/validators.dart'; import 'package:mobile_app/viewmodels/groups/assignment_details_viewmodel.dart'; diff --git a/lib/ui/views/groups/group_details_view.dart b/lib/ui/views/groups/group_details_view.dart index a86a7c19..707032c2 100644 --- a/lib/ui/views/groups/group_details_view.dart +++ b/lib/ui/views/groups/group_details_view.dart @@ -12,7 +12,7 @@ import 'package:mobile_app/ui/views/groups/components/assignment_card.dart'; import 'package:mobile_app/ui/views/groups/components/member_card.dart'; import 'package:mobile_app/ui/views/groups/edit_group_view.dart'; import 'package:mobile_app/ui/views/groups/update_assignment_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/utils/validators.dart'; import 'package:mobile_app/ui/components/cv_flat_button.dart'; diff --git a/lib/ui/views/groups/my_groups_view.dart b/lib/ui/views/groups/my_groups_view.dart index a7545638..ce3ac1b9 100644 --- a/lib/ui/views/groups/my_groups_view.dart +++ b/lib/ui/views/groups/my_groups_view.dart @@ -11,7 +11,7 @@ import 'package:mobile_app/ui/views/groups/components/group_member_card.dart'; import 'package:mobile_app/ui/views/groups/components/group_mentor_card.dart'; import 'package:mobile_app/ui/views/groups/edit_group_view.dart'; import 'package:mobile_app/ui/views/groups/new_group_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/viewmodels/groups/my_groups_viewmodel.dart'; diff --git a/lib/ui/views/ib/ib_landing_view.dart b/lib/ui/views/ib/ib_landing_view.dart index 6b8373a6..2233d8aa 100644 --- a/lib/ui/views/ib/ib_landing_view.dart +++ b/lib/ui/views/ib/ib_landing_view.dart @@ -6,7 +6,7 @@ import 'package:mobile_app/models/ib/ib_chapter.dart'; import 'package:mobile_app/ui/components/cv_drawer_tile.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/ib/ib_page_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/viewmodels/ib/ib_landing_viewmodel.dart'; import 'package:theme_provider/theme_provider.dart'; diff --git a/lib/ui/views/profile/user_favourites_view.dart b/lib/ui/views/profile/user_favourites_view.dart index f4e0c2af..9d5f1a67 100644 --- a/lib/ui/views/profile/user_favourites_view.dart +++ b/lib/ui/views/profile/user_favourites_view.dart @@ -5,7 +5,7 @@ import 'package:mobile_app/ui/components/cv_add_icon_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/projects/components/project_card.dart'; import 'package:mobile_app/ui/views/projects/project_details_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/viewmodels/profile/user_favourites_viewmodel.dart'; class UserFavouritesView extends StatefulWidget { diff --git a/lib/ui/views/profile/user_projects_view.dart b/lib/ui/views/profile/user_projects_view.dart index 319f5ff8..d00d7134 100644 --- a/lib/ui/views/profile/user_projects_view.dart +++ b/lib/ui/views/profile/user_projects_view.dart @@ -4,7 +4,7 @@ import 'package:mobile_app/ui/components/cv_add_icon_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/projects/components/project_card.dart'; import 'package:mobile_app/ui/views/projects/project_details_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/viewmodels/profile/user_projects_viewmodel.dart'; class UserProjectsView extends StatefulWidget { diff --git a/lib/ui/views/projects/featured_projects_view.dart b/lib/ui/views/projects/featured_projects_view.dart index a48446a0..9ad0b53c 100644 --- a/lib/ui/views/projects/featured_projects_view.dart +++ b/lib/ui/views/projects/featured_projects_view.dart @@ -5,7 +5,7 @@ import 'package:mobile_app/ui/components/cv_primary_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/projects/components/featured_project_card.dart'; import 'package:mobile_app/ui/views/projects/project_details_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/viewmodels/projects/featured_projects_viewmodel.dart'; class FeaturedProjectsView extends StatefulWidget { diff --git a/lib/ui/views/projects/project_details_view.dart b/lib/ui/views/projects/project_details_view.dart index 9aa02f7c..7d330f63 100644 --- a/lib/ui/views/projects/project_details_view.dart +++ b/lib/ui/views/projects/project_details_view.dart @@ -14,7 +14,7 @@ import 'package:mobile_app/ui/components/cv_flat_button.dart'; import 'package:mobile_app/ui/views/base_view.dart'; import 'package:mobile_app/ui/views/profile/profile_view.dart'; import 'package:mobile_app/ui/views/projects/edit_project_view.dart'; -import 'package:mobile_app/utils/cv_exception.dart'; +import 'package:mobile_app/ui/components/cv_exception.dart'; import 'package:mobile_app/utils/snackbar_utils.dart'; import 'package:mobile_app/utils/validators.dart'; import 'package:mobile_app/viewmodels/projects/project_details_viewmodel.dart';