AI_Drawing/lib/dialog/newDialog.dart
2024-06-03 15:30:15 +08:00

163 lines
6.5 KiB
Dart

import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import '../bean/popout_bean.dart';
///弹框列表
class newDialog extends StatefulWidget {
// 点击返回index 0 1
Function onTap;
final PopoutBean popoutBean;
newDialog({required this.onTap, required this.popoutBean});
@override
_newDialogState createState() => _newDialogState();
}
class _newDialogState extends State<newDialog> {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final dw = size.width / 1.87178287318;
final dh = size.width / 7.71373473323;
double bl = 0, bt = 0, br = 0, bb = 0;
if (widget.popoutBean.BgPicInfo != null) {
if (widget.popoutBean.BgPicInfo!.PosY < 0) {
bt = widget.popoutBean.BgPicInfo!.PosY * -1 + 0.0;
} else {
bb = widget.popoutBean.BgPicInfo!.PosY + 0.0;
}
if (widget.popoutBean.BgPicInfo!.PosX < 0) {
bl = widget.popoutBean.BgPicInfo!.PosX * -1 + 0.0;
} else {
br = widget.popoutBean.BgPicInfo!.PosX + 0.0;
}
}
double dl = 0, dt = 0, dr = 0, db = 0;
if (widget.popoutBean.BtOKInfo != null) {
if (widget.popoutBean.BtOKInfo!.PosY < 0) {
dt = widget.popoutBean.BtOKInfo!.PosY * -1 + 0.0;
} else {
db = widget.popoutBean.BtOKInfo!.PosY + 0.0;
}
if (widget.popoutBean.BtOKInfo!.PosX < 0) {
dl = widget.popoutBean.BtOKInfo!.PosX * -1 + 0.0;
} else {
dr = widget.popoutBean.BtOKInfo!.PosX + 0.0;
}
}
double dl2 = 0, dt2 = 0, dr2 = 0, db2 = 0;
if (widget.popoutBean.BtCloseInfo != null) {
if (widget.popoutBean.BtCloseInfo!.PosY < 0) {
dt2 = widget.popoutBean.BtCloseInfo!.PosY * -1 + 0.0;
} else {
db2 = widget.popoutBean.BtCloseInfo!.PosY + 0.0;
}
if (widget.popoutBean.BtCloseInfo!.PosX < 0) {
dl2 = widget.popoutBean.BtCloseInfo!.PosX * -1 + 0.0;
} else {
dr2 = widget.popoutBean.BtCloseInfo!.PosX + 0.0;
}
}
// String price = "";
// NetworkConfig.productIdList.forEach((key, value) {
// if (widget.popoutBean.Text == key) {
// price = value;
// }
// });
return Material(
type: MaterialType.transparency, //透明类型
color: Color(0x1A000000),
child: Center(
// ClipRRect 创建圆角矩形 要不然发现下边button不是圆角
child: Container(
child: Stack(
alignment: Alignment.center,
children: <Widget>[
widget.popoutBean.BgPicInfo != null
? Container(
margin: EdgeInsets.only(left: bl, top: bt, right: br, bottom: bb),
child: CachedNetworkImage(
width: widget.popoutBean.BgPicInfo!.W + 0.33,
height: widget.popoutBean.BgPicInfo!.H + 0.33,
fit: BoxFit.fill,
imageUrl: widget.popoutBean.BgPicInfo != null && widget.popoutBean.BgPicInfo!.Pic != null
? widget.popoutBean.BgPicInfo!.Pic!
: "",
errorWidget: (context, url, error) => Icon(Icons.error),
))
: Container(),
widget.popoutBean.BtOKInfo != null
? Container(
margin: EdgeInsets.only(left: dl, top: dt, right: dr, bottom: db),
child: GestureDetector(
onTap: () {
// Navigator.pop(context);
if (widget.onTap != null) {
// Navigator.pop(context);
widget.onTap(widget.popoutBean.PopoutId, widget.popoutBean.PopoutType, widget.popoutBean.Text);
}
},
child: Stack(
alignment: Alignment.center,
children: [
CachedNetworkImage(
width: widget.popoutBean.BtOKInfo!.W + 0.33,
height: widget.popoutBean.BtOKInfo!.H + 0.33,
fit: BoxFit.fill,
imageUrl: widget.popoutBean.BtOKInfo != null && widget.popoutBean.BtOKInfo!.Pic != null
? widget.popoutBean.BtOKInfo!.Pic!
: "",
errorWidget: (context, url, error) => Image(
height: dh,
width: dw,
fit: BoxFit.fill,
image: AssetImage('assets/images/btn_mianfeiliangqu.webp'),
),
),
widget.popoutBean.PopoutType == 6
? Positioned(
child: Text(
"S.of(context).only + price",
style: TextStyle(color: Colors.white, fontSize: 16),
))
: Container()
],
),
))
: Container(),
widget.popoutBean.BtCloseInfo != null
? Container(
margin: EdgeInsets.only(left: dl2, top: dt2, right: dr2, bottom: db2),
child: GestureDetector(
onTap: () {
Navigator.pop(context);
},
child: CachedNetworkImage(
width: widget.popoutBean.BtCloseInfo!.W + 0.33,
height: widget.popoutBean.BtCloseInfo!.H + 0.33,
fit: BoxFit.fill,
imageUrl: widget.popoutBean.BtCloseInfo != null && widget.popoutBean.BtCloseInfo!.Pic != null
? widget.popoutBean.BtCloseInfo!.Pic!
: "",
errorWidget: (context, url, error) => Image(
height: dh,
width: dw,
fit: BoxFit.fill,
image: AssetImage('assets/images/btn_mianfeiliangqu.webp'),
),
)))
: Container(),
],
),
),
),
);
}
}