You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
6.5 KiB
Dart

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import 'package:flutter/material.dart';
import 'commonFun.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'doJSON.dart';
import 'hyxx_data_handle.dart';
import 'dart:convert';
import '../pages/MyMsics/03_personal/ContactModify.dart';
import '../pages/MyMsics/03_personal/ContactAdd.dart';
//添加、修改、删除联系人对话框
class customDialogE extends Dialog {
String title;
String content;
int index;
customDialogE({this.title = "", this.content = "", this.index = -1});
// String getTitle(int index) {
// return listContacts2[index]["姓名"] +
// ' ' +
// listContacts2[index]["部门"] +
// ' ' +
// listContacts2[index]["职务"] +
// '\n' +
// listContacts2[index]["手机"] +
// ' ' +
// listContacts2[index]["邮箱"];
// }
Widget getBtnSizeX({@required text, width = 60.0, height = 30.0, onPressedFun}) {
return Container(
color: Colors.white12, //onPressedFun为null时无效
width: width,
height: height,
child: RaisedButton(
padding: EdgeInsets.all(0),
textColor: Colors.black,
child: Text(text),
onPressed: onPressedFun,
),
);
}
@override
Widget build(BuildContext context) {
Size mediaSize = MediaQuery.of(context).size;
//myController.text = getTitle(this.index);
myController.text = content;
// TODO: implement build
return WillPopScope(
child: Material(
type: MaterialType.transparency,
child: Container(
alignment: Alignment(0, -0.7),
child: Container(
height: mediaSize.height * 0.4,
width: mediaSize.width * 0.95,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(
Radius.circular(2),
),
),
child: Column(
children: <Widget>[
Padding(
padding: EdgeInsets.fromLTRB(10, 10, 10, 0),
child: Stack(
children: <Widget>[
Align(
alignment: Alignment.center,
child: Text(
"${this.title}",
style: TextStyle(
fontSize: 15.0,
),
),
),
Align(
alignment: Alignment.centerRight,
child: InkWell(
child: Icon(Icons.close),
onTap: () {
//Navigator.pop(context, index);
Navigator.pop(context); //关闭弹框,播放输入视频地址
},
),
)
],
),
),
Divider(),
Container(
padding: EdgeInsets.fromLTRB(20, 10, 20, 10),
width: double.infinity,
child: TextField(
maxLines: 4,
controller: myController,
autofocus: false,
//不会自动打开输入键盘
decoration: InputDecoration(
fillColor: Theme.of(context).hoverColor,
filled: true,
hintText: 'Media Url',
border: OutlineInputBorder(),
),
enableInteractiveSelection: false,
onTap: () {
FocusScope.of(context).requestFocus(new FocusNode());
},
),
),
SizedBox(height: 10),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
getBtnSizeX(
text: "添加",
onPressedFun: () async {
//跳转到修改对话框
Navigator.of(context)
.push(MaterialPageRoute(
builder: (context) => ContactAdd(contactIndex: index)))
.then((value) => Navigator.pop(context));
},
),
getBtnSizeX(
text: "修改",
onPressedFun: () async {
//跳转到修改对话框
await Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ContactModify(contactIndex: index)));
await Navigator.pop(context); //先关闭“选择操作”对话框
//跳转并关闭当前页面
// Navigator.pushAndRemoveUntil(
// context,
// MaterialPageRoute(
// builder: (context) => ContactModify(contactIndex: index)),
// (route) => route == null,
// );
},
),
getBtnSizeX(
text: "删除",
onPressedFun: () {
listContacts2.removeAt(index);
bFlash = true;
print("ContactDel bFlash = $bFlash");
writeJSON(json.encode(listContacts2), 'listContacts2.json');
Navigator.pop(context); //关闭弹框,播放输入视频地址
},
),
getBtnSizeX(
text: "复制",
onPressedFun: () {
// Flutter 复制文本到剪贴板
Clipboard.setData(ClipboardData(text: myController.text));
//showToast('帮助信息已复制到剪贴板', textAlign: TextAlign.left);
Fluttertoast.showToast(msg: '联系人信息已复制到剪贴板', gravity: ToastGravity.BOTTOM);
},
),
],
),
],
),
),
),
),
onWillPop: () {
// 屏蔽点击返回键的操作
//player.pause();
//Navigator.pop(context, index);
},
);
}
}