Browse Source

开发完善信息页面

ios
Batman 4 months ago
parent
commit
e89ff9f025
7 changed files with 402 additions and 2 deletions
  1. BIN
      assets/images/avatars_example.png
  2. BIN
      assets/images/bg_edit_avatars.png
  3. BIN
      assets/images/bg_information.png
  4. BIN
      assets/images/edit_avatars_icon.png
  5. 5
      lib/generated/assets.dart
  6. 6
      lib/pages/mine/login_controller.dart
  7. 393
      lib/pages/mine/user_info_page.dart

BIN
assets/images/avatars_example.png

Before After
Width: 340  |  Height: 340  |  Size: 86 KiB

BIN
assets/images/bg_edit_avatars.png

Before After
Width: 76  |  Height: 76  |  Size: 1.0 KiB

BIN
assets/images/bg_information.png

Before After
Width: 2250  |  Height: 4872  |  Size: 874 KiB

BIN
assets/images/edit_avatars_icon.png

Before After
Width: 38  |  Height: 38  |  Size: 317 B

5
lib/generated/assets.dart

@ -5,5 +5,8 @@ class Assets {
static const String imagesLoginLogo = 'assets/images/login_logo.png';
static const String imagesManIcon = 'assets/images/man_icon.png';
static const String imagesWomenIcon = 'assets/images/women_icon.png';
static const String imagesBgInformation = 'assets/images/bg_information.png';
static const String imagesAvatarsExample = 'assets/images/avatars_example.png';
static const String imagesBgEditAvatars = 'assets/images/bg_edit_avatars.png';
static const String imagesEditAvatarsIcon = 'assets/images/edit_avatars_icon.png';
}

6
lib/pages/mine/login_controller.dart

