From 707950a1f2bed405cc64ff6fb6c380268b602b67 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Wed, 3 Feb 2021 15:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E4=B8=9A=E9=A1=B5=E9=9D=A2=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=8D=A1=E7=89=87=E9=87=8D=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/market/market_page.dart | 7 ------- lib/pages/property/property_index.dart | 7 +++---- lib/widget/views/application_view.dart | 24 ++++++++++++++++++------ 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/lib/pages/market/market_page.dart b/lib/pages/market/market_page.dart index c1ca7ada..3ad2273b 100644 --- a/lib/pages/market/market_page.dart +++ b/lib/pages/market/market_page.dart @@ -133,13 +133,6 @@ class _MarketPageState extends State imagePath: 'assets/example/guanggao5.png', radius: 36, ), - ContainerComment( - radius: 8, - customWidget: GridButtons( - gridList: [], - crossCount: 4, - ), - ), ], ), ), diff --git a/lib/pages/property/property_index.dart b/lib/pages/property/property_index.dart index e8d2dc29..2bfb96c8 100644 --- a/lib/pages/property/property_index.dart +++ b/lib/pages/property/property_index.dart @@ -1,5 +1,7 @@ // Flutter imports: +import 'package:akuCommunity/constants/application_objects.dart'; import 'package:akuCommunity/ui/community/notice/notice_page.dart'; +import 'package:akuCommunity/widget/views/application_view.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -202,10 +204,7 @@ class _PropertyIndexState extends State SliverToBoxAdapter( child: ContainerComment( radius: 8, - customWidget: GridButtons( - gridList: _gridList, - crossCount: 4, - ), + customWidget: ApplicationView.custom(items: smartManagerApp), ), ), SliverToBoxAdapter( diff --git a/lib/widget/views/application_view.dart b/lib/widget/views/application_view.dart index af331125..16394485 100644 --- a/lib/widget/views/application_view.dart +++ b/lib/widget/views/application_view.dart @@ -7,7 +7,14 @@ import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; class ApplicationView extends StatefulWidget { - ApplicationView({Key key}) : super(key: key); + final List items; + ApplicationView({Key key}) + : items = null, + super(key: key); + + ApplicationView.custom({Key key, @required this.items}) + : assert(items != null), + super(key: key); @override _ApplicationViewState createState() => _ApplicationViewState(); @@ -34,19 +41,24 @@ class _ApplicationViewState extends State { ); } + bool get _isCustom => widget.items != null; + List get _items { + final appProvider = Provider.of(context); + + return _isCustom ? widget.items : appProvider.myApplications; + } + @override Widget build(BuildContext context) { - final appProvider = Provider.of(context); return GridView.builder( padding: EdgeInsets.zero, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), itemBuilder: (context, index) { - if (index == appProvider.myApplications.length) - return _buildTile(allApp); - return _buildTile(appProvider.myApplications[index]); + if (index == _items.length) return _buildTile(allApp); + return _buildTile(_items[index]); }, - itemCount: appProvider.myApplications.length + 1, + itemCount: _items.length + 1, shrinkWrap: true, ); }