From 1efb77967585dfc0787b0b0f510a9248d0826c01 Mon Sep 17 00:00:00 2001 From: MohammadTaha Basiri Date: Sat, 23 Apr 2022 15:21:29 +0430 Subject: [PATCH] bug fixes --- lib/views/home/hashtag/hashtag.dart | 3 ++ lib/views/home/statistic/statistic.dart | 4 +- .../statistic_details/statistic_details.dart | 45 ++++++++++--------- .../statistic_details_state.dart | 13 +++--- 4 files changed, 37 insertions(+), 28 deletions(-) diff --git a/lib/views/home/hashtag/hashtag.dart b/lib/views/home/hashtag/hashtag.dart index c12e92e..551e1f2 100644 --- a/lib/views/home/hashtag/hashtag.dart +++ b/lib/views/home/hashtag/hashtag.dart @@ -7,6 +7,7 @@ import 'package:didvan/views/home/widgets/overview/podcast.dart'; import 'package:didvan/views/home/widgets/overview/radar.dart'; import 'package:didvan/views/home/widgets/overview/video.dart'; import 'package:didvan/views/widgets/didvan/scaffold.dart'; +import 'package:didvan/views/widgets/state_handlers/empty_list.dart'; import 'package:didvan/views/widgets/state_handlers/sliver_state_handler.dart'; import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; @@ -38,6 +39,8 @@ class _HashtagState extends State { slivers: [ Consumer( builder: (context, state, child) => SliverStateHandler( + emptyState: const EmptyList(), + enableEmptyState: state.items.isEmpty, itemPadding: const EdgeInsets.only(bottom: 8), state: state, placeholder: RadarOverview.placeholder, diff --git a/lib/views/home/statistic/statistic.dart b/lib/views/home/statistic/statistic.dart index 6496e79..5720ce0 100644 --- a/lib/views/home/statistic/statistic.dart +++ b/lib/views/home/statistic/statistic.dart @@ -94,7 +94,9 @@ class _StatisticState extends State { placeholder: StatisticOverview.placeHolder, builder: (context, state, index) { if (index == state.markedStatistics.length) { - return const DidvanDivider(verticalPadding: 8); + return index == 0 + ? const SizedBox() + : const DidvanDivider(verticalPadding: 8); } bool isMarked = false; StatisticData statistic; diff --git a/lib/views/home/statistic/statistic_details/statistic_details.dart b/lib/views/home/statistic/statistic_details/statistic_details.dart index ae78195..fbf92f4 100644 --- a/lib/views/home/statistic/statistic_details/statistic_details.dart +++ b/lib/views/home/statistic/statistic_details/statistic_details.dart @@ -214,30 +214,31 @@ class _StatisticDetailsState extends State { ), ), const SizedBox(height: 16), - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: DidvanCard( - child: Column( - children: [ - if (state.relatedContents.isEmpty) - for (var i = 0; i < 3; i++) ...[ - MultitypeOverview.placeholder, - if (i != 2) const SizedBox(height: 16) - ], - for (var i = 0; - i < state.relatedContents.length; - i++) ...[ - MultitypeOverview( - item: state.relatedContents[i], - onMarkChanged: (id, value) {}, - ), - if (i != state.relatedContents.length - 1) - const SizedBox(height: 16) - ] - ], + if (state.relatedContents != null) + Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: DidvanCard( + child: Column( + children: [ + if (state.relatedContents!.isEmpty) + for (var i = 0; i < 3; i++) ...[ + MultitypeOverview.placeholder, + if (i != 2) const SizedBox(height: 16) + ], + for (var i = 0; + i < state.relatedContents!.length; + i++) ...[ + MultitypeOverview( + item: state.relatedContents![i], + onMarkChanged: (id, value) {}, + ), + if (i != state.relatedContents!.length - 1) + const SizedBox(height: 16) + ] + ], + ), ), ), - ), const SizedBox(height: 16), ], ), diff --git a/lib/views/home/statistic/statistic_details/statistic_details_state.dart b/lib/views/home/statistic/statistic_details/statistic_details_state.dart index a87ef8c..f4af93d 100644 --- a/lib/views/home/statistic/statistic_details/statistic_details_state.dart +++ b/lib/views/home/statistic/statistic_details/statistic_details_state.dart @@ -11,12 +11,12 @@ import 'package:collection/collection.dart'; class StatisticDetailsState extends CoreProvier { late bool marked; late String label; + final List datas = []; + final List tags = []; String? startDate; String? endDate; int currentDateRangeId = 0; - final List datas = []; - final List relatedContents = []; - final List tags = []; + List? relatedContents = []; Data? data; double maxValue = 0; double? minValue; @@ -153,7 +153,7 @@ class StatisticDetailsState extends CoreProvier { double.parse(value.replaceAll(',', '')); Future getRelatedContents() async { - if (relatedContents.isNotEmpty) return; + if (relatedContents!.isNotEmpty) return; final service = RequestService(RequestHelper.tag( ids: tags.map((tag) => tag.id).toList(), )); @@ -161,7 +161,10 @@ class StatisticDetailsState extends CoreProvier { if (service.isSuccess) { final relateds = service.result['contents']; for (var i = 0; i < relateds.length; i++) { - relatedContents.add(OverviewData.fromJson(relateds[i])); + relatedContents!.add(OverviewData.fromJson(relateds[i])); + } + if (relatedContents!.isEmpty) { + relatedContents = null; } notifyListeners(); }