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.
115 lines
3.8 KiB
115 lines
3.8 KiB
import 'package:flutter/material.dart'; |
|
|
|
class MessageItem extends StatefulWidget { |
|
final Function(bool) onChanged; |
|
final int stststatus; |
|
MessageItem(this.stststatus, this.onChanged); |
|
|
|
@override |
|
_MessageItemState createState() => _MessageItemState(); |
|
} |
|
|
|
class _MessageItemState extends State<MessageItem> { |
|
@override |
|
Widget build(BuildContext context) { |
|
return Row( |
|
children: [ |
|
if (widget.stststatus != 0) checkView(), |
|
Container( |
|
margin: EdgeInsets.only(left: widget.stststatus == 0 ? 16 : 0), |
|
child: Image.network( |
|
"https://t7.baidu.com/it/u=1297102096,3476971300&fm=193&f=GIF", |
|
width: 44, |
|
fit: BoxFit.cover, |
|
height: 44, |
|
), |
|
), |
|
Expanded( |
|
flex: 1, |
|
child: Container( |
|
margin: EdgeInsets.only(left: 16, right: 16), |
|
height: 44, |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.spaceAround, |
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
children: [ |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Text( |
|
"海峡姐妹", |
|
style: TextStyle( |
|
fontWeight: FontWeight.bold, |
|
fontSize: 14, |
|
color: Color(0xFF060606)), |
|
), |
|
Text( |
|
"2021.03.08 13:22", |
|
style: |
|
TextStyle(fontSize: 10, color: Color(0xFFA29E9E)), |
|
), |
|
], |
|
), |
|
Row( |
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
|
crossAxisAlignment: CrossAxisAlignment.center, |
|
children: [ |
|
Expanded( |
|
flex: 1, |
|
child: Text( |
|
"2021由她上,三八妇女节感恩回馈!三八妇女节,五一劳动节,六一儿童节", |
|
overflow: TextOverflow.ellipsis, |
|
style: TextStyle( |
|
fontSize: 10, color: Color(0xFF353535)), |
|
)), |
|
if (widget.stststatus == 0) |
|
Container( |
|
width: 10, |
|
height: 10, |
|
alignment: Alignment.center, |
|
margin: EdgeInsets.only(left: 17), |
|
decoration: BoxDecoration( |
|
color: Colors.red, |
|
borderRadius: |
|
BorderRadius.all(Radius.circular(5))), |
|
child: Text( |
|
"1", |
|
style: TextStyle( |
|
fontSize: 7, color: Color(0xFFFFFFFF)), |
|
), |
|
) |
|
], |
|
), |
|
], |
|
), |
|
)), |
|
], |
|
); |
|
} |
|
|
|
var _isCheck = false; |
|
|
|
Widget checkView() { |
|
return GestureDetector( |
|
onTap: () { |
|
setState(() { |
|
_isCheck = !_isCheck; |
|
}); |
|
if (widget.onChanged != null) { |
|
widget.onChanged.call(_isCheck); |
|
} |
|
}, |
|
child: Container( |
|
padding: EdgeInsets.all(16), |
|
alignment: Alignment.center, |
|
child: Image.asset( |
|
_isCheck |
|
? "assets/image/icon_radio_unselected.png" |
|
: "assets/image/icon_radio_selected.png", |
|
width: 16, |
|
height: 16, |
|
)), |
|
); |
|
} |
|
}
|
|
|