120 lines
4.2 KiB
Dart
120 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
///兑换码弹窗
|
|
class ExchangeDialog extends StatefulWidget {
|
|
final Function onTap;
|
|
|
|
const ExchangeDialog({super.key, required this.onTap});
|
|
|
|
@override
|
|
State<ExchangeDialog> createState() => _ExchangeDialogState();
|
|
}
|
|
|
|
class _ExchangeDialogState extends State<ExchangeDialog> {
|
|
final TextEditingController _textController = TextEditingController();
|
|
String redemptionCode = "";
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.of(context).size;
|
|
final w163 = size.width / 2.2085889570552;
|
|
final w6 = size.width / 60;
|
|
final t17 = size.width / 21.176470588235;
|
|
final h10 = size.width / 36;
|
|
final s7 = size.width / 51.428571428571;
|
|
final w101 = size.width / 3.2727272727272;
|
|
final h19 = size.width / 18.947368421052;
|
|
final c5 = size.width / 72;
|
|
final w90 = size.width / 4;
|
|
final h20 = size.width / 18;
|
|
|
|
return Material(
|
|
type: MaterialType.transparency, //透明类型
|
|
color: Color(0x1A000000),
|
|
child: Center(
|
|
child: Container(
|
|
width: w163,
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF202530),
|
|
borderRadius: BorderRadius.circular(11),
|
|
),
|
|
child: Stack(
|
|
children: [
|
|
Positioned(
|
|
right: h10,
|
|
top: h10,
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
Navigator.pop(context);
|
|
},
|
|
child: Image(
|
|
width: w6,
|
|
height: w6,
|
|
image: AssetImage('assets/images/ic_cross.png'),
|
|
),
|
|
),
|
|
),
|
|
Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: h10),
|
|
child: Text(
|
|
"请输入礼包码兑换奖励",
|
|
style: TextStyle(fontSize: s7, color: Color(0xFFD6D6D7)),
|
|
),
|
|
),
|
|
Container(
|
|
width: w101,
|
|
height: h19,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: h19),
|
|
decoration: BoxDecoration(color: Color(0xFF111319), borderRadius: BorderRadius.all(Radius.circular(c5))),
|
|
child: TextField(
|
|
textAlign: TextAlign.center,
|
|
controller: _textController,
|
|
cursorColor: Color(0xFF074CE7),
|
|
style: TextStyle(fontSize: s7, color: Colors.white),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none,
|
|
hintText: '请输入兑换码',
|
|
hintStyle: TextStyle(fontSize: s7, color: Color(0xFF44474F)),
|
|
),
|
|
),
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
if (_textController.text == "") {
|
|
EasyLoading.showToast("请输入兑换码");
|
|
return;
|
|
}
|
|
// Navigator.pop(context);
|
|
widget.onTap(_textController.text);
|
|
},
|
|
child: Container(
|
|
width: w90,
|
|
height: h20,
|
|
alignment: Alignment.center,
|
|
margin: EdgeInsets.only(top: h19, bottom: h10),
|
|
decoration: BoxDecoration(
|
|
color: Color(0xFF074CE7),
|
|
borderRadius: BorderRadius.all(Radius.circular(h10)),
|
|
),
|
|
child: Text(
|
|
"兑换",
|
|
style: TextStyle(fontSize: s7, color: Colors.white),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|