mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: remove limit of ninegridview
This commit is contained in:
@@ -129,9 +129,8 @@ class NineGridView extends StatefulWidget {
|
|||||||
class _NineGridViewState extends State<NineGridView> {
|
class _NineGridViewState extends State<NineGridView> {
|
||||||
/// init view size.
|
/// init view size.
|
||||||
Rect _initSize(BuildContext context) {
|
Rect _initSize(BuildContext context) {
|
||||||
int itemCount = math.min(9, widget.itemCount);
|
|
||||||
EdgeInsets padding = widget.padding;
|
EdgeInsets padding = widget.padding;
|
||||||
if (itemCount == 0) {
|
if (widget.itemCount == 0) {
|
||||||
return Rect.fromLTRB(0, 0, padding.horizontal, padding.vertical);
|
return Rect.fromLTRB(0, 0, padding.horizontal, padding.vertical);
|
||||||
}
|
}
|
||||||
double width = widget.width ??
|
double width = widget.width ??
|
||||||
@@ -140,15 +139,16 @@ class _NineGridViewState extends State<NineGridView> {
|
|||||||
double space = widget.space;
|
double space = widget.space;
|
||||||
double itemW;
|
double itemW;
|
||||||
if (widget.type == NineGridType.weiBo &&
|
if (widget.type == NineGridType.weiBo &&
|
||||||
(itemCount == 1 || itemCount == 2)) {
|
(widget.itemCount == 1 || widget.itemCount == 2)) {
|
||||||
// || itemCount == 4
|
// || itemCount == 4
|
||||||
itemW = (width - space) / 2;
|
itemW = (width - space) / 2;
|
||||||
} else {
|
} else {
|
||||||
itemW = (width - space * 2) / 3;
|
itemW = (width - space * 2) / 3;
|
||||||
}
|
}
|
||||||
bool fourGrid = (itemCount == 4 && widget.type != NineGridType.normal);
|
bool fourGrid =
|
||||||
int column = fourGrid ? 2 : math.min(3, itemCount);
|
(widget.itemCount == 4 && widget.type != NineGridType.normal);
|
||||||
int row = fourGrid ? 2 : (itemCount / 3).ceil();
|
int column = fourGrid ? 2 : math.min(3, widget.itemCount);
|
||||||
|
int row = fourGrid ? 2 : (widget.itemCount / 3).ceil();
|
||||||
double realWidth =
|
double realWidth =
|
||||||
itemW * column + space * (column - 1) + padding.horizontal;
|
itemW * column + space * (column - 1) + padding.horizontal;
|
||||||
double realHeight = itemW * row + space * (row - 1) + padding.vertical;
|
double realHeight = itemW * row + space * (row - 1) + padding.vertical;
|
||||||
@@ -157,11 +157,11 @@ class _NineGridViewState extends State<NineGridView> {
|
|||||||
|
|
||||||
/// build nine grid view.
|
/// build nine grid view.
|
||||||
Widget _buildChild(BuildContext context, double itemW) {
|
Widget _buildChild(BuildContext context, double itemW) {
|
||||||
int itemCount = math.min(9, widget.itemCount);
|
|
||||||
double space = widget.space;
|
double space = widget.space;
|
||||||
int column = (itemCount == 4 && widget.type != NineGridType.normal) ? 2 : 3;
|
int column =
|
||||||
|
(widget.itemCount == 4 && widget.type != NineGridType.normal) ? 2 : 3;
|
||||||
List<Widget> list = [];
|
List<Widget> list = [];
|
||||||
for (int i = 0; i < itemCount; i++) {
|
for (int i = 0; i < widget.itemCount; i++) {
|
||||||
list.add(Positioned(
|
list.add(Positioned(
|
||||||
top: (space + itemW) * (i ~/ column),
|
top: (space + itemW) * (i ~/ column),
|
||||||
left: (space + itemW) * (i % column),
|
left: (space + itemW) * (i % column),
|
||||||
@@ -212,20 +212,19 @@ class _NineGridViewState extends State<NineGridView> {
|
|||||||
|
|
||||||
/// build weChat group.
|
/// build weChat group.
|
||||||
Widget _buildWeChatGroup(BuildContext context) {
|
Widget _buildWeChatGroup(BuildContext context) {
|
||||||
int itemCount = math.min(9, widget.itemCount);
|
|
||||||
double width = widget.width! - widget.padding.horizontal;
|
double width = widget.width! - widget.padding.horizontal;
|
||||||
double space = widget.space;
|
double space = widget.space;
|
||||||
double itemW;
|
double itemW;
|
||||||
|
|
||||||
int column = itemCount < 5 ? 2 : 3;
|
int column = widget.itemCount < 5 ? 2 : 3;
|
||||||
int row = 0;
|
int row = 0;
|
||||||
if (itemCount == 1) {
|
if (widget.itemCount == 1) {
|
||||||
row = 1;
|
row = 1;
|
||||||
itemW = width;
|
itemW = width;
|
||||||
} else if (itemCount < 5) {
|
} else if (widget.itemCount < 5) {
|
||||||
row = itemCount == 2 ? 1 : 2;
|
row = widget.itemCount == 2 ? 1 : 2;
|
||||||
itemW = (width - space) / 2;
|
itemW = (width - space) / 2;
|
||||||
} else if (itemCount < 7) {
|
} else if (widget.itemCount < 7) {
|
||||||
row = 2;
|
row = 2;
|
||||||
itemW = (width - space * 2) / 3;
|
itemW = (width - space * 2) / 3;
|
||||||
} else {
|
} else {
|
||||||
@@ -233,9 +232,9 @@ class _NineGridViewState extends State<NineGridView> {
|
|||||||
itemW = (width - space * 2) / 3;
|
itemW = (width - space * 2) / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
int first = itemCount % column;
|
int first = widget.itemCount % column;
|
||||||
List<Widget> list = [];
|
List<Widget> list = [];
|
||||||
for (int i = 0; i < itemCount; i++) {
|
for (int i = 0; i < widget.itemCount; i++) {
|
||||||
double left;
|
double left;
|
||||||
if (first > 0 && i < first) {
|
if (first > 0 && i < first) {
|
||||||
left = (width - itemW * first - space * (first - 1)) / 2 +
|
left = (width - itemW * first - space * (first - 1)) / 2 +
|
||||||
|
|||||||
Reference in New Issue
Block a user