Skip to content

Commit

Permalink
fix: failed to load widget/error widget (#134)
Browse files Browse the repository at this point in the history
* fix - failed to load widget/error widget

* fix : failed to load / error widget
  • Loading branch information
roopak99 authored Sep 11, 2021
1 parent 085cddc commit d3fd49c
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/ui/components/cv_exception.dart
Original file line number Diff line number Diff line change
@@ -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),
);
}
}
9 changes: 9 additions & 0 deletions lib/ui/views/groups/assignment_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/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';
Expand Down Expand Up @@ -463,6 +464,14 @@ class _AssignmentDetailsViewState extends State<AssignmentDetailsView> {
_buildGrades(),
],
),
if (_model.isError(_model.FETCH_ASSIGNMENT_DETAILS))
Column(
children: <Widget>[
CVException(
_model.errorMessageFor(_model.FETCH_ASSIGNMENT_DETAILS),
),
],
),
],
);
}),
Expand Down
8 changes: 8 additions & 0 deletions lib/ui/views/groups/group_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/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';
Expand Down Expand Up @@ -407,6 +408,13 @@ class _GroupDetailsViewState extends State<GroupDetailsView> {
);
});
}
if (_model.isError(_model.FETCH_GROUP_DETAILS)) {
_items.add(
CVException(
_model.errorMessageFor(_model.FETCH_GROUP_DETAILS),
),
);
}

return ListView(
padding: const EdgeInsets.all(8),
Expand Down
15 changes: 15 additions & 0 deletions lib/ui/views/groups/my_groups_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/ui/components/cv_exception.dart';
import 'package:mobile_app/utils/snackbar_utils.dart';
import 'package:mobile_app/viewmodels/groups/my_groups_viewmodel.dart';

Expand Down Expand Up @@ -135,6 +136,13 @@ class _MyGroupsViewState extends State<MyGroupsView> {
);
}
}
if (_model.isError(_model.FETCH_MENTORED_GROUPS)) {
_items.add(
CVException(
_model.errorMessageFor(_model.FETCH_MENTORED_GROUPS),
),
);
}

_items.add(SizedBox(height: 24));

Expand All @@ -153,6 +161,13 @@ class _MyGroupsViewState extends State<MyGroupsView> {
);
}
}
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),
Expand Down
5 changes: 3 additions & 2 deletions lib/ui/views/ib/ib_landing_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/ui/components/cv_exception.dart';
import 'package:mobile_app/viewmodels/ib/ib_landing_viewmodel.dart';
import 'package:theme_provider/theme_provider.dart';

Expand Down Expand Up @@ -159,8 +160,8 @@ class _IbLandingViewState extends State<IbLandingView> {
),
!_model.isSuccess(_model.IB_FETCH_CHAPTERS)
? InkWell(
child: CVDrawerTile(
title: 'Loading...',
child: CVException(
_model.errorMessageFor(_model.IB_FETCH_CHAPTERS),
),
)
: _buildChapters(_model.chapters),
Expand Down
8 changes: 8 additions & 0 deletions lib/ui/views/profile/user_favourites_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/ui/components/cv_exception.dart';
import 'package:mobile_app/viewmodels/profile/user_favourites_viewmodel.dart';

class UserFavouritesView extends StatefulWidget {
Expand Down Expand Up @@ -46,6 +47,13 @@ class _UserFavouritesViewState extends State<UserFavouritesView>
);
});
}
if (model.isError(model.FETCH_USER_FAVOURITES)) {
_items.add(
CVException(
model.errorMessageFor(model.FETCH_USER_FAVOURITES),
),
);
}

if (model?.previousUserFavouritesBatch?.links?.next != null) {
_items.add(
Expand Down
9 changes: 9 additions & 0 deletions lib/ui/views/profile/user_projects_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/ui/components/cv_exception.dart';
import 'package:mobile_app/viewmodels/profile/user_projects_viewmodel.dart';

class UserProjectsView extends StatefulWidget {
Expand Down Expand Up @@ -44,6 +45,14 @@ class _UserProjectsViewState extends State<UserProjectsView>
});
}

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(
Expand Down
8 changes: 8 additions & 0 deletions lib/ui/views/projects/featured_projects_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/ui/components/cv_exception.dart';
import 'package:mobile_app/viewmodels/projects/featured_projects_viewmodel.dart';

class FeaturedProjectsView extends StatefulWidget {
Expand Down Expand Up @@ -42,6 +43,13 @@ class _FeaturedProjectsViewState extends State<FeaturedProjectsView> {
);
});
}
if (model.isError(model.FETCH_FEATURED_PROJECTS)) {
_items.add(
CVException(
model.errorMessageFor(model.FETCH_FEATURED_PROJECTS),
),
);
}

if (!widget.embed &&
model?.previousFeaturedProjectsBatch?.links?.next != null) {
Expand Down
10 changes: 10 additions & 0 deletions lib/ui/views/projects/project_details_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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/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';
Expand Down Expand Up @@ -624,6 +625,15 @@ class _ProjectDetailsViewState extends State<ProjectDetailsView> {
);
});
}
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),
Expand Down

0 comments on commit d3fd49c

Please sign in to comment.