访客管理页面逻辑

hmxc
张萌 4 years ago
parent f84b02f0b1
commit ad735bacce

@ -5,7 +5,7 @@ import 'package:aku_community_manager/ui/widgets/inner/aku_tab_bar.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
enum VisitorStatus{ enum VisitorStatus {
NOT_VISIT, NOT_VISIT,
VISIT_DONE, VISIT_DONE,
OUTDATE, OUTDATE,
@ -17,7 +17,8 @@ class VisitorCardsModel {
String plate; String plate;
String time; String time;
VisitorStatus status; VisitorStatus status;
VisitorCardsModel(this.adress,this.name, this.status,{this.plate,this.time}); VisitorCardsModel(this.adress, this.name, this.status,
{this.plate, this.time});
} }
class VisitorManagerPage extends StatefulWidget { class VisitorManagerPage extends StatefulWidget {
@ -30,12 +31,18 @@ class VisitorManagerPage extends StatefulWidget {
class _VisitorManagerPageState extends State<VisitorManagerPage> class _VisitorManagerPageState extends State<VisitorManagerPage>
with TickerProviderStateMixin { with TickerProviderStateMixin {
List<String> tabs = ['全部', '未到访', '已到访', '已过期']; List<String> _tabs = ['全部', '未到访', '已到访', '已过期'];
List<VisitorCardsModel> cards=[ List<VisitorCardsModel> _cards = [
VisitorCardsModel('深圳华悦茂峰1幢1单元702', '马泽城',VisitorStatus.VISIT_DONE, plate:'浙BA9899',time:'2020-10-24 12:00',), VisitorCardsModel(
VisitorCardsModel('深圳华悦茂峰2幢2单元702', '刘揪心',VisitorStatus.NOT_VISIT), '深圳华悦茂峰1幢1单元702',
VisitorCardsModel('深圳华悦茂峰3幢3单元602', '刘揪心',VisitorStatus.OUTDATE), '马泽城',
VisitorStatus.VISIT_DONE,
plate: '浙BA9899',
time: '2020-10-24 12:00',
),
VisitorCardsModel('深圳华悦茂峰2幢2单元702', '刘揪心', VisitorStatus.NOT_VISIT),
VisitorCardsModel('深圳华悦茂峰3幢3单元602', '刘揪心', VisitorStatus.OUTDATE),
]; ];
TabController _tabController; TabController _tabController;
@ -46,22 +53,85 @@ class _VisitorManagerPageState extends State<VisitorManagerPage>
TabController(length: 4, vsync: this, initialIndex: widget.initIndex); TabController(length: 4, vsync: this, initialIndex: widget.initIndex);
} }
@override
void dispose() {
_tabController?.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return AkuScaffold( return AkuScaffold(
title: '访客管理', title: '访客管理',
appBarBottom: PreferredSize( appBarBottom: PreferredSize(
child: AkuTabBar( child: AkuTabBar(
tabs: tabs, tabs: _tabs,
controller: _tabController, controller: _tabController,
), ),
preferredSize: Size.fromHeight(88.w)), preferredSize: Size.fromHeight(88.w)),
body: ListView( body: TabBarView(
padding: EdgeInsets.only(left:32.w,right:32.w), controller: _tabController,
children: [ // children: _tabs.map((e) => _buildTabView(_tabs.indexOf(e))).toList(),)
...cards.map((e) => VisitorManagerCard(adress: e.adress,name: e.name,plate: e.plate,time: e.time,)).toList(), // children: [
], // ListView(
), // padding: EdgeInsets.only(left: 32.w, right: 32.w),
// children: _cards
// .map((e) => VisitorManagerCard(
// adress: e.adress,
// name: e.name,
// plate: e.plate,
// time: e.time,
// ))
// .toList(),
// ),
// ListView(
// padding: EdgeInsets.only(left: 32.w, right: 32.w),
// children: _cards
// .where((element) => element.status == VisitorStatus.NOT_VISIT)
// .map((e) => VisitorManagerCard(
// adress: e.adress,
// name: e.name,
// plate: e.plate,
// time: e.time,
// ))
// .toList(),
// ),
// ListView(),
// ListView(),
// ],
children: _tabs.map((e) => _buildListView(_tabs.indexOf(e))).toList(),
));
}
Widget _buildListView(int index) {
List<VisitorCardsModel> _selectCards;
switch (index) {
case 0:
_selectCards = _cards;
break;
case 1:
_selectCards = _cards
.where((element) => element.status == VisitorStatus.NOT_VISIT).toList();
break;
case 2:
_selectCards = _cards
.where((element) => element.status == VisitorStatus.VISIT_DONE).toList();
break;
case 3:
_selectCards =
_cards.where((element) => element.status == VisitorStatus.OUTDATE).toList();
break;
}
return ListView(
padding: EdgeInsets.only(left: 32.w, right: 32.w),
children: _selectCards
.map((e) => VisitorManagerCard(
adress: e.adress,
name: e.name,
plate: e.plate,
time: e.time,
))
.toList(),
); );
} }
} }

Loading…
Cancel
Save