import 'package:flutter/material.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import '../../generated/l10n.dart'; import '../../view_widget/border_text.dart'; import '../../view_widget/classic_header.dart'; import '../../view_widget/my_footer.dart'; import '../../view_widget/round_button.dart'; class RequestRefund extends StatefulWidget { @override State createState() { return _RequestRefund(); } } class _RequestRefund extends State { final RefreshController refreshController = RefreshController(); final TextEditingController modifyAmountController = TextEditingController(); FocusNode _focusNode = FocusNode(); bool isKeyBoardShow = false; int modifyAmountState = 0; @override void initState() { super.initState(); WidgetsBinding.instance.addPostFrameCallback((_) { setState(() { print("object: ${MediaQuery.of(context).viewInsets.bottom}"); if (MediaQuery.of(context).viewInsets.bottom == 0) { if (isKeyBoardShow) { isKeyBoardShow = false; //关闭键盘 软键盘关闭了, 清除输入控件的焦点, 否则重新进入页面会导致软键盘再弹出问题 FocusScope.of(context).requestFocus(FocusNode()); } } else { isKeyBoardShow = true; } }); }); } ///离开页面记着销毁和清除 @override void dispose() { _focusNode.unfocus(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( resizeToAvoidBottomInset: false, backgroundColor: Color(0xFFF8F8FA), appBar: MyAppBar( title: "申请退款", titleColor: Colors.black, background: Colors.white, leadingColor: Colors.black, brightness: Brightness.dark, ), body: Container( margin: EdgeInsets.only(top: 24.h,left: 16.w,right: 16.w), child:Column( children: [ Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular(8.w), boxShadow: [ BoxShadow( color: Color(0x0F06152E).withAlpha(12), offset: Offset(0, 2), blurRadius: 4, spreadRadius: 0, ), ], ), padding: EdgeInsets.only(top: 16.h,left: 16.w,right: 16.w,), child: Column( children: [ Row( children: [ Container( width: 2.w, height: 16.h, color: Color(0xFF30415B), margin: EdgeInsets.only(right:6.w), ), Text( "申请金额", style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 16.sp, fontWeight: MyFontWeight.semi_bold, ), ), ], ), SizedBox(height:32.h,), Row( children: [ if(modifyAmountState == 0) Expanded(child:Text.rich( TextSpan( children: [ TextSpan( text: "¥", style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 24.sp, fontWeight: MyFontWeight.semi_bold, ), ), TextSpan( text: "1112.33", style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 24.sp, fontWeight: MyFontWeight.medium, ), ), ], ), )), if(modifyAmountState == 1) Text( "¥", style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 24.sp, fontWeight: MyFontWeight.semi_bold, ), ), if(modifyAmountState == 1) Expanded(child: TextField( controller: modifyAmountController, decoration: InputDecoration( hintText: "请输入修改金额", hintStyle: TextStyle( color: Color(0xFF0D0D0D), fontSize: 14.sp, fontWeight: MyFontWeight.regular ), border: InputBorder.none, ), keyboardType: TextInputType.phone, style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 24.sp, fontWeight: MyFontWeight.medium ), ),), GestureDetector( behavior: HitTestBehavior.opaque, onTap: (){ // showModifyAmountDialog(); setState((){ modifyAmountState = 1; }); }, child: Row( children: [ Image.asset( "assets/image/bs_edit.webp", fit: BoxFit.cover, width:16, height:16, ), SizedBox(width: 4.w,), Text( "修改金额", style: TextStyle( color: Color(0xFF7A797F), fontSize: 14.sp, fontWeight: MyFontWeight.regular, ), ), ], ), ) ], ), Container( height: 1.h, width: double.infinity, color: Color(0xFFEBECEF), margin: EdgeInsets.only(bottom: 50.h), ) ], ), ), Spacer(), GestureDetector( behavior: HitTestBehavior.opaque, onTap: (){ showModifyAmountDialog(); }, child: Container( width: double.infinity, alignment: Alignment.center, margin: EdgeInsets.only(bottom:55.h,top: 125.h), padding: EdgeInsets.symmetric(vertical:16.h), decoration: BoxDecoration( borderRadius: BorderRadius.circular(27), color: Color(0xFF30415B) ), child: Text( "确定退款", style: TextStyle( fontWeight: MyFontWeight.semi_bold, fontSize: 16.sp, color: Colors.white, ), ), ), ) ], ), ), ); } ///修改金额提示 showModifyAmountDialog() { showDialog( context: context, builder: (context) { return AlertDialog( content: Container( width: MediaQuery.of(context).size.width - 84, height: 139.h, child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( "申请退款", style: TextStyle( color: Color(0xFF0D0D0D), fontSize: 16.sp, fontWeight: MyFontWeight.regular, ), ), SizedBox( height: 15.h, ), Text( "此操作将进行退款申请,是否继续?", style: TextStyle( color: Color(0xFFF4524D), fontSize: 16.sp, fontWeight: MyFontWeight.regular, ), ), SizedBox( height: 35.h, ), Row( children: [ Expanded( child: InkWell( child: BorderText( text: S.of(context).quxiao, textColor: Color(0xFF30415B), fontSize: 16.sp, fontWeight: FontWeight.bold, borderColor: Color(0xFF30415B), radius: 4, padding: EdgeInsets.all(12), borderWidth: 1, ), onTap: () { Navigator.of(context).pop(); }, ), flex: 1, ), SizedBox( width: 16.w, ), Expanded( child: InkWell( child: RoundButton( text: S.of(context).queren, textColor: Colors.white, radius: 4, padding: EdgeInsets.all(12), backgroup: Color(0xFF30415B), fontSize: 16.sp, fontWeight: FontWeight.bold, ), onTap: () { Navigator.of(context).pop(); }, ), flex: 1, ), ], ) ], ), ), ); }, ); } }