|
- //用于刷新DialogContent
- import 'package:chat/data/constants.dart';
- import 'package:chat/generated/i18n.dart';
- import 'package:flutter/material.dart';
-
- import 'package:oktoast/oktoast.dart';
-
- class MyDialogContent extends StatefulWidget {
- final dataMap;
- final keyList;
- @required
- final mostNum;
- MyDialogContent({Key key, this.dataMap, this.keyList, this.mostNum})
- : super(key: key);
-
- _MyDialogContentState createState() => _MyDialogContentState();
- }
-
- class _MyDialogContentState extends State<MyDialogContent> {
- @override
- Widget build(BuildContext context) {
- Widget buildItem(key, str) {
- Text text = new Text(str,
- textScaleFactor: 1.0,
- style: TextStyle(
- fontSize: 14,
- color: widget.keyList.contains(key)
- ? Constants.BlueTextColor
- : Constants.BlackTextColor));
- return InkWell(
- highlightColor: Colors.transparent,
- radius: 0.0,
- child: Container(
- decoration: BoxDecoration(
- border: Border(bottom: Constants.GreyBorderSide),
- ),
- height: 50,
- alignment: Alignment.center,
- child: text),
- onTap: () {
- setState(() {
- if (widget.keyList.contains(key)) {
- widget.keyList.remove(key);
- } else {
- if (widget.keyList.length >= widget.mostNum) {
- showToast(I18n.of(context)
- .most
- .replaceFirst('/s1', widget.mostNum.toString()));
- return;
- }
- widget.keyList.add(key);
- }
- });
- },
- );
- }
-
- List<Widget> buildDateprogram() {
- List<Widget> result = new List<Widget>();
- widget.dataMap.forEach((k, v) => result.add(buildItem(k, v)));
- return result;
- }
-
- return new Container(
- decoration: BoxDecoration(
- border: Border(top: BorderSide(color: Colors.grey, width: 1)),
- ),
-
- height: 230.0, // Change as per your requirement
- width: 350.0, // Change as per your requirement
- child: ListView(
- children: buildDateprogram(),
- ),
- );
- }
- }
|