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