11 changed files with 355 additions and 14 deletions
Unified View
Diff Options
-
40lib/controller/home/home_controller.dart
-
84lib/model/home/matchmaker_data.dart
-
3lib/network/api_urls.dart
-
7lib/network/home_api.dart
-
38lib/network/home_api.g.dart
-
2lib/pages/discover/visitor_list_page.dart
-
109lib/pages/home/matchmaker_card.dart
-
11lib/pages/home/matchmaker_item.dart
-
71lib/pages/home/matchmaker_page.dart
-
2lib/pages/home/nearby_tab.dart
-
2lib/pages/home/recommend_tab.dart
@ -0,0 +1,84 @@ |
|||||
|
class MatchmakerData { |
||||
|
List<Records>? records; |
||||
|
int? total; |
||||
|
int? size; |
||||
|
int? current; |
||||
|
int? pages; |
||||
|
|
||||
|
MatchmakerData( |
||||
|
{this.records, this.total, this.size, this.current, this.pages}); |
||||
|
|
||||
|
MatchmakerData.fromJson(Map<String, dynamic> json) { |
||||
|
if (json['records'] != null) { |
||||
|
records = <Records>[]; |
||||
|
json['records'].forEach((v) { |
||||
|
records!.add(new Records.fromJson(v)); |
||||
|
}); |
||||
|
} |
||||
|
total = json['total']; |
||||
|
size = json['size']; |
||||
|
current = json['current']; |
||||
|
pages = json['pages']; |
||||
|
} |
||||
|
|
||||
|
Map<String, dynamic> toJson() { |
||||
|
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
|
if (this.records != null) { |
||||
|
data['records'] = this.records!.map((v) => v.toJson()).toList(); |
||||
|
} |
||||
|
data['total'] = this.total; |
||||
|
data['size'] = this.size; |
||||
|
data['current'] = this.current; |
||||
|
data['pages'] = this.pages; |
||||
|
return data; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class Records { |
||||
|
String? miId; |
||||
|
String? userId; |
||||
|
String? matchmakerId; |
||||
|
String? profilePhoto; |
||||
|
String? nickName; |
||||
|
bool? isRealNameCertified; |
||||
|
String? birthYear; |
||||
|
String? birthDate; |
||||
|
int? age; |
||||
|
|
||||
|
Records( |
||||
|
{this.miId, |
||||
|
this.userId, |
||||
|
this.matchmakerId, |
||||
|
this.profilePhoto, |
||||
|
this.nickName, |
||||
|
this.isRealNameCertified, |
||||
|
this.birthYear, |
||||
|
this.birthDate, |
||||
|
this.age}); |
||||
|
|
||||
|
Records.fromJson(Map<String, dynamic> json) { |
||||
|
miId = json['miId']; |
||||
|
userId = json['userId']; |
||||
|
matchmakerId = json['matchmakerId']; |
||||
|
profilePhoto = json['profilePhoto']; |
||||
|
nickName = json['nickName']; |
||||
|
isRealNameCertified = json['isRealNameCertified']; |
||||
|
birthYear = json['birthYear']; |
||||
|
birthDate = json['birthDate']; |
||||
|
age = json['age']; |
||||
|
} |
||||
|
|
||||
|
Map<String, dynamic> toJson() { |
||||
|
final Map<String, dynamic> data = new Map<String, dynamic>(); |
||||
|
data['miId'] = this.miId; |
||||
|
data['userId'] = this.userId; |
||||
|
data['matchmakerId'] = this.matchmakerId; |
||||
|
data['profilePhoto'] = this.profilePhoto; |
||||
|
data['nickName'] = this.nickName; |
||||
|
data['isRealNameCertified'] = this.isRealNameCertified; |
||||
|
data['birthYear'] = this.birthYear; |
||||
|
data['birthDate'] = this.birthDate; |
||||
|
data['age'] = this.age; |
||||
|
return data; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,109 @@ |
|||||
|
|
||||
|
|
||||
|
import 'package:cached_network_image/cached_network_image.dart'; |
||||
|
import 'package:dating_touchme_app/controller/global.dart'; |
||||
|
import 'package:dating_touchme_app/extension/ex_widget.dart'; |
||||
|
import 'package:dating_touchme_app/generated/assets.dart'; |
||||
|
import 'package:dating_touchme_app/model/home/matchmaker_data.dart'; |
||||
|
import 'package:dating_touchme_app/pages/home/user_information_page.dart'; |
||||
|
import 'package:flutter/material.dart'; |
||||
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
import 'package:get/get.dart'; |
||||
|
|
||||
|
class MatchmakerCard extends StatelessWidget { |
||||
|
final Records visitor; |
||||
|
|
||||
|
const MatchmakerCard({Key? key, required this.visitor}) : super(key: key); |
||||
|
|
||||
|
@override |
||||
|
Widget build(BuildContext context) { |
||||
|
return Stack( |
||||
|
children: [ |
||||
|
ClipRRect( |
||||
|
borderRadius: BorderRadius.all(Radius.circular(10.w)), |
||||
|
child: CachedNetworkImage( |
||||
|
imageUrl: "${visitor.profilePhoto}?x-oss-process=image/format,webp/resize,w_240", |
||||
|
width: 173.w, |
||||
|
height: 173.w, |
||||
|
fit: BoxFit.cover, |
||||
|
placeholder: (context, url) => Container( |
||||
|
color: Colors.white38, |
||||
|
child: Center( |
||||
|
child: CircularProgressIndicator( |
||||
|
strokeWidth: 1.w, |
||||
|
color: Colors.grey, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
errorWidget: (context, url, error) => |
||||
|
Image.asset( |
||||
|
Assets.imagesUserAvatar, |
||||
|
width: 173.w, |
||||
|
height: 173.w, |
||||
|
fit: BoxFit.cover, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
Positioned( |
||||
|
left: 8.w, |
||||
|
bottom: 12.w, |
||||
|
child: Column( |
||||
|
crossAxisAlignment: CrossAxisAlignment.start, |
||||
|
children: [ |
||||
|
if(visitor.nickName != "")SizedBox( |
||||
|
width: 156.w, |
||||
|
child: Text(visitor.nickName ?? "", |
||||
|
maxLines: 1, |
||||
|
overflow: TextOverflow.ellipsis, |
||||
|
style: TextStyle( |
||||
|
fontSize: 12.w, |
||||
|
color: Colors.white, |
||||
|
fontWeight: FontWeight.w500, |
||||
|
), |
||||
|
), |
||||
|
), |
||||
|
SizedBox(height: 2.w), |
||||
|
SizedBox( |
||||
|
width: 156.w, |
||||
|
child: Row( |
||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
|
children: [ |
||||
|
Text( |
||||
|
"${visitor.age}岁", |
||||
|
style: TextStyle( |
||||
|
fontSize: 14.w, |
||||
|
color: Colors.white, |
||||
|
fontWeight: FontWeight.w500, |
||||
|
), |
||||
|
), |
||||
|
], |
||||
|
), |
||||
|
) |
||||
|
], |
||||
|
), |
||||
|
) |
||||
|
], |
||||
|
).onTap((){ |
||||
|
Get.to(() => UserInformationPage(miId: visitor.miId ?? "", userId: visitor.userId!)); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
// String _formatTime(String timestamp) { |
||||
|
// var time = DateTime.parse(timestamp); |
||||
|
// final now = DateTime.now(); |
||||
|
// final difference = now.difference(time); |
||||
|
// |
||||
|
// if (difference.inMinutes < 1) { |
||||
|
// return '刚刚'; |
||||
|
// } else if (difference.inHours < 1) { |
||||
|
// return '${difference.inMinutes}分钟前'; |
||||
|
// } else if (difference.inDays < 1) { |
||||
|
// return '${difference.inHours}小时前'; |
||||
|
// } else if (difference.inDays < 7) { |
||||
|
// return '${difference.inDays}天前'; |
||||
|
// } else { |
||||
|
// return '${time.month}/${time.day}'; |
||||
|
// } |
||||
|
// } |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save