425 lines
16 KiB
Dart
425 lines
16 KiB
Dart
import 'package:circle_app/components/my_app_bar.dart';
|
||
import 'package:circle_app/router/app_routers.dart';
|
||
import 'package:circle_app/util/util.dart';
|
||
import 'package:flutter/material.dart';
|
||
import 'package:flutter_pickers/pickers.dart';
|
||
import 'package:flutter_pickers/style/default_style.dart';
|
||
import 'package:flutter_pickers/time_picker/model/date_mode.dart';
|
||
import 'package:flutter_pickers/time_picker/model/pduration.dart';
|
||
import 'package:flutter_pickers/time_picker/model/suffix.dart';
|
||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
import 'package:get/get.dart';
|
||
|
||
import 'logic.dart';
|
||
|
||
class Complete_materialPage extends StatelessWidget {
|
||
Complete_materialPage({Key? key}) : super(key: key);
|
||
final logic = Get.put(Complete_materialLogic());
|
||
|
||
// PickerStyle pickerStyle = PickerStyle();
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return GetBuilder(builder: (Complete_materialLogic controller) {
|
||
return Stack(
|
||
children: [
|
||
Container(
|
||
width: MediaQuery.of(context).size.width,
|
||
height: MediaQuery.of(context).size.height,
|
||
child: Image.asset(
|
||
getBaseImage('bg'),
|
||
fit: BoxFit.fill,
|
||
),
|
||
),
|
||
Scaffold(
|
||
appBar: MyAppBar(
|
||
centerTitle: '完善您的个人形象',
|
||
isBack: true,
|
||
),
|
||
backgroundColor: Colors.transparent,
|
||
body: GestureDetector(
|
||
onTap: () {
|
||
FocusManager.instance.primaryFocus?.unfocus();
|
||
},
|
||
child: SingleChildScrollView(
|
||
child: Container(
|
||
width: MediaQuery.of(context).size.width,
|
||
color: Colors.transparent,
|
||
child: Column(
|
||
crossAxisAlignment: CrossAxisAlignment.center,
|
||
children: [
|
||
SizedBox(
|
||
height: 20.sp,
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
controller.getImageFile();
|
||
},
|
||
child: controller.headUrl == ''
|
||
? Image.asset(
|
||
getLoginImage('add'),
|
||
width: 86.sp,
|
||
height: 86.sp,
|
||
)
|
||
: ClipOval(
|
||
child: Image.network(
|
||
fit: BoxFit.fill,
|
||
controller.headUrl,
|
||
width: 86.sp,
|
||
height: 86.sp,
|
||
),
|
||
),
|
||
),
|
||
SizedBox(
|
||
height: 15.sp,
|
||
),
|
||
Text(
|
||
'数据表明95%的人对真实的头像更感兴趣',
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontWeight: FontWeight.w500,
|
||
fontSize: 16.sp),
|
||
),
|
||
funcWidget(
|
||
'昵称',
|
||
TextField(
|
||
controller: controller.state.textEditingController,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontWeight: FontWeight.w500,
|
||
fontSize: 14.sp),
|
||
decoration: InputDecoration(
|
||
hintText: '请输入昵称',
|
||
hintStyle: TextStyle(
|
||
color: Colors.white,
|
||
fontWeight: FontWeight.w500,
|
||
fontSize: 14.sp),
|
||
border: InputBorder.none,
|
||
),
|
||
),
|
||
() {},
|
||
img: 'edit'),
|
||
funcWidget(
|
||
'属性',
|
||
Text(
|
||
controller.state.sex,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.w500),
|
||
), () {
|
||
showSexPiker(context, controller);
|
||
}),
|
||
funcWidget(
|
||
'生日',
|
||
Text(
|
||
controller.state.age,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.w500),
|
||
), () {
|
||
showAgePiker(
|
||
context,
|
||
controller,
|
||
);
|
||
}),
|
||
funcWidget(
|
||
'角色',
|
||
Text(
|
||
controller.state.role,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.w500),
|
||
), () {
|
||
showRolePiker(context, controller);
|
||
}),
|
||
funcWidget(
|
||
'取向',
|
||
Text(
|
||
controller.state.orientation,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 14.sp,
|
||
fontWeight: FontWeight.w500),
|
||
), () {
|
||
showOrientationPiker(context, controller);
|
||
}),
|
||
funcWidget(
|
||
'兴趣',
|
||
Row(
|
||
children: controller.numbers.isNotEmpty
|
||
? [interestWdiget('JK圈', controller)]
|
||
: [],
|
||
), () async {
|
||
var data = await Get.toNamed(
|
||
AppRoutes.SelectCircleActivity,
|
||
arguments: {
|
||
"interestMap" :controller.configBean.interestMap,
|
||
'selectCircle':controller.numbers,
|
||
"isRodio" :false
|
||
});
|
||
if (data != null) {
|
||
controller.numbers = data;
|
||
controller.update();
|
||
}
|
||
}),
|
||
Container(
|
||
margin: EdgeInsets.only(
|
||
top: 24.sp,
|
||
bottom: 18.sp,
|
||
left: 28.sp,
|
||
right: 28.sp),
|
||
height: 116.sp,
|
||
child: Stack(
|
||
children: [
|
||
Image.asset(getLoginImage('desc_bg')),
|
||
TextField(
|
||
maxLines: 4,
|
||
controller:
|
||
controller.state.descEditingController,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontWeight: FontWeight.w500,
|
||
fontSize: 14.sp),
|
||
decoration: InputDecoration(
|
||
hintText: '请输入您的交友宣言',
|
||
// icon: Text('交友宣言:',style: TextStyle(color: Colors.white,fontSize: 14.sp,fontWeight: FontWeight.w500),),
|
||
labelText: '您的交友宣言',
|
||
labelStyle: TextStyle(
|
||
color: Colors.white,
|
||
fontWeight: FontWeight.w600,
|
||
fontSize: 16.sp),
|
||
hintStyle: TextStyle(
|
||
color: Colors.white,
|
||
fontWeight: FontWeight.w500,
|
||
fontSize: 14.sp),
|
||
border: InputBorder.none,
|
||
contentPadding: EdgeInsets.all(20.sp)),
|
||
)
|
||
],
|
||
),
|
||
),
|
||
GestureDetector(
|
||
onTap: () {
|
||
if (controller.type == "user") {
|
||
// Navigator.pop(context);
|
||
controller.editInfo();
|
||
} else {
|
||
controller.checkInfo();
|
||
}
|
||
|
||
// controller.checkInfo();
|
||
},
|
||
child: Container(
|
||
alignment: Alignment.center,
|
||
width: 133.sp,
|
||
height: 56.sp,
|
||
decoration: BoxDecoration(
|
||
image: DecorationImage(
|
||
fit: BoxFit.fill,
|
||
image: AssetImage(getLoginImage('start_bg'))),
|
||
),
|
||
child: Text(
|
||
controller.type == "user" ? "完成" : '开启小圈之旅',
|
||
style: TextStyle(
|
||
color: Color(0xff00FFF4),
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w600),
|
||
),
|
||
),
|
||
)
|
||
],
|
||
),
|
||
),
|
||
),
|
||
),
|
||
)
|
||
],
|
||
);
|
||
});
|
||
}
|
||
|
||
Widget funcWidget(
|
||
String leftStr, Widget tipWidget, GestureTapCallback callback,
|
||
{String img = 'down_arr'}) {
|
||
return Container(
|
||
width: Get.width,
|
||
padding: EdgeInsets.only(left: 28.sp, right: 28.sp),
|
||
height: 54.sp,
|
||
child: Column(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Expanded(
|
||
child: GestureDetector(
|
||
behavior: HitTestBehavior.opaque,
|
||
onTap: callback,
|
||
child: Row(
|
||
mainAxisAlignment: MainAxisAlignment.center,
|
||
children: [
|
||
Text(leftStr,
|
||
style: TextStyle(
|
||
color: Colors.white,
|
||
fontSize: 16.sp,
|
||
fontWeight: FontWeight.w500,
|
||
shadows: [
|
||
Shadow(color: Color(0xffF657FF), blurRadius: 4.0.sp)
|
||
])),
|
||
Expanded(
|
||
child: Padding(
|
||
padding: EdgeInsets.only(left: 20.sp),
|
||
child: tipWidget,
|
||
)),
|
||
Image.asset(
|
||
getLoginImage(img),
|
||
width: img == 'down_arr' ? 24.sp : 18.sp,
|
||
)
|
||
],
|
||
),
|
||
),
|
||
),
|
||
lineWidget(),
|
||
],
|
||
),
|
||
);
|
||
}
|
||
|
||
lineWidget() {
|
||
return Container(
|
||
height: 1.sp,
|
||
width: Get.width - 28 * 2.sp,
|
||
decoration: const BoxDecoration(
|
||
gradient:
|
||
SweepGradient(colors: [Color(0xff03FEFB), Color(0xffE735F4)])),
|
||
);
|
||
}
|
||
|
||
interestWdiget(String interest, Complete_materialLogic controller) {
|
||
return Container(
|
||
height: 59.sp,
|
||
width: 240.sp,
|
||
child: ListView.builder(
|
||
itemCount: controller.numbers.length,
|
||
// 替换为实际的 item 数量
|
||
scrollDirection: Axis.horizontal,
|
||
// 设置为水平方向
|
||
padding: EdgeInsets.symmetric(vertical: 18.sp),
|
||
// 替换为实际的边距值
|
||
itemBuilder: (context, index) {
|
||
return Container(
|
||
margin: EdgeInsets.only(right: 11.sp), // 替换为实际的 item 间距
|
||
child: Container(
|
||
height: 34.sp,
|
||
padding: EdgeInsets.only(left: 15.sp, right: 15.sp),
|
||
decoration: BoxDecoration(
|
||
borderRadius: BorderRadius.circular(17.0.sp), // 设置圆角半径
|
||
border: Border.all(color: Colors.white, width: 1.sp),
|
||
color: Color(0xFF392D53),
|
||
),
|
||
child: Text(
|
||
controller.numbers[index].name,
|
||
style: TextStyle(
|
||
fontSize: 12.0.sp,
|
||
color: Colors.white,
|
||
),
|
||
),
|
||
), // 替换为实际的列表项小部件
|
||
);
|
||
},
|
||
),
|
||
);
|
||
|
||
// return Container(
|
||
// height: 21.sp,
|
||
// padding: EdgeInsets.only(left: 12.sp, right: 12.sp),
|
||
// margin: EdgeInsets.only(left: 10.sp),
|
||
// alignment: Alignment.center,
|
||
// decoration: BoxDecoration(
|
||
// border: Border.all(width: 1, color: Colors.white),
|
||
// borderRadius: BorderRadius.circular(21.sp),
|
||
// ),
|
||
// child: Text(
|
||
// interest,
|
||
// style: TextStyle(
|
||
// color: Colors.white, fontSize: 11.sp, fontWeight: FontWeight.w500),
|
||
// ),
|
||
// );
|
||
}
|
||
|
||
showSexPiker(context, Complete_materialLogic controller) {
|
||
Pickers.showSinglePicker(context,
|
||
pickerStyle: DefaultPickerStyle.dark(),
|
||
data: controller.genderList,
|
||
selectData: controller.state.sex.isNotEmpty
|
||
? controller.state.sex
|
||
: '男', onConfirm: (p, position) {
|
||
controller.state.sex = p;
|
||
controller.state.genderId =
|
||
controller.configBean.genderMap.keys.toList()[position];
|
||
controller.update();
|
||
});
|
||
}
|
||
|
||
showAgePiker(context, Complete_materialLogic controller) {
|
||
var date = PDuration.now();
|
||
PDuration currentDur =
|
||
PDuration(year: date.year! - 18, month: date.month, day: date.day);
|
||
if (controller.state.brithday.isNotEmpty) {}
|
||
Pickers.showDatePicker(
|
||
context,
|
||
pickerStyle: DefaultPickerStyle.dark(),
|
||
// context,
|
||
// 模式,详见下方
|
||
mode: DateMode.YMD,
|
||
// 后缀 默认Suffix.normal(),为空的话Suffix()
|
||
suffix: Suffix(years: ' 年', month: ' 月', days: ' 日'),
|
||
// 样式 详见下方样式
|
||
// pickerStyle: pickerStyle,
|
||
// 默认选中
|
||
selectDate: currentDur,
|
||
maxDate:
|
||
PDuration(year: date.year! - 18, month: date.month, day: date.day),
|
||
minDate:
|
||
PDuration(year: date.year! - 100, month: date.month, day: date.day),
|
||
onConfirm: (p) {
|
||
String month = p.month! < 10 ? '0${p.month!}' : p.month!.toString();
|
||
String day = p.day! < 10 ? '0${p.day!}' : p.day!.toString();
|
||
var time = '${p.year}-${month}-${day}';
|
||
controller.state.age = controller.getAge(p);
|
||
controller.state.brithday = time;
|
||
controller.update();
|
||
},
|
||
// onChanged: (p) => print(p),
|
||
);
|
||
}
|
||
|
||
showRolePiker(context, Complete_materialLogic controller) {
|
||
Pickers.showSinglePicker(context,
|
||
pickerStyle: DefaultPickerStyle.dark(),
|
||
data: controller.roleList,
|
||
selectData: controller.state.role.isNotEmpty
|
||
? controller.state.role
|
||
: 'Sado', onConfirm: (p, position) {
|
||
controller.state.role = p;
|
||
controller.state.roleId =
|
||
controller.configBean.roleMap.keys.toList()[position];
|
||
controller.update();
|
||
});
|
||
}
|
||
|
||
//
|
||
showOrientationPiker(context, Complete_materialLogic controller) {
|
||
Pickers.showSinglePicker(context,
|
||
pickerStyle: DefaultPickerStyle.dark(),
|
||
data: controller.orientationList,
|
||
selectData: controller.state.orientation.isNotEmpty
|
||
? controller.state.orientation
|
||
: '异性恋', onConfirm: (p, position) {
|
||
controller.state.orientation = p;
|
||
controller.state.orientationId =
|
||
controller.configBean.orientationMap.keys.toList()[position];
|
||
controller.update();
|
||
});
|
||
}
|
||
}
|