From eadfa391fd20b615e36c2183a3666a04cdcdb56d Mon Sep 17 00:00:00 2001 From: mehrdad78 Date: Fri, 12 Apr 2024 23:28:15 +0330 Subject: [PATCH] some little changes --- .../new_statistic/general_item_model.dart | 4 ++ lib/services/network/request_helper.dart | 2 +- .../home/infography/infography_screen.dart | 6 +++ .../home/new_statistic/new_statistic.dart | 8 +-- .../stat_cats_general_screen.dart | 7 +++ .../stat_cats_general_state.dart | 6 ++- .../home/new_statistic/stock/total_type3.dart | 54 +------------------ .../home/new_statistic/stock/total_type4.dart | 38 +------------ .../widgets/general_stat_card.dart | 26 +++++---- lib/views/widgets/overview/multitype.dart | 9 ++-- 10 files changed, 49 insertions(+), 111 deletions(-) diff --git a/lib/models/new_statistic/general_item_model.dart b/lib/models/new_statistic/general_item_model.dart index c810ecb..176146d 100644 --- a/lib/models/new_statistic/general_item_model.dart +++ b/lib/models/new_statistic/general_item_model.dart @@ -24,11 +24,13 @@ class Content { final int id; final String label; final String title; + final int category; final int type; final bool marked; final Data data; Content({ + required this.category, required this.id, required this.label, required this.title, @@ -45,6 +47,7 @@ class Content { type: json['type'], marked: json['marked'], data: Data.fromJson(json['data']), + category: json['category'], ); } @@ -53,6 +56,7 @@ class Content { 'id': id, 'label': label, 'title': title, + 'category': category, 'type': type, 'marked': marked, 'data': data.toJson(), diff --git a/lib/services/network/request_helper.dart b/lib/services/network/request_helper.dart index 9e728f6..1693f9d 100644 --- a/lib/services/network/request_helper.dart +++ b/lib/services/network/request_helper.dart @@ -38,7 +38,7 @@ class RequestHelper { String? search, List? types, }) => - '$_baseHomeUrl/mark${_urlConcatGenerator([ + '$_baseHomeUrl/mark/v2${_urlConcatGenerator([ MapEntry('page', page), MapEntry('q', search), MapEntry('type', _urlListConcatGenerator(types)), diff --git a/lib/views/home/infography/infography_screen.dart b/lib/views/home/infography/infography_screen.dart index b1957c4..1d48f62 100644 --- a/lib/views/home/infography/infography_screen.dart +++ b/lib/views/home/infography/infography_screen.dart @@ -11,6 +11,7 @@ import 'package:didvan/views/widgets/didvan/checkbox.dart'; import 'package:didvan/views/widgets/didvan/text.dart'; import 'package:didvan/views/widgets/item_title.dart'; import 'package:didvan/views/widgets/search_field.dart'; +import 'package:didvan/views/widgets/state_handlers/empty_result.dart'; import 'package:didvan/views/widgets/state_handlers/state_handler.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; @@ -144,6 +145,10 @@ class _InfographyScreenState extends State { @override Widget build(BuildContext context) { return StateHandler( + emptyState: EmptyResult( + onNewSearch: () => _focusNode.requestFocus(), + ), + enableEmptyState: context.watch().contents.isEmpty, onRetry: context.read().init, state: context.watch(), builder: (context, state) { @@ -170,6 +175,7 @@ class _InfographyScreenState extends State { onChanged: _onChanged, focusNode: _focusNode, onFilterButtonPressed: _showFilterBottomSheet, + value: state.lastSearch, isFiltered: state.filtering), ), Expanded( diff --git a/lib/views/home/new_statistic/new_statistic.dart b/lib/views/home/new_statistic/new_statistic.dart index 8c5734c..fd22ce8 100644 --- a/lib/views/home/new_statistic/new_statistic.dart +++ b/lib/views/home/new_statistic/new_statistic.dart @@ -128,7 +128,7 @@ class _NewStatisticState extends State { arguments: { "id": 2, "title": state.contents[2].header - }); + }).then((value) => _reset()); }), child: StatHeader( header: state.contents[2].header, @@ -151,7 +151,7 @@ class _NewStatisticState extends State { onTap: () => Future.delayed(Duration.zero, () { Navigator.of(context).pushNamed(Routes.statGeneral, arguments: {"id": 3, "title": state.contents[3].header}); - }), + }).then((value) => _reset()), child: StatHeader( header: state.contents[3].header, icon: DidvanIcons.commodity_solid, @@ -176,7 +176,7 @@ class _NewStatisticState extends State { arguments: { "id": 4, "title": state.contents[4].header - }); + }).then((value) => _reset()); }), child: StatHeader( header: state.contents[4].header, @@ -201,7 +201,7 @@ class _NewStatisticState extends State { .pushNamed(Routes.statGeneral, arguments: { "id": 5, "title": state.contents[5].header, - }); + }).then((value) => _reset()); }), child: StatHeader( header: state.contents[5].header, diff --git a/lib/views/home/new_statistic/statistics_details/stat_cats_general_screen.dart b/lib/views/home/new_statistic/statistics_details/stat_cats_general_screen.dart index 87be240..fa58be6 100644 --- a/lib/views/home/new_statistic/statistics_details/stat_cats_general_screen.dart +++ b/lib/views/home/new_statistic/statistics_details/stat_cats_general_screen.dart @@ -4,6 +4,7 @@ import 'package:didvan/views/home/new_statistic/statistics_details/stat_cats_gen import 'package:didvan/views/home/new_statistic/widgets/general_stat_card.dart'; import 'package:didvan/views/widgets/didvan/text.dart'; import 'package:didvan/views/widgets/search_field.dart'; +import 'package:didvan/views/widgets/state_handlers/empty_result.dart'; import 'package:didvan/views/widgets/state_handlers/state_handler.dart'; import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; @@ -76,6 +77,11 @@ class _StatGeneralScreenState extends State { return StateHandler( onRetry: context.read().init, state: context.watch(), + emptyState: EmptyResult( + onNewSearch: () => _focusNode.requestFocus(), + ), + enableEmptyState: + context.watch().contents.isEmpty, builder: (context, state) { return Scaffold( appBar: AppBar( @@ -99,6 +105,7 @@ class _StatGeneralScreenState extends State { title: widget.pageData['title'], onChanged: _onChanged, focusNode: _focusNode, + value: state.lastSearch, ), ), Padding( diff --git a/lib/views/home/new_statistic/statistics_details/stat_cats_general_state.dart b/lib/views/home/new_statistic/statistics_details/stat_cats_general_state.dart index ae4dd4c..018d56e 100644 --- a/lib/views/home/new_statistic/statistics_details/stat_cats_general_state.dart +++ b/lib/views/home/new_statistic/statistics_details/stat_cats_general_state.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:didvan/models/enums.dart'; import 'package:didvan/models/new_statistic/general_item_model.dart'; import 'package:didvan/models/requests/newstats_general.dart'; @@ -51,8 +53,8 @@ class StatGeneralScreenState extends CoreProvier { } void resetFilters(bool isInit) { - search = ''; - lastSearch = ''; + // search = ''; + // lastSearch = ''; if (!isInit) { getGeneralStatContent(page: 1, id: type); } diff --git a/lib/views/home/new_statistic/stock/total_type3.dart b/lib/views/home/new_statistic/stock/total_type3.dart index 2d20508..540e673 100644 --- a/lib/views/home/new_statistic/stock/total_type3.dart +++ b/lib/views/home/new_statistic/stock/total_type3.dart @@ -87,7 +87,7 @@ class TotalType3Card extends StatelessWidget { ), ), SizedBox( - width: 45, + width: 52, child: Center( child: DidvanText( overflow: TextOverflow.fade, @@ -110,6 +110,7 @@ class TotalType3Card extends StatelessWidget { ? Theme.of(context).colorScheme.success : Theme.of(context).colorScheme.error), DidvanText("${e.dp}%", + style: Theme.of(context).textTheme.bodySmall, color: totalContent.id == 36 ? Theme.of(context).colorScheme.success : Theme.of(context).colorScheme.error), @@ -121,57 +122,6 @@ class TotalType3Card extends StatelessWidget { ) .toList(), ) - // SizedBox( - // width: MediaQuery.of(context).size.width, - // height: MediaQuery.of(context).size.width / 2, - // child: ListView.builder( - // physics: NeverScrollableScrollPhysics(), - // itemCount: totalContent.data.length, - // itemBuilder: (context, index) => Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // children: [ - // SizedBox( - // width: MediaQuery.of(context).size.width * 0.25, - // child: DidvanText( - // totalContent.data[index].name.toString(), - // overflow: TextOverflow.fade, - // style: Theme.of(context).textTheme.bodySmall, - // ), - // ), - // SizedBox( - // width: 40, - // child: Center( - // child: DidvanText( - // totalContent.data[index].p.toString(), - // style: Theme.of(context).textTheme.bodySmall, - // ), - // ), - // ), - // SizedBox( - // width: MediaQuery.of(context).size.width * 0.25, - // child: Row( - // mainAxisAlignment: MainAxisAlignment.end, - // children: [ - // Icon( - // totalContent.id == 36 - // ? DidvanIcons.angle_up_regular - // : DidvanIcons.angle_down_regular, - // size: 14, - // color: totalContent.id == 36 - // ? Theme.of(context).colorScheme.success - // : Theme.of(context).colorScheme.error), - // DidvanText( - // totalContent.data[index].dp.toString() + "%", - // color: totalContent.id == 36 - // ? Theme.of(context).colorScheme.success - // : Theme.of(context).colorScheme.error), - // ], - // ), - // ) - // ], - // ), - // ), - // ), ], ), ), diff --git a/lib/views/home/new_statistic/stock/total_type4.dart b/lib/views/home/new_statistic/stock/total_type4.dart index c4193e6..09736bd 100644 --- a/lib/views/home/new_statistic/stock/total_type4.dart +++ b/lib/views/home/new_statistic/stock/total_type4.dart @@ -59,7 +59,6 @@ class TotalType4Card extends StatelessWidget { ), ], ), - Column( children: totalContent.data .map((e) => Row( @@ -83,6 +82,7 @@ class TotalType4Card extends StatelessWidget { child: Directionality( textDirection: TextDirection.ltr, child: DidvanText( + style: Theme.of(context).textTheme.bodySmall, e.p.toString(), textAlign: TextAlign.start, ), @@ -92,42 +92,6 @@ class TotalType4Card extends StatelessWidget { )) .toList(), ) - // SizedBox( - // width: MediaQuery.of(context).size.width, - // height: MediaQuery.of(context).size.width / 2, - // child: ListView.builder( - // physics: NeverScrollableScrollPhysics(), - // itemCount: totalContent.data.length, - // itemBuilder: (context, index) => Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // SizedBox( - // width: MediaQuery.of(context).size.width * 0.25, - // child: DidvanText( - // totalContent.data[index].name.toString(), - // overflow: TextOverflow.fade, - // style: Theme.of(context).textTheme.bodySmall, - // ), - // ), - // DidvanText( - // totalContent.data[index].v.toString(), - // style: Theme.of(context).textTheme.bodySmall, - // ), - // SizedBox( - // width: MediaQuery.of(context).size.width * 0.25, - // child: Directionality( - // textDirection: TextDirection.ltr, - // child: DidvanText( - // totalContent.data[index].p.toString(), - // textAlign: TextAlign.start, - // ), - // ), - // ) - // ], - // ), - // ), - // ), ], ), ), diff --git a/lib/views/home/new_statistic/widgets/general_stat_card.dart b/lib/views/home/new_statistic/widgets/general_stat_card.dart index 4533675..ab5e949 100644 --- a/lib/views/home/new_statistic/widgets/general_stat_card.dart +++ b/lib/views/home/new_statistic/widgets/general_stat_card.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:didvan/config/theme_data.dart'; import 'package:didvan/constants/app_icons.dart'; import 'package:didvan/models/new_statistic/general_item_model.dart'; @@ -49,18 +51,20 @@ class _NewStatisticOverviewCardState extends State { builder: (context, state) => Padding( padding: const EdgeInsets.all(8.0), child: DidvanCard( - onTap: () => widget.statistic.id != 5 - ? Navigator.of(context) + onTap: () { + if (widget.statistic.category != 5) { + Navigator.of(context) .pushNamed(Routes.statisticDetails, arguments: { - 'onMarkChanged': (value) => - widget.onMarkChanged(widget.statistic.id, value), - 'label': widget.statistic.label, - 'title': widget.statistic.title, - 'marked': widget.statistic.marked, - }).then( - (value) => state.getGeneralStatContent(page: 1, id: 7), - ) - : null, + 'onMarkChanged': (value) => + widget.onMarkChanged(widget.statistic.id, value), + 'label': widget.statistic.label, + 'title': widget.statistic.title, + 'marked': widget.statistic.marked, + }).then( + (value) => state.getGeneralStatContent(page: 1), + ); + } + }, child: Column( children: [ Row( diff --git a/lib/views/widgets/overview/multitype.dart b/lib/views/widgets/overview/multitype.dart index 11246de..2fd88ac 100644 --- a/lib/views/widgets/overview/multitype.dart +++ b/lib/views/widgets/overview/multitype.dart @@ -128,7 +128,7 @@ class MultitypeOverview extends StatelessWidget { children: [ Stack( children: [ - SkeletonImage(imageUrl: item.image, height: 80, width: 80), + SkeletonImage(imageUrl: item.image, height: 80, width: 60), Container( padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 8), @@ -162,10 +162,11 @@ class MultitypeOverview extends StatelessWidget { ), Flexible( child: Row( + crossAxisAlignment: CrossAxisAlignment.center, children: [ const Icon( DidvanIcons.calendar_day_light, - size: 12, + size: 16, ), const SizedBox(width: 4), DidvanText( @@ -176,12 +177,12 @@ class MultitypeOverview extends StatelessWidget { if ((item.timeToRead ?? item.duration) != null) ...[ const Icon( DidvanIcons.timer_light, - size: 18, + size: 16, ), const SizedBox(width: 4), DidvanText( item.timeToRead != null - ? 'خواندن در ${item.timeToRead} دقیقه' + ? '${item.timeToRead} دقیقه' : DateTimeUtils.normalizeTimeDuration( Duration(seconds: item.duration!), ),