bug fixes

This commit is contained in:
MohammadTaha Basiri 2022-04-23 15:21:29 +04:30
parent 20c32577c5
commit 1efb779675
4 changed files with 37 additions and 28 deletions

View File

@ -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/radar.dart';
import 'package:didvan/views/home/widgets/overview/video.dart'; import 'package:didvan/views/home/widgets/overview/video.dart';
import 'package:didvan/views/widgets/didvan/scaffold.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:didvan/views/widgets/state_handlers/sliver_state_handler.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart';
@ -38,6 +39,8 @@ class _HashtagState extends State<Hashtag> {
slivers: [ slivers: [
Consumer<HashtagState>( Consumer<HashtagState>(
builder: (context, state, child) => SliverStateHandler<HashtagState>( builder: (context, state, child) => SliverStateHandler<HashtagState>(
emptyState: const EmptyList(),
enableEmptyState: state.items.isEmpty,
itemPadding: const EdgeInsets.only(bottom: 8), itemPadding: const EdgeInsets.only(bottom: 8),
state: state, state: state,
placeholder: RadarOverview.placeholder, placeholder: RadarOverview.placeholder,

View File

@ -94,7 +94,9 @@ class _StatisticState extends State<Statistic> {
placeholder: StatisticOverview.placeHolder, placeholder: StatisticOverview.placeHolder,
builder: (context, state, index) { builder: (context, state, index) {
if (index == state.markedStatistics.length) { if (index == state.markedStatistics.length) {
return const DidvanDivider(verticalPadding: 8); return index == 0
? const SizedBox()
: const DidvanDivider(verticalPadding: 8);
} }
bool isMarked = false; bool isMarked = false;
StatisticData statistic; StatisticData statistic;

View File

@ -214,30 +214,31 @@ class _StatisticDetailsState extends State<StatisticDetails> {
), ),
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
Padding( if (state.relatedContents != null)
padding: const EdgeInsets.symmetric(horizontal: 16), Padding(
child: DidvanCard( padding: const EdgeInsets.symmetric(horizontal: 16),
child: Column( child: DidvanCard(
children: [ child: Column(
if (state.relatedContents.isEmpty) children: [
for (var i = 0; i < 3; i++) ...[ if (state.relatedContents!.isEmpty)
MultitypeOverview.placeholder, for (var i = 0; i < 3; i++) ...[
if (i != 2) const SizedBox(height: 16) MultitypeOverview.placeholder,
], if (i != 2) const SizedBox(height: 16)
for (var i = 0; ],
i < state.relatedContents.length; for (var i = 0;
i++) ...[ i < state.relatedContents!.length;
MultitypeOverview( i++) ...[
item: state.relatedContents[i], MultitypeOverview(
onMarkChanged: (id, value) {}, item: state.relatedContents![i],
), onMarkChanged: (id, value) {},
if (i != state.relatedContents.length - 1) ),
const SizedBox(height: 16) if (i != state.relatedContents!.length - 1)
] const SizedBox(height: 16)
], ]
],
),
), ),
), ),
),
const SizedBox(height: 16), const SizedBox(height: 16),
], ],
), ),

View File

@ -11,12 +11,12 @@ import 'package:collection/collection.dart';
class StatisticDetailsState extends CoreProvier { class StatisticDetailsState extends CoreProvier {
late bool marked; late bool marked;
late String label; late String label;
final List<Data> datas = [];
final List<Tag> tags = [];
String? startDate; String? startDate;
String? endDate; String? endDate;
int currentDateRangeId = 0; int currentDateRangeId = 0;
final List<Data> datas = []; List<OverviewData>? relatedContents = [];
final List<OverviewData> relatedContents = [];
final List<Tag> tags = [];
Data? data; Data? data;
double maxValue = 0; double maxValue = 0;
double? minValue; double? minValue;
@ -153,7 +153,7 @@ class StatisticDetailsState extends CoreProvier {
double.parse(value.replaceAll(',', '')); double.parse(value.replaceAll(',', ''));
Future<void> getRelatedContents() async { Future<void> getRelatedContents() async {
if (relatedContents.isNotEmpty) return; if (relatedContents!.isNotEmpty) return;
final service = RequestService(RequestHelper.tag( final service = RequestService(RequestHelper.tag(
ids: tags.map((tag) => tag.id).toList(), ids: tags.map((tag) => tag.id).toList(),
)); ));
@ -161,7 +161,10 @@ class StatisticDetailsState extends CoreProvier {
if (service.isSuccess) { if (service.isSuccess) {
final relateds = service.result['contents']; final relateds = service.result['contents'];
for (var i = 0; i < relateds.length; i++) { 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(); notifyListeners();
} }