Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions lib/src/components/selection/widget/brn_selection_range_widget.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import 'package:bruno/src/components/button/brn_big_main_button.dart';
import 'package:bruno/src/components/calendar/brn_calendar_view.dart';
import 'package:bruno/src/components/line/brn_line.dart';
Expand Down Expand Up @@ -82,7 +81,7 @@ class _BrnRangeSelectionGroupWidgetState

@override
void initState() {
_screenWidth = View.of(context).physicalSize.width / View.of(context).devicePixelRatio;
super.initState();
_initData();
_tabController = TabController(vsync: this, length: _firstList.length);
if (_firstIndex >= 0) {
Expand All @@ -94,7 +93,13 @@ class _BrnRangeSelectionGroupWidgetState
? _firstList
: _firstList[_tabController.index].children);
});
super.initState();
}

@override
void didChangeDependencies() {
super.didChangeDependencies();
_screenWidth =
View.of(context).physicalSize.width / View.of(context).devicePixelRatio;
}

@override
Expand Down Expand Up @@ -237,14 +242,10 @@ class _BrnRangeSelectionGroupWidgetState

///如果指定展示列,则按照指定列展示,否则动态计算宽度。最大不超过四列。
if (widget.rowCount == null) {
int oneCountTagWidth =
(_screenWidth - 40 - 12 * (1 - 1)) ~/ 1;
int twoCountTagWidth =
(_screenWidth - 40 - 12 * (2 - 1)) ~/ 2;
int threeCountTagWidth =
(_screenWidth - 40 - 12 * (3 - 1)) ~/ 3;
int fourCountTagWidth =
(_screenWidth - 40 - 12 * (4 - 1)) ~/ 4;
int oneCountTagWidth = (_screenWidth - 40 - 12 * (1 - 1)) ~/ 1;
int twoCountTagWidth = (_screenWidth - 40 - 12 * (2 - 1)) ~/ 2;
int threeCountTagWidth = (_screenWidth - 40 - 12 * (3 - 1)) ~/ 3;
int fourCountTagWidth = (_screenWidth - 40 - 12 * (4 - 1)) ~/ 4;
if (maxWidthSize.width > twoCountTagWidth) {
tagWidth = oneCountTagWidth;
} else if (threeCountTagWidth < maxWidthSize.width &&
Expand All @@ -257,10 +258,8 @@ class _BrnRangeSelectionGroupWidgetState
tagWidth = fourCountTagWidth;
}
} else {
tagWidth = (_screenWidth -
40 -
12 * (widget.rowCount! - 1)) ~/
widget.rowCount!;
tagWidth =
(_screenWidth - 40 - 12 * (widget.rowCount! - 1)) ~/ widget.rowCount!;
}

var tagContainer = tagFilterList.isNotEmpty
Expand Down Expand Up @@ -435,12 +434,15 @@ class _BrnRangeSelectionGroupWidgetState
if (!rangeEntity.isValidRange()) {
FocusScope.of(context).requestFocus(FocusNode());
if (rangeEntity.filterType == BrnSelectionFilterType.range) {
BrnToast.show(BrnIntl.of(context).localizedResource.enterRangeError, context);
BrnToast.show(
BrnIntl.of(context).localizedResource.enterRangeError, context);
} else if (rangeEntity.filterType ==
BrnSelectionFilterType.dateRange ||
rangeEntity.filterType ==
BrnSelectionFilterType.dateRangeCalendar) {
BrnToast.show(BrnIntl.of(context).localizedResource.selectRangeError, context);
BrnToast.show(
BrnIntl.of(context).localizedResource.selectRangeError,
context);
}
return;
}
Expand Down Expand Up @@ -664,10 +666,11 @@ class _BrnRangeSelectionGroupWidgetState
bool _hasCalendarItem(BrnSelectionEntity entity) {
bool hasCalendarItem = false;
hasCalendarItem = entity.children
.where((_) =>
_.filterType == BrnSelectionFilterType.date ||
_.filterType == BrnSelectionFilterType.dateRangeCalendar)
.toList().isNotEmpty;
.where((_) =>
_.filterType == BrnSelectionFilterType.date ||
_.filterType == BrnSelectionFilterType.dateRangeCalendar)
.toList()
.isNotEmpty;

/// 查找第二层级
if (!hasCalendarItem) {
Expand Down