Skip to content

Commit

Permalink
fix Loading error
Browse files Browse the repository at this point in the history
  • Loading branch information
He9sham committed May 5, 2024
1 parent 4d6dbff commit 3e616d3
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 13 deletions.
27 changes: 27 additions & 0 deletions lib/core/widgets/loading_widget_error.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

class LoadingWidgetError extends StatelessWidget {
const LoadingWidgetError({super.key});
@override
Widget build(BuildContext context) {
return Center(
child: SizedBox(
width: 200.0,
height: 100.0,
child: Shimmer.fromColors(
baseColor: Colors.red,
highlightColor: Colors.yellow,
child: const Text(
'Books Loading...',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 40.0,
fontWeight: FontWeight.bold,
),
),
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:bookly_app/core/widgets/loading_widget_error.dart';
import 'package:bookly_app/features/Search/presantation/view_model/Search/search_cubit.dart';
import 'package:bookly_app/features/home/presantation/views/widgets/Best_seller_view.dart';
import 'package:flutter/material.dart';
Expand All @@ -15,17 +16,17 @@ class BooklistView extends StatelessWidget {
shrinkWrap: true,
itemCount: state.books.length,
itemBuilder: (context, index) {
return Padding(
return Padding(
padding: const EdgeInsets.symmetric(vertical: 10),
child: BestSellerViewItem( bookmodels: state.books[index]),
child: BestSellerViewItem(bookmodels: state.books[index]),
);
});
} else if (state is SearchFauiler) {
return const Center(child: Text('was an error'),);
} else {
return const Center(
child: CircularProgressIndicator(),
return Center(
child: Text(state.errmessage),
);
} else {
return const LoadingWidgetError();
}
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class SearchViewBody extends StatelessWidget {
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 16),
child: BooklistView(
),
child: BooklistView(),
),
),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:bookly_app/core/widgets/loading_widget_error.dart';
import 'package:bookly_app/features/home/presantation/view_models/newset_books_list/newset_books_list_cubit.dart';
import 'package:bookly_app/features/home/presantation/views/widgets/Best_seller_view.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -30,7 +31,7 @@ class BestSellerListView extends StatelessWidget {
);
} else {
return const Center(
child: CircularProgressIndicator(),
child: LoadingWidgetError()
);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:bookly_app/core/widgets/loading_widget_error.dart';
import 'package:bookly_app/features/home/presantation/view_models/similer_books/similar_books_cubit.dart';
import 'package:bookly_app/features/home/presantation/views/widgets/custom_list_view_item.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -38,9 +39,7 @@ class SimiletorBooKsView extends StatelessWidget {
child: Text(state.errmessage),
);
} else {
return const Center(
child: CircularProgressIndicator(),
);
return const Center(child: LoadingWidgetError());
}
},
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:bookly_app/core/widgets/loading_widget_error.dart';
import 'package:bookly_app/features/home/presantation/view_models/feature_books_list/feature_books_list_cubit.dart';
import 'package:bookly_app/features/home/presantation/views/widgets/custom_list_view_item.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -41,7 +42,7 @@ class FeatureBooksListView extends StatelessWidget {
);
} else {
return const Center(
child: CircularProgressIndicator(),
child: LoadingWidgetError(),
);
}
},
Expand Down

0 comments on commit 3e616d3

Please sign in to comment.