Hibok
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.
 
 
 
 
 
 

77 rivejä
2.2 KiB

  1. //用于刷新DialogContent
  2. import 'package:chat/data/constants.dart';
  3. import 'package:chat/generated/i18n.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:oktoast/oktoast.dart';
  6. class MyDialogContent extends StatefulWidget {
  7. final dataMap;
  8. final keyList;
  9. @required
  10. final mostNum;
  11. MyDialogContent({Key key, this.dataMap, this.keyList, this.mostNum})
  12. : super(key: key);
  13. _MyDialogContentState createState() => _MyDialogContentState();
  14. }
  15. class _MyDialogContentState extends State<MyDialogContent> {
  16. @override
  17. Widget build(BuildContext context) {
  18. Widget buildItem(key, str) {
  19. Text text = new Text(str,
  20. textScaleFactor: 1.0,
  21. style: TextStyle(
  22. fontSize: 14,
  23. color: widget.keyList.contains(key)
  24. ? Constants.BlueTextColor
  25. : Constants.BlackTextColor));
  26. return InkWell(
  27. highlightColor: Colors.transparent,
  28. radius: 0.0,
  29. child: Container(
  30. decoration: BoxDecoration(
  31. border: Border(bottom: Constants.GreyBorderSide),
  32. ),
  33. height: 50,
  34. alignment: Alignment.center,
  35. child: text),
  36. onTap: () {
  37. setState(() {
  38. if (widget.keyList.contains(key)) {
  39. widget.keyList.remove(key);
  40. } else {
  41. if (widget.keyList.length >= widget.mostNum) {
  42. showToast(I18n.of(context)
  43. .most
  44. .replaceFirst('/s1', widget.mostNum.toString()));
  45. return;
  46. }
  47. widget.keyList.add(key);
  48. }
  49. });
  50. },
  51. );
  52. }
  53. List<Widget> buildDateprogram() {
  54. List<Widget> result = new List<Widget>();
  55. widget.dataMap.forEach((k, v) => result.add(buildItem(k, v)));
  56. return result;
  57. }
  58. return new Container(
  59. decoration: BoxDecoration(
  60. border: Border(top: BorderSide(color: Colors.grey, width: 1)),
  61. ),
  62. height: 230.0, // Change as per your requirement
  63. width: 350.0, // Change as per your requirement
  64. child: ListView(
  65. children: buildDateprogram(),
  66. ),
  67. );
  68. }
  69. }