| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/src/widgets/framework.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:keyboard/base/base_view.dart';
- import 'package:keyboard/module/new_user/new_user_controller.dart';
- import 'package:flutter/material.dart';
- import 'package:keyboard/resource/string.gen.dart';
- import 'package:get/get.dart';
- import '../../../../resource/assets.gen.dart';
- import '../../../../resource/colors.gen.dart';
- import '../../../../utils/age_zodiac_sign_util.dart';
- import '../../../../utils/styles.dart';
- import '../../../../widget/avatar/avatar_image_widget.dart';
- class StepPartnerView extends BaseView<NewUserController> {
- const StepPartnerView({super.key});
- @override
- Color backgroundColor() {
- return Colors.transparent;
- }
- @override
- Widget buildBody(BuildContext context) {
- return Container(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _buildStepTitle(),
- SizedBox(height: 24.w),
- Center(child: _buildAvatar()),
- SizedBox(height: 12.w),
- Expanded(child: SingleChildScrollView(child: _buildContent())),
- ],
- ),
- );
- }
- Widget _buildStepTitle() {
- return Container(
- margin: EdgeInsets.only(left: 30.w, right: 30.w),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- StringName.newUserPartnerTitle,
- style: TextStyle(
- color: Colors.black.withAlpha(204),
- fontSize: 22.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- SizedBox(height: 7.h),
- Text(
- StringName.newUserPartnerDesc,
- style: TextStyle(
- color: Colors.black.withAlpha(153),
- fontSize: 14.sp,
- fontWeight: FontWeight.w400,
- ),
- ),
- ],
- ),
- );
- }
- Widget _buildAvatar() {
- return GestureDetector(
- onTap: controller.nextAvatar,
- child: Obx(() {
- return Container(
- height: 90.w,
- child: Stack(
- children: [
- Container(
- width: 84.w,
- height: 84.w,
- child:
- controller.partnerAvatarUrl.isNotEmpty
- ? CircleAvatarWidget(
- image:
- Assets.images.iconKeyboardDefaultAvatar
- .provider(),
- imageUrl: controller.partnerAvatarUrl,
- size: 84.w,
- borderColor: Colors.white,
- borderWidth: 2.r,
- placeholder: (_, __) {
- return const CupertinoActivityIndicator();
- },
- )
- : SizedBox(),
- ),
- Positioned(
- left: 0,
- right: 0,
- bottom: 0,
- child: _buildAvatarSwitch(),
- ),
- ],
- ),
- );
- }),
- );
- }
- Widget _buildAvatarSwitch() {
- return GestureDetector(
- onTap: controller.nextAvatar,
- child: SizedBox(
- width: 22.r,
- height: 22.r,
- child: Assets.images.iconCharacterCustomDetailSwitch.image(
- width: 22.r,
- height: 22.r,
- ),
- ),
- );
- }
- Widget _buildContent() {
- return Container(
- margin: EdgeInsets.only(left: 16.w, right: 16.w, bottom: 200.w),
- padding: EdgeInsets.only(top: 21.w),
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(18),
- color: Colors.white,
- ),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Padding(
- padding: EdgeInsets.only(left: 20.w),
- child: Text(
- StringName.newUserPartnerIs,
- style: Styles.getTextStyleBlack204W500(14.sp),
- ),
- ),
- SizedBox(height: 12.w),
- buildPartnerNameFiled(),
- SizedBox(height: 30.w),
- Padding(
- padding: EdgeInsets.only(left: 20.w),
- child: Text(
- StringName.gender,
- style: Styles.getTextStyleBlack204W500(14.sp),
- ),
- ),
- SizedBox(height: 9.w),
- Obx(
- () => Container(
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
- children: [
- // 女生按钮
- Expanded(
- child: buildGenderSwitchButton(
- isSelected: controller.partnerGender == 2,
- text: StringName.newUserPartnerIsFemale,
- genderIcon: Assets.images.iconFamateBlack,
- onTap: () => controller.onPartnerGenderChanged(2),
- ),
- ),
- SizedBox(width: 16.w),
- // 男生按钮
- Expanded(
- child: buildGenderSwitchButton(
- genderIcon: Assets.images.iconMaleWhite,
- isSelected: controller.partnerGender == 1,
- text: StringName.newUserPartnerIsMale,
- onTap: () => controller.onPartnerGenderChanged(1),
- ),
- ),
- ],
- ),
- ),
- ),
- SizedBox(height: 30.w),
- Padding(
- padding: EdgeInsets.only(left: 20.w),
- child: Text(
- StringName.newUserBirthdayTitle,
- style: Styles.getTextStyleBlack204W500(14.sp),
- ),
- ),
- SizedBox(height: 12.w),
- _buildPartnerBirthday(),
- SizedBox(height: 32.w),
- ],
- ),
- );
- }
- Widget buildPartnerNameFiled() {
- return Container(
- height: 42.w,
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- padding: EdgeInsets.symmetric(horizontal: 12.w),
- decoration: BoxDecoration(
- color: Color(0XFFF6F5FA),
- borderRadius: BorderRadius.circular(28.w),
- ),
- child: Row(
- children: [
- Expanded(
- child: TextField(
- cursorHeight: 20.w,
- style: TextStyle(
- fontSize: 14.sp,
- color: Colors.black.withAlpha(204),
- fontWeight: FontWeight.w500,
- ),
- controller: controller.partnerNameController,
- maxLines: 1,
- textAlignVertical: TextAlignVertical.center,
- decoration: InputDecoration(
- hintText: StringName.newUserNicknameTitle,
- counterText: "",
- hintStyle: TextStyle(
- fontSize: 14.sp,
- color: Colors.black.withAlpha(77),
- fontWeight: FontWeight.w500,
- ),
- labelStyle: TextStyle(
- fontSize: 14.sp,
- color: ColorName.primaryTextColor,
- ),
- contentPadding: const EdgeInsets.all(0),
- border: const OutlineInputBorder(borderSide: BorderSide.none),
- enabled: true,
- ),
- onChanged: controller.onNicknameChange,
- ),
- ),
- ],
- ),
- );
- }
- Widget buildSwitchPartnerGender() {
- return Container(
- width: 296,
- height: 42,
- decoration: ShapeDecoration(
- color: const Color(0xFFF5F4F9),
- shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)),
- ),
- );
- }
- Widget buildGenderSwitchButton({
- required String text,
- required bool isSelected,
- required VoidCallback onTap,
- required AssetGenImage genderIcon,
- }) {
- return GestureDetector(
- onTap: onTap,
- child: Container(
- height: 42.w,
- alignment: Alignment.center,
- decoration: BoxDecoration(
- borderRadius: BorderRadius.circular(28.r),
- color: isSelected ? null : const Color(0xFFF5F4F9),
- gradient:
- isSelected
- ? LinearGradient(
- begin: Alignment.centerLeft,
- end: Alignment.centerRight,
- transform: GradientRotation(0.5),
- colors: [const Color(0xFF7D46FC), const Color(0xFFBC87FF)],
- )
- : null,
- ),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- genderIcon.image(width: 24.w,height: 24.w,color: isSelected ? Colors.white : Colors.black),
- Text(
- text,
- style:
- isSelected
- ? Styles.getTextStyleWhiteW500(14.sp)
- : Styles.getTextStyleBlack204W500(14.sp),
- ),
- ],
- ),
- ),
- );
- }
- _buildPartnerBirthday() {
- return GestureDetector(
- onTap: controller.changePartnerBirthday,
- child: Obx(() {
- return Container(
- height: 42.w,
- margin: EdgeInsets.symmetric(horizontal: 16.w),
- padding: EdgeInsets.symmetric(horizontal: 12.w),
- decoration: BoxDecoration(
- color: Color(0XFFF6F5FA),
- borderRadius: BorderRadius.circular(28.w),
- ),
- child: Row(
- children: [
- controller.currentPartnerBirthday == null
- ? Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Text(
- StringName.newUserPartnerBirthday,
- style: TextStyle(
- color: Colors.black.withAlpha(77),
- fontSize: 14.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- Assets.images.iconArrowRight.image(
- width: 24.w,
- height: 24.w,
- fit: BoxFit.contain,
- ),
- ],
- ),
- )
- : Expanded(
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- _buildBirthdayNotEmptyText(),
- Assets.images.iconArrowRight.image(
- width: 24.w,
- height: 24.w,
- fit: BoxFit.contain,
- ),
- ],
- ),
- ),
- ],
- ),
- );
- }),
- );
- }
- _buildBirthdayNotEmptyText() {
- return Row(
- children: [
- Text(
- controller.dateComponents.yearPart,
- style: Styles.getTextStyleBlack204W500(14.sp),
- ),
- SizedBox(width: 4.w),
- Text(
- StringName.year,
- style: TextStyle(
- color: Colors.black.withAlpha(102),
- fontSize: 12.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- SizedBox(width: 4.w),
- Text(
- controller.dateComponents.monthPart,
- style: Styles.getTextStyleBlack204W500(14.sp),
- ),
- SizedBox(width: 4.w),
- Text(
- StringName.month,
- style: TextStyle(
- color: Colors.black.withAlpha(102),
- fontSize: 12.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- SizedBox(width: 4.w),
- Text(
- controller.dateComponents.dayPart,
- style: Styles.getTextStyleBlack204W500(14.sp),
- ),
- Text(
- StringName.day,
- style: TextStyle(
- color: Colors.black.withAlpha(102),
- fontSize: 12.sp,
- fontWeight: FontWeight.w500,
- ),
- ),
- SizedBox(width: 16.w),
- Text(
- AgeZodiacSignUtil.getZodiacSign(
- controller.currentPartnerBirthday!,
- ).name,
- style: Styles.getTextStyleBlack204W500(14.sp),
- ),
- ],
- );
- }
- }
|