You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
226 lines
7.9 KiB
226 lines
7.9 KiB
1 year ago
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||
|
import 'package:huixiang/utils/font_weight.dart';
|
||
|
import 'package:huixiang/view_widget/my_appbar.dart';
|
||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
|
|
||
|
import '../../../retrofit/business_api.dart';
|
||
|
|
||
|
class AddVip extends StatefulWidget {
|
||
|
final Map<String, dynamic> arguments;
|
||
|
|
||
|
AddVip({this.arguments});
|
||
|
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _AddVip();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class _AddVip extends State<AddVip> {
|
||
|
final TextEditingController vipPhoneController = TextEditingController();
|
||
|
final TextEditingController vipNameController = TextEditingController();
|
||
|
bool isKeyBoardShow = false;
|
||
|
FocusNode _focusNode = FocusNode();
|
||
|
BusinessApiService businessService;
|
||
|
|
||
|
@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 GestureDetector(
|
||
|
behavior: HitTestBehavior.translucent,
|
||
|
onTap: () {
|
||
|
FocusScope.of(context).unfocus();
|
||
|
},
|
||
|
child: Scaffold(
|
||
|
resizeToAvoidBottomInset: false,
|
||
|
backgroundColor: Colors.white,
|
||
|
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,
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
),
|
||
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||
|
child: Row(
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: Text.rich(
|
||
|
TextSpan(
|
||
|
children: [
|
||
|
TextSpan(
|
||
|
text: "会员手机号",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: FontWeight.w500,
|
||
|
),
|
||
|
),
|
||
|
TextSpan(
|
||
|
text: "*",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFFFA5151),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: FontWeight.w500,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Expanded(
|
||
|
child: TextField(
|
||
|
controller: vipPhoneController,
|
||
|
decoration: InputDecoration(
|
||
|
hintText: "请输入会员手机号",
|
||
|
hintTextDirection: TextDirection.rtl,
|
||
|
hintStyle: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
border: InputBorder.none,
|
||
|
contentPadding: EdgeInsets.only(left: 16.w),
|
||
|
),
|
||
|
textAlign: TextAlign.right,
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
borderRadius: BorderRadius.circular(8),
|
||
|
),
|
||
|
padding: EdgeInsets.symmetric(horizontal: 16.w),
|
||
|
margin: EdgeInsets.only(top: 16.h),
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: Text(
|
||
|
"会员姓名",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: FontWeight.w500,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Expanded(
|
||
|
child: TextField(
|
||
|
controller: vipNameController,
|
||
|
decoration: InputDecoration(
|
||
|
hintText: "请输入会员姓名",
|
||
|
hintTextDirection: TextDirection.rtl,
|
||
|
hintStyle: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
border: InputBorder.none,
|
||
|
contentPadding: EdgeInsets.only(left: 16.w),
|
||
|
),
|
||
|
textAlign: TextAlign.right,
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
)),
|
||
|
Spacer(),
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap: () {
|
||
|
if (vipPhoneController.text == "") {
|
||
|
SmartDialog.showToast("请输入会员手机号",
|
||
|
alignment: Alignment.center);
|
||
|
return;
|
||
|
} else {
|
||
|
print("新增成功");
|
||
|
}
|
||
|
},
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
borderRadius: BorderRadius.circular(27),
|
||
|
color: Color(0xFF30415B),
|
||
|
),
|
||
|
width: double.infinity,
|
||
|
alignment: Alignment.center,
|
||
|
padding: EdgeInsets.symmetric(vertical: 16.h),
|
||
|
margin: EdgeInsets.only(bottom: 34.h),
|
||
|
child: Text(
|
||
|
"确认新增",
|
||
|
style: TextStyle(
|
||
|
color: Colors.white,
|
||
|
fontSize: 16.sp,
|
||
|
fontWeight: FontWeight.bold,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|