You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.0 KiB
81 lines
2.0 KiB
4 years ago
|
import 'dart:collection';
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:huixiang/view_widget/message_item.dart';
|
||
|
|
||
|
class MineMessagePage extends StatefulWidget {
|
||
|
final int status;
|
||
|
final Function(bool) onChanged;
|
||
|
MineMessagePage(this.status, this.onChanged);
|
||
|
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _MineMessagePage();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
class _MineMessagePage extends State<MineMessagePage> {
|
||
|
Map<int, bool> map;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
map = HashMap();
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return SingleChildScrollView(
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(
|
||
|
left: 16,
|
||
|
right: 16,
|
||
|
top: 32,
|
||
|
),
|
||
|
padding: EdgeInsets.only(top: 16, bottom: 16),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Colors.black.withAlpha(12),
|
||
|
offset: Offset(0, 3),
|
||
|
blurRadius: 14,
|
||
|
spreadRadius: 0)
|
||
|
],
|
||
|
borderRadius: BorderRadius.all(Radius.circular(8))),
|
||
|
child: ListView.builder(
|
||
|
itemCount: 12,
|
||
|
shrinkWrap: true,
|
||
|
physics: new NeverScrollableScrollPhysics(),
|
||
|
itemBuilder: (context, position) {
|
||
|
return Container(
|
||
|
margin: EdgeInsets.only(top: 12, bottom: 12),
|
||
|
child: GestureDetector(
|
||
|
onTap: () {
|
||
|
Navigator.of(context).pushNamed('/router/system_msg_page');
|
||
|
},
|
||
|
child: MessageItem(widget.status, (check) {
|
||
|
map[position] = check;
|
||
|
refreshStatus();
|
||
|
}),
|
||
|
),
|
||
|
);
|
||
|
}),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
|
||
|
refreshStatus() {
|
||
|
var isOneCheck = false;
|
||
|
map.forEach((key, value) {
|
||
|
if (value) {
|
||
|
isOneCheck = true;
|
||
|
}
|
||
|
});
|
||
|
if (widget.onChanged != null) {
|
||
|
widget.onChanged.call(isOneCheck);
|
||
|
}
|
||
|
}
|
||
|
}
|