bug fixes
This commit is contained in:
parent
257e4b6a59
commit
6853af3d21
|
|
@ -195,6 +195,11 @@ class CommentsState extends CoreProvier {
|
|||
);
|
||||
}
|
||||
comments.remove(comment);
|
||||
} else {
|
||||
comments
|
||||
.firstWhere((element) => element.id == rootId)
|
||||
.replies
|
||||
.removeWhere((element) => element.id == id);
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import 'package:didvan/views/home/widgets/categories_gird.dart';
|
|||
import 'package:didvan/views/home/widgets/categories_list.dart';
|
||||
import 'package:didvan/views/home/widgets/logo_app_bar.dart';
|
||||
import 'package:didvan/views/widgets/animated_visibility.dart';
|
||||
import 'package:didvan/views/widgets/didvan/divider.dart';
|
||||
import 'package:didvan/views/widgets/didvan/text.dart';
|
||||
import 'package:didvan/views/widgets/state_handlers/empty_list.dart';
|
||||
import 'package:didvan/views/widgets/state_handlers/sliver_state_handler.dart';
|
||||
|
|
@ -61,7 +62,8 @@ class _StatisticState extends State<Statistic> {
|
|||
const SliverToBoxAdapter(
|
||||
child: SizedBox(height: 180),
|
||||
),
|
||||
if (state.appState != AppState.failed)
|
||||
if (state.appState != AppState.failed &&
|
||||
state.markedStatistics.isNotEmpty)
|
||||
SliverPadding(
|
||||
padding: const EdgeInsets.only(right: 16, bottom: 20),
|
||||
sliver: SliverToBoxAdapter(
|
||||
|
|
@ -80,7 +82,7 @@ class _StatisticState extends State<Statistic> {
|
|||
),
|
||||
),
|
||||
SliverStateHandler<StatisticState>(
|
||||
onRetry: () => state.getStatistic(page: state.page),
|
||||
onRetry: state.getStatistic,
|
||||
state: state,
|
||||
itemPadding: const EdgeInsets.only(
|
||||
bottom: 20,
|
||||
|
|
@ -91,12 +93,16 @@ class _StatisticState extends State<Statistic> {
|
|||
enableEmptyState: _itemCount(state) == 0,
|
||||
placeholder: StatisticOverview.placeHolder,
|
||||
builder: (context, state, index) {
|
||||
if (index == state.markedStatistics.length) {
|
||||
return const DidvanDivider(verticalPadding: 8);
|
||||
}
|
||||
bool isMarked = false;
|
||||
StatisticData statistic;
|
||||
if (index < state.markedStatistics.length) {
|
||||
isMarked = true;
|
||||
statistic = state.markedStatistics[index];
|
||||
} else {
|
||||
index--;
|
||||
statistic =
|
||||
state.statistics[index - state.markedStatistics.length];
|
||||
}
|
||||
|
|
@ -106,7 +112,7 @@ class _StatisticState extends State<Statistic> {
|
|||
onMarkChanged: state.changeMark,
|
||||
);
|
||||
},
|
||||
childCount: _itemCount(state),
|
||||
childCount: _itemCount(state) + 1,
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: SizedBox(
|
||||
|
|
@ -136,7 +142,7 @@ class _StatisticState extends State<Statistic> {
|
|||
isColapsed: state.isColapsed,
|
||||
onSelected: (id) {
|
||||
state.selectedCategoryId = id;
|
||||
state.getStatistic(page: 1);
|
||||
state.getStatistic();
|
||||
},
|
||||
selectedCats: state.selectedCategory == null
|
||||
? []
|
||||
|
|
@ -157,7 +163,7 @@ class _StatisticState extends State<Statistic> {
|
|||
if (category.id != 0) {
|
||||
state.selectedCategoryId = category.id;
|
||||
}
|
||||
state.getStatistic(page: 1);
|
||||
state.getStatistic();
|
||||
}
|
||||
|
||||
void _handleAnimations([bool forceAnimate = false]) async {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import 'package:didvan/services/network/request.dart';
|
|||
import 'package:didvan/services/network/request_helper.dart';
|
||||
|
||||
class StatisticState extends CoreProvier {
|
||||
int page = 1;
|
||||
bool isScrolled = false;
|
||||
bool shouldColapse = false;
|
||||
int selectedCategoryId = -1;
|
||||
|
|
@ -25,24 +24,10 @@ class StatisticState extends CoreProvier {
|
|||
|
||||
bool get isCategorySelected => selectedCategoryId != 0;
|
||||
|
||||
void resetFilters(bool isInit) {
|
||||
selectedCategoryId = 0;
|
||||
isScrolled = false;
|
||||
if (!isInit) {
|
||||
getStatistic(page: 1);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getStatistic({
|
||||
required int page,
|
||||
}) async {
|
||||
this.page = page;
|
||||
if (this.page == page) {
|
||||
Future<void> getStatistic() async {
|
||||
statistics.clear();
|
||||
}
|
||||
if (page == 1) {
|
||||
markedStatistics.clear();
|
||||
appState = AppState.busy;
|
||||
}
|
||||
final RequestService service = RequestService(
|
||||
RequestHelper.statisticOverviews(
|
||||
selectedCategoryId == 0 || selectedCategoryId == 1
|
||||
|
|
@ -58,7 +43,7 @@ class StatisticState extends CoreProvier {
|
|||
}
|
||||
final marked = service.result['marked'];
|
||||
for (var i = 0; i < marked.length; i++) {
|
||||
statistics.add(StatisticData.fromJson(marked[i]));
|
||||
markedStatistics.add(StatisticData.fromJson(marked[i]));
|
||||
}
|
||||
if (isColapsed || isCategorySelected) {
|
||||
shouldColapse = true;
|
||||
|
|
@ -66,7 +51,6 @@ class StatisticState extends CoreProvier {
|
|||
appState = AppState.idle;
|
||||
return;
|
||||
}
|
||||
|
||||
appState = AppState.failed;
|
||||
}
|
||||
|
||||
|
|
@ -85,9 +69,12 @@ class StatisticState extends CoreProvier {
|
|||
}
|
||||
|
||||
void init() {
|
||||
resetFilters(true);
|
||||
selectedCategoryId = 0;
|
||||
isScrolled = false;
|
||||
markedStatistics.clear();
|
||||
statistics.clear();
|
||||
Future.delayed(Duration.zero, () {
|
||||
getStatistic(page: 1);
|
||||
getStatistic();
|
||||
});
|
||||
categories = [
|
||||
CategoryData(
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ class DidvanAppBar extends StatelessWidget {
|
|||
),
|
||||
)
|
||||
: null,
|
||||
color: backgroundColor ?? Theme.of(context).colorScheme.background,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
|
|
|
|||
|
|
@ -59,11 +59,15 @@ class _DidvanScaffoldState extends State<DidvanScaffold> {
|
|||
SliverAppBar(
|
||||
toolbarHeight: (widget.appBarData!.isSmall ? 56 : 72) -
|
||||
statusBarHeight,
|
||||
backgroundColor: widget.backgroundColor ??
|
||||
Theme.of(context).colorScheme.background,
|
||||
automaticallyImplyLeading: false,
|
||||
pinned: true,
|
||||
flexibleSpace: DidvanAppBar(appBarData: widget.appBarData!),
|
||||
backgroundColor: widget.backgroundColor ??
|
||||
Theme.of(context).colorScheme.background,
|
||||
flexibleSpace: DidvanAppBar(
|
||||
appBarData: widget.appBarData!,
|
||||
backgroundColor: widget.backgroundColor ??
|
||||
Theme.of(context).colorScheme.background,
|
||||
),
|
||||
),
|
||||
if (widget.children != null && !widget.showSliversFirst)
|
||||
SliverPadding(
|
||||
|
|
|
|||
Loading…
Reference in New Issue