import 'package:flutter/material.dart'; class PaymentMethodDialog extends StatefulWidget { Function onTap; PaymentMethodDialog({super.key, required this.onTap}); @override State createState() => _PaymentMethodDialogState(); } class _PaymentMethodDialogState extends State { bool isWX = true; @override void initState() { // TODO: implement initState super.initState(); } @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; return Material( type: MaterialType.transparency, //透明类型 color: Color(0x1A000000), child: Container( decoration: const BoxDecoration( color: Color(0xFF19191A), borderRadius: BorderRadius.only( topLeft: Radius.circular(7), topRight: Radius.circular(7), )), child: Column( mainAxisSize: MainAxisSize.min, children: [ Container( margin: EdgeInsets.only(top: 16), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( margin: EdgeInsets.only(left: 16), child: Text( '请选择支付方式', style: TextStyle(fontSize: 13, color: Colors.white), ), ), Container( margin: const EdgeInsets.only(right: 16), child: GestureDetector( onTap: () { Navigator.of(context).pop(); }, child: Image( width: 10, image: AssetImage('assets/images/ic_close.png'), ), )), ], ), ), Container( margin: EdgeInsets.only(left: 16, right: 16, top: 22), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image( width: 14.67, height: 12, image: AssetImage('assets/images/ic_we_chat.png'), ), Container( margin: EdgeInsets.only(left: 5), child: Text( '微信支付', style: TextStyle(fontSize: 10, color: Colors.white), ), ) ], ), GestureDetector( onTap: () { setState(() { isWX = true; }); }, child: Image( width: 15, height: 15, image: !isWX ? AssetImage('assets/images/ic_c.png') : AssetImage('assets/images/ic_c_s.png'), ), ), ], ), ), Container( margin: EdgeInsets.only(left: 16, right: 16, top: 17), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Image( width: 14, height: 14, image: AssetImage('assets/images/ic_alipay.png'), ), Container( margin: EdgeInsets.only(left: 5), child: Text( '支付宝支付', style: TextStyle(fontSize: 10, color: Colors.white), ), ) ], ), GestureDetector( onTap: () { setState(() { isWX = false; }); }, child: Image( width: 15, height: 15, image: isWX ? AssetImage('assets/images/ic_c.png') : AssetImage('assets/images/ic_c_s.png'), ), ), ], ), ), GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { widget.onTap(isWX); Navigator.of(context).pop(); }, child: Container( width: size.width, height: 40, margin: EdgeInsets.only(left: 16, right: 16, top: 25, bottom: 36), alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFFFF9000), borderRadius: BorderRadius.all(Radius.circular(10)), ), child: Text( "去支付", style: TextStyle(fontSize: 16, color: Colors.white), ), ), ), ], )), ); } }