Skip to content

Commit

Permalink
Fixed loading indicator in Pinned Posts (#2480)
Browse files Browse the repository at this point in the history
* Centered loading indicatior & updated tests

* minor change
  • Loading branch information
GlenDsza authored Apr 19, 2024
1 parent 2212d50 commit 45e0538
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
6 changes: 5 additions & 1 deletion lib/views/after_auth_screens/feed/pinned_post_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ class _PinnedPostScreenState extends State<PinnedPostScreen> {
cacheManager: widget.cacheManager,
imageUrl: widget.post['imageUrl']!,
errorWidget: (context, url, error) {
return const CircularProgressIndicator();
return const SizedBox(
child: Center(
child: CircularProgressIndicator(),
),
);
},
height: SizeConfig.screenHeight! * .75,
fit: BoxFit.cover,
Expand Down
12 changes: 8 additions & 4 deletions lib/views/demo_screens/organization_feed_demo.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ignore_for_file: talawa_api_doc
import 'package:flutter/material.dart';
import 'package:talawa/models/post/post_model.dart';
import 'package:talawa/utils/app_localization.dart';
Expand All @@ -19,9 +18,7 @@ class DemoOrganizationFeed extends StatelessWidget {
/// To implement the test.
final bool forTest;

/// a_line_ending_with_end_punctuation.
///
/// more_info_if_required
/// List of dummy pinned posts.
static const List<Map<String, String>> pinnedPosts = [
{
'text': 'Church Meeting',
Expand Down Expand Up @@ -88,6 +85,13 @@ class DemoOrganizationFeed extends StatelessWidget {
},
];

/// function returns a widget that shows the feed of the organization.
///
/// **params**:
/// * `context`: build context of the widget.
///
/// **returns**:
/// * `Widget`: returns a widget that shows the feed of the organization.
Widget demoOrganisationFeedPage(BuildContext context) {
return Scaffold(
appBar: AppBar(
Expand Down
18 changes: 8 additions & 10 deletions lib/widgets/pinned_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,11 @@ import 'package:talawa/services/size_config.dart';
import 'package:talawa/view_model/main_screen_view_model.dart';
import 'package:talawa/views/after_auth_screens/feed/pinned_post_screen.dart';

/// a_line_ending_with_end_punctuation.
///
/// more_info_if_required
/// PinnedPost returns a widget that shows the pinned post.
class PinnedPost extends StatelessWidget {
const PinnedPost({super.key, required this.pinnedPost, required this.model});

/// contains the pinned post.
///
final List<Post> pinnedPost;

/// gives access mainScreenViewModel's attributes.
Expand Down Expand Up @@ -58,7 +55,12 @@ class PinnedPost extends StatelessWidget {
? 'placeHolderUrl'
: pinnedPost[index].imageUrl!,
errorWidget: (context, url, error) {
return const CircularProgressIndicator();
print(error);
return const SizedBox(
child: Center(
child: CircularProgressIndicator(),
),
);
},
height: SizeConfig.screenHeight! * 0.15,
fit: BoxFit.cover,
Expand Down Expand Up @@ -104,9 +106,7 @@ class PinnedPost extends StatelessWidget {
);
}

/// converts date time to hrs.
///
/// more_info_if_required
/// Function returns the time difference in hours.
///
/// **params**:
/// * `createdAtString`: the time from post
Expand All @@ -123,8 +123,6 @@ class PinnedPost extends StatelessWidget {

/// converts post to mapped string.
///
/// more_info_if_required
///
/// **params**:
/// * `index`: current index
///
Expand Down
2 changes: 1 addition & 1 deletion test/widget_tests/widgets/pinned_post_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ void main() {
widgetTester.binding.rootElement!,
'',
Exception(),
) is CircularProgressIndicator,
) is SizedBox,
),
findsOneWidget,
);
Expand Down

0 comments on commit 45e0538

Please sign in to comment.