refactor: убрал закоментированный код
This commit is contained in:
parent
c087b6a2a2
commit
8132957bf2
@ -62,10 +62,10 @@ class _BodyState extends State<_Body> {
|
|||||||
final bloc = context.read<HomeBloc>();
|
final bloc = context.read<HomeBloc>();
|
||||||
if (!bloc.state.isPaginationLoading) {
|
if (!bloc.state.isPaginationLoading) {
|
||||||
bloc.add(HomeLoadDataEvent(
|
bloc.add(HomeLoadDataEvent(
|
||||||
search: searchController.text,
|
search: searchController.text,
|
||||||
pageNumber: bloc.state.data?.pageNumber,
|
pageNumber: bloc.state.data?.pageNumber,
|
||||||
nextPageNumber: bloc.state.data?.nextPageNumber,
|
nextPageNumber: bloc.state.data?.nextPageNumber,
|
||||||
lastPageNumber: bloc.state.data?.lastPageNumber
|
lastPageNumber: bloc.state.data?.lastPageNumber
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,7 +81,10 @@ class _BodyState extends State<_Body> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
|
padding: EdgeInsets.only(top: MediaQuery
|
||||||
|
.of(context)
|
||||||
|
.padding
|
||||||
|
.top),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
@ -94,9 +97,10 @@ class _BodyState extends State<_Body> {
|
|||||||
controller: searchController,
|
controller: searchController,
|
||||||
placeholder: context.locale.search,
|
placeholder: context.locale.search,
|
||||||
onChanged: (search) {
|
onChanged: (search) {
|
||||||
Debounce.run(() => context
|
Debounce.run(() =>
|
||||||
.read<HomeBloc>()
|
context
|
||||||
.add(HomeLoadDataEvent(search: search)));
|
.read<HomeBloc>()
|
||||||
|
.add(HomeLoadDataEvent(search: search)));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -121,47 +125,50 @@ class _BodyState extends State<_Body> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
BlocBuilder<HomeBloc, HomeState>(
|
BlocBuilder<HomeBloc, HomeState>(
|
||||||
builder: (context, state) => state.error != null
|
builder: (context, state) =>
|
||||||
|
state.error != null
|
||||||
? Text(
|
? Text(
|
||||||
state.error ?? '',
|
state.error ?? '',
|
||||||
style: Theme.of(context)
|
style: Theme
|
||||||
.textTheme
|
.of(context)
|
||||||
.headlineSmall
|
.textTheme
|
||||||
?.copyWith(color: Colors.red),
|
.headlineSmall
|
||||||
)
|
?.copyWith(color: Colors.red),
|
||||||
|
)
|
||||||
: state.isLoading
|
: state.isLoading
|
||||||
? const CircularProgressIndicator()
|
? const CircularProgressIndicator()
|
||||||
: BlocBuilder<LikeBloc, LikeState>(
|
: BlocBuilder<LikeBloc, LikeState>(
|
||||||
builder: (context, likeState) {
|
builder: (context, likeState) {
|
||||||
return Expanded(
|
return Expanded(
|
||||||
child: RefreshIndicator(
|
child: RefreshIndicator(
|
||||||
onRefresh: _onRefresh,
|
onRefresh: _onRefresh,
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
itemCount: state.data?.data?.length ?? 0,
|
itemCount: state.data?.data?.length ?? 0,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final data = state.data?.data?[index];
|
final data = state.data?.data?[index];
|
||||||
return data != null
|
return data != null
|
||||||
? _Card.fromData(
|
? _Card.fromData(
|
||||||
data,
|
data,
|
||||||
onLike: _onLike,
|
onLike: _onLike,
|
||||||
isLiked: likeState.likedIds
|
isLiked: likeState.likedIds
|
||||||
?.contains(data.id) ==
|
?.contains(data.id) ==
|
||||||
true,
|
true,
|
||||||
onTap: () =>
|
onTap: () =>
|
||||||
_navToDetails(context, data),
|
_navToDetails(context, data),
|
||||||
)
|
)
|
||||||
: const SizedBox.shrink();
|
: const SizedBox.shrink();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
BlocBuilder<HomeBloc, HomeState>(
|
BlocBuilder<HomeBloc, HomeState>(
|
||||||
builder: (context, state) => state.isPaginationLoading
|
builder: (context, state) =>
|
||||||
|
state.isPaginationLoading
|
||||||
? const CircularProgressIndicator()
|
? const CircularProgressIndicator()
|
||||||
: const SizedBox.shrink(),
|
: const SizedBox.shrink(),
|
||||||
),
|
),
|
||||||
@ -205,27 +212,3 @@ class _BodyState extends State<_Body> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// @override
|
|
||||||
// Widget build(BuildContext context) {
|
|
||||||
// final data = ApiRepository().loadData();
|
|
||||||
// return Center(
|
|
||||||
// child: FutureBuilder<List<CardData>?>(
|
|
||||||
// future: data,
|
|
||||||
// builder: (context, snapshot) => SingleChildScrollView(
|
|
||||||
// child: snapshot.hasData
|
|
||||||
// ? Column(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
// children: snapshot.data
|
|
||||||
// ?.map((data) => CardPost.fromData(data,
|
|
||||||
// onLike: (String title, bool isLiked) =>
|
|
||||||
// _showSnackBar(context, title, isLiked),
|
|
||||||
// onTap: () => _navToDetails(context, data)))
|
|
||||||
// .toList() ??
|
|
||||||
// [])
|
|
||||||
// : const CircularProgressIndicator(),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user