import 'package:dating_touchme_app/controller/global.dart'; import 'package:dating_touchme_app/generated/assets.dart'; import 'package:dating_touchme_app/model/home/marriage_data.dart'; import 'package:dating_touchme_app/pages/home/report_page.dart'; import 'package:dating_touchme_app/pages/message/chat_page.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:get/get_core/src/get_main.dart'; class UserInformationPage extends StatefulWidget { final MarriageData userData; const UserInformationPage({super.key, required this.userData}); @override State createState() => _UserInformationPageState(); } class _UserInformationPageState extends State { List imgList = [ "https://fastly.picsum.photos/id/64/800/800.jpg?hmac=NBZ4_-vqzD6p25oCeaW0H5vH-ql9zzei-SqJNeUo1QU", "https://fastly.picsum.photos/id/985/800/800.jpg?hmac=DfRt99HFbMJ96DlN-poOhruWYRsexESE94ilLC3g1rU", "https://fastly.picsum.photos/id/703/800/800.jpg?hmac=-bRTkPxnsiQ5kCo2tfXj6tFrXMD7YnVx7bQ0STno3Tg" ]; int nowSelect = 0; List tagList = [ "北京", "160cm", "想要甜甜的恋爱", "本科", "朋友圈摄影师", "英雄联盟", "流放之路", "CF", "DNA", "堡垒之夜", "SCP" ]; int calculateAge(String birthdayStr) { final birthday = DateTime.parse(birthdayStr); // 自动识别 1996-1-20 final today = DateTime.now(); int age = today.year - birthday.year; // 如果今年生日还没过,年龄要减 1 if (today.month < birthday.month || (today.month == birthday.month && today.day < birthday.day)) { age--; } return age; } final userData = GlobalData().userData.obs; @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ widget.userData.photoList.isNotEmpty ? Image.network( widget.userData.photoList[nowSelect].photoUrl, width: 375.w, height: 384.w, fit: BoxFit.cover, ) : Image.network( widget.userData.avatar, width: 375.w, height: 384.w, fit: BoxFit.cover, ), SingleChildScrollView( child: Container( padding: EdgeInsets.only(top: 361.w), child: Container( height: 812.h - 361.w, width: 375.w, padding: EdgeInsets.only( top: 31.w, left: 15.w, right: 24.w ), decoration: BoxDecoration( borderRadius: BorderRadius.vertical( top: Radius.circular(23.w) ), color: Colors.white ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Row( children: [ Text( widget.userData.nickName, style: TextStyle( fontSize: 19.w, color: const Color.fromRGBO(51, 51, 51, 1), fontWeight: FontWeight.w600 ), ), SizedBox(width: 13.w,), if(userData.value?.genderCode == 0) Container( width: 33.w, height: 13.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(13.w)), color: const Color.fromRGBO(255, 237, 255, 1) ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( Assets.imagesFemale, width: 8.w, height: 8.w, ), SizedBox(width: 2.w,), Text( "${widget.userData.age}", style: TextStyle( fontSize: 9.w, color: const Color.fromRGBO(255, 66, 236, 1) ), ) ], ), ), SizedBox(width: 3.w,), Container( width: 33.w, height: 13.w, margin: EdgeInsets.only(right: 2.w), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(13.w)), color: const Color.fromRGBO(234, 255, 219, 1) ), child: Center( child: Text( "在线", style: TextStyle( fontSize: 9.w, color: const Color.fromRGBO(38, 199, 124, 1) ), ), ), ), SizedBox(width: 4.w,), if (widget.userData.isRealNameCertified) Container( width: 43.w, height: 13.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(13.w)), color: const Color.fromRGBO(246, 237, 255, 1) ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( Assets.imagesRealName, width: 8.w, height: 7.w, ), SizedBox(width: 2.w,), Text( "实名", style: TextStyle( fontSize: 9.w, color: const Color.fromRGBO(160, 92, 255, 1) ), ) ], ), ), SizedBox(width: 4.w,), if(userData.value?.genderCode == 1) Container( width: 33.w, height: 13.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(13.w)), color: const Color.fromRGBO(237, 245, 255, 1) ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( Assets.imagesMale, width: 8.w, height: 8.w, ), SizedBox(width: 2.w,), Text( "${widget.userData.age}", style: TextStyle( fontSize: 9.w, color: const Color.fromRGBO(120, 140, 255, 1) ), ) ], ), ), ], ), Container( width: 63.w, height: 27.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(27.w)), color: const Color.fromRGBO(117, 98, 249, .1) ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( Assets.imagesPlayer, width: 15.w, height: 15.w, ), SizedBox(width: 4.w,), Image.asset( Assets.imagesVoice, width: 15.w, height: 13.w, ), SizedBox(width: 4.w,), Text( "6'", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(117, 98, 249, 1) ), ) ], ), ) ], ), SizedBox(height: 8.w,), Text( "父母催婚找个结婚的", style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(144, 144, 144, 1) ), ), SizedBox(height: 11.w,), Wrap( spacing: 7.w, runSpacing: 7.w, children: [ ...tagList.map((e){ return TagItem(label: e); }), ], ), SizedBox(height: 16.w,), if (widget.userData.provinceName.isNotEmpty) Text( "IP属地:${widget.userData.provinceName}", style: TextStyle( fontSize: 9.w, color: const Color.fromRGBO(144, 144, 144, 1) ), ), Text( "动我ID:${widget.userData.userId}", style: TextStyle( fontSize: 9.w, color: const Color.fromRGBO(144, 144, 144, 1) ), ), Spacer(), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ InkWell( onTap: () { // 跳转到聊天页面,传递用户ID和用户数据模型 Get.to(() => ChatPage( userId: widget.userData.userId, userData: widget.userData, )); }, child: Container( width: 246.w, height: 38.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(38.w)), color: const Color.fromRGBO(51, 51, 51, 1) ), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Image.asset( Assets.imagesChatBtn, width: 13.w, height: 12.w, ), SizedBox(width: 4.w,), Text( "发消息", style: TextStyle( fontSize: 15.w, color: Colors.white, fontWeight: FontWeight.w500 ), ) ], ), ), ), Container( width: 81.w, height: 38.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(38.w)), color: const Color.fromRGBO(117, 98, 249, 1) ), child: Center( child: Text( "关注", style: TextStyle( fontSize: 15.w, color: Colors.white, fontWeight: FontWeight.w500 ), ), ), ), ], ) ], ), ), ), ), Positioned( left: 0, top: MediaQuery.of(context).padding.top + 23, child: Container( width: 375.w, padding: EdgeInsets.symmetric(horizontal: 19.w), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ InkWell( onTap: (){ Get.back(); }, child: Container( width: 31.w, height: 31.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(31.w)), color: const Color.fromRGBO(51, 51, 51, .5) ), child: Center( child: Icon( Icons.keyboard_arrow_left, size: 23.w, color: Colors.white, ), ), ), ), PopupMenuButton( tooltip: "", padding: EdgeInsets.zero, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), color: Colors.white, elevation: 8, offset: Offset(0, 32.w), // 相对按钮下移一点 itemBuilder: (context) => [ const PopupMenuItem(value: 'report', child: Text('举报')), const PopupMenuItem(value: 'block', child: Text('拉黑')), ], onSelected: (v) { if (v == 'report') { print("举报"); Get.to(() => ReportPage()); } else if (v == 'block') { print("拉黑"); } }, child: Container( width: 31.w, height: 31.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(62.w)), color: const Color.fromRGBO(51, 51, 51, .5) ), child: Center( child: Icon( Icons.keyboard_control, size: 23.w, color: Colors.white, ), ), ), // 你的小圆按钮 ), ], ), ), ), Positioned( left: 15.w, top: 310.w, width: 345.w, child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: Row( children: [ ...widget.userData.photoList.asMap().entries.map((entry){ return Container( margin: EdgeInsets.only(right: 7.w), child: InkWell( onTap: (){ nowSelect = entry.key; setState(() { }); }, child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(7.w)), child: Container( width: 40.w, height: 40.w, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(7.w)), border: nowSelect == entry.key ? Border.all(width: 2.w, color: Colors.white) : null ), child: Center( child: Image.network( entry.value.photoUrl, width: 38.w, height: 38.w, fit: BoxFit.cover, ), ), ), ), ), ); }), ], ), ), ), ], ), ); } } class TagItem extends StatelessWidget { final String label; const TagItem({super.key, required this.label}); @override Widget build(BuildContext context) { return Container( padding: EdgeInsets.symmetric( vertical: 2.w, horizontal: 6.w ), decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(13.w)), color: const Color.fromRGBO(245, 247, 255, 1) ), child: Text( label, style: TextStyle( fontSize: 11.w, color: const Color.fromRGBO(51, 51, 51, 1) ), ), ); } }