@ -3,6 +3,8 @@ import 'package:get/get.dart';
import 'package:get_storage/get_storage.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:dating_touchme_app/network/user_api.dart';
import 'package:dating_touchme_app/pages/mine/user_info_page.dart';
class LoginController extends GetxController {
//
@ -156,7 +158,9 @@ class LoginController extends GetxController {
// UI状态或保存到存储中
if(response.data.data == null){
//
SmartDialog.showToast('跳转到完善信息');
SmartDialog.showToast('转到完善信息');
//
Get.offAll(() => UserInfoPage());
}
} else {
//

393
lib/pages/mine/user_info_page.dart

@ -0,0 +1,393 @@
import 'package:flutter/material.dart';
import 'package:dating_touchme_app/generated/assets.dart';
class UserInfoPage extends StatefulWidget {
const UserInfoPage({Key? key}) : super(key: key);
@override
State<UserInfoPage> createState() => _UserInfoPageState();
}
class _UserInfoPageState extends State<UserInfoPage> {
String _gender = 'male'; //
String _nickname = '强壮的瘦子';
String _birthday = '';
String _education = '';
String _invitationCode = '';
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
//
Positioned.fill(
child: Image.asset(
Assets.imagesBgInformation,
fit: BoxFit.cover,
),
),
//
SafeArea(
child: SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20.0),
child: Column(
children: [
//
const SizedBox(height: 20),
Text(
'完善信息',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Color.fromRGBO(51, 51, 51, 1),
),
),
const SizedBox(height: 30),
//
Stack(
children: [
Container(
width: 85,
height: 85,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.grey,
),
child: ClipOval(
//
child: Image.asset(
Assets.imagesAvatarsExample,
fit: BoxFit.cover,
),
),
),
Positioned(
bottom: 0,
right: 0,
child: Container(
width: 30,
height: 30,
decoration: const BoxDecoration(
shape: BoxShape.circle,
color: Colors.blue,
),
child: Image.asset(
Assets.imagesBgEditAvatars,
width: 16,
height: 16,
color: Colors.white,
),
),
),
],
),
const SizedBox(height: 30),
//
const Align(
alignment: Alignment.centerLeft,
child: Text(
'性别 (注册后不可修改)',
style: TextStyle(
fontSize: 16,
color: Color.fromRGBO(144, 144, 144, 1),
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 10),
Row(
children: [
GestureDetector(
onTap: () {
setState(() {
_gender = 'male';
});
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: _gender == 'male' ? Colors.black : Colors.grey[200],
),
child: Row(
children: [
Image.asset(
Assets.imagesManIcon,
width: 20,
height: 20,
color: _gender == 'male' ? Colors.white : Colors.black,
),
const SizedBox(width: 5),
],
),
),
),
const SizedBox(width: 20),
GestureDetector(
onTap: () {
setState(() {
_gender = 'female';
});
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: _gender == 'female' ? Colors.pink : Colors.grey[200],
),
child: Row(
children: [
Image.asset(
Assets.imagesWomenIcon,
width: 20,
height: 20,
color: _gender == 'female' ? Colors.white : Colors.black,
),
const SizedBox(width: 5),
],
),
),
),
],
),
const SizedBox(height: 30),
//
const Align(
alignment: Alignment.centerLeft,
child: Text(
'昵称',
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: Row(
children: [
Expanded(
child: TextField(
controller: TextEditingController(text: _nickname),
onChanged: (value) {
_nickname = value;
},
decoration: const InputDecoration(
border: InputBorder.none,
),
),
),
TextButton(
onPressed: () {
//
},
child: const Text(
'随机',
style: TextStyle(
color: Colors.grey,
),
),
),
],
),
),
const SizedBox(height: 30),
//
const Align(
alignment: Alignment.centerLeft,
child: Text(
'年龄',
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 10),
GestureDetector(
onTap: () {
//
_selectDate();
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_birthday.isEmpty ? '请选择你的出生日期' : _birthday,
style: TextStyle(
color: _birthday.isEmpty ? Colors.grey : Colors.black,
),
),
const Icon(Icons.arrow_forward_ios, color: Colors.grey),
],
),
),
),
const SizedBox(height: 30),
//
const Align(
alignment: Alignment.centerLeft,
child: Text(
'学历',
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 10),
GestureDetector(
onTap: () {
//
_selectEducation();
},
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_education.isEmpty ? '请选择你的学历' : _education,
style: TextStyle(
color: _education.isEmpty ? Colors.grey : Colors.black,
),
),
const Icon(Icons.arrow_forward_ios, color: Colors.grey),
],
),
),
),
const SizedBox(height: 30),
//
const Align(
alignment: Alignment.centerLeft,
child: Text(
'邀请码 (非必填)',
style: TextStyle(
fontSize: 16,
color: Colors.black,
fontWeight: FontWeight.w500,
),
),
),
const SizedBox(height: 10),
Container(
padding: const EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
),
child: TextField(
onChanged: (value) {
_invitationCode = value;
},
decoration: const InputDecoration(
hintText: '请输入邀请码',
hintStyle: TextStyle(color: Colors.grey),
border: InputBorder.none,
),
),
),
const SizedBox(height: 50),
//
SizedBox(
width: double.infinity,
height: 50,
child: ElevatedButton(
onPressed: () {
//
_submitUserInfo();
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(25),
),
),
child: const Text(
'开始交友',
style: TextStyle(
fontSize: 18,
color: Colors.white,
),
),
),
),
const SizedBox(height: 30),
],
),
),
),
],
),
);
}
//
void _selectDate() {
//
//
setState(() {
_birthday = '1990-01-01';
});
}
//
void _selectEducation() {
//
//
setState(() {
_education = '本科';
});
}
//
void _submitUserInfo() {
//
print('提交用户信息:');
print('性别: $_gender');
print('昵称: $_nickname');
print('生日: $_birthday');
print('学历: $_education');
print('邀请码: $_invitationCode');
//
if (_birthday.isEmpty || _education.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('请完善所有必填信息')),
);
return;
}
//
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('信息提交成功')),
);
}
}
Loading…
Cancel
Save