diff --git a/lib/models/member/info.dart b/lib/models/member/info.dart index 4b668c7d5..72ee462a3 100644 --- a/lib/models/member/info.dart +++ b/lib/models/member/info.dart @@ -10,6 +10,7 @@ class MemberInfoModel { this.topPhoto, this.official, this.vip, + this.liveRoom, }); int? mid; @@ -29,13 +30,14 @@ class MemberInfoModel { name = json['name']; sex = json['sex']; face = json['face']; - sign = json['sign'] == '' ? '该用户还没有签名' : json['sign']; + sign = json['sign'] == '' ? '该用户还没有签名' : json['sign'].replaceAll('\n', ''); level = json['level']; isFollowed = json['is_followed']; topPhoto = json['top_photo']; official = json['official']; vip = Vip.fromJson(json['vip']); - liveRoom = LiveRoom.fromJson(json['live_room']); + liveRoom = + json['live_room'] != null ? LiveRoom.fromJson(json['live_room']) : null; } } @@ -80,12 +82,12 @@ class LiveRoom { int? roundStatus; LiveRoom.fromJson(Map json) { - roomStatus = json['room_status']; - liveStatus = json['live_status']; + roomStatus = json['roomStatus']; + liveStatus = json['liveStatus']; url = json['url']; title = json['title']; cover = json['cover']; - roomId = json['room_id']; - roundStatus = json['round_status']; + roomId = json['roomid']; + roundStatus = json['roundStatus']; } } diff --git a/lib/pages/dynamics/widgets/up_panel.dart b/lib/pages/dynamics/widgets/up_panel.dart index 81dc2d789..0faa2af89 100644 --- a/lib/pages/dynamics/widgets/up_panel.dart +++ b/lib/pages/dynamics/widgets/up_panel.dart @@ -141,7 +141,7 @@ class _UpPanelState extends State { 'roomid': data.roomId, }); Get.toNamed( - '/liveRoom?rooid=${data.roomId}', + '/liveRoom?roomid=${data.roomId}', arguments: {'liveItem': liveItem}, ); } diff --git a/lib/pages/member/controller.dart b/lib/pages/member/controller.dart index 6fb0f3369..d3ac80695 100644 --- a/lib/pages/member/controller.dart +++ b/lib/pages/member/controller.dart @@ -1,6 +1,8 @@ import 'package:get/get.dart'; +import 'package:hive/hive.dart'; import 'package:pilipala/http/member.dart'; import 'package:pilipala/models/member/info.dart'; +import 'package:pilipala/utils/storage.dart'; import 'package:pilipala/utils/wbi_sign.dart'; class MemberController extends GetxController { @@ -9,11 +11,14 @@ class MemberController extends GetxController { Map? userStat; String? face; String? heroTag; + Box user = GStrorage.user; + late int ownerMid; @override void onInit() { super.onInit(); mid = int.parse(Get.parameters['mid']!); + ownerMid = user.get(UserBoxKey.userMid); face = Get.arguments['face']!; heroTag = Get.arguments['heroTag']!; } diff --git a/lib/pages/member/view.dart b/lib/pages/member/view.dart index 24da624c0..631313ccf 100644 --- a/lib/pages/member/view.dart +++ b/lib/pages/member/view.dart @@ -1,7 +1,10 @@ import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; +import 'package:pilipala/models/live/item.dart'; import 'package:pilipala/models/user/stat.dart'; import 'package:pilipala/pages/member/index.dart'; import 'package:pilipala/utils/utils.dart'; @@ -39,7 +42,7 @@ class _MemberPageState extends State elevation: 0, scrolledUnderElevation: 0, forceElevated: innerBoxIsScrolled, - expandedHeight: 300, + expandedHeight: 320, actions: [ IconButton(onPressed: () {}, icon: const Icon(Icons.more_vert)), const SizedBox(width: 4), @@ -97,8 +100,6 @@ class _MemberPageState extends State alignment: AlignmentDirectional.center, children: [ Column( - // mainAxisAlignment: - // MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -117,7 +118,24 @@ class _MemberPageState extends State fontWeight: FontWeight.bold), ), - const SizedBox(width: 6), + const SizedBox(width: 2), + if (_memberController + .memberInfo.value.sex == + '女') + const Icon( + FontAwesomeIcons.venus, + size: 14, + color: Colors.pink, + ), + if (_memberController + .memberInfo.value.sex == + '男') + const Icon( + FontAwesomeIcons.mars, + size: 14, + color: Colors.blue, + ), + const SizedBox(width: 4), Image.asset( 'assets/images/lv/lv${_memberController.memberInfo.value.level}.png', height: 11, @@ -159,39 +177,49 @@ class _MemberPageState extends State .official!['title'] != '') ...[ const SizedBox(height: 6), - Row( - children: [ - Text( - _memberController - .memberInfo - .value - .official![ - 'role'] == - 1 - ? '个人认证:' - : '企业认证:', - style: TextStyle( - color: Theme.of(context) - .primaryColor, + Text.rich( + maxLines: 2, + TextSpan( + text: _memberController + .memberInfo + .value + .official!['role'] == + 1 + ? '个人认证:' + : '企业认证:', + style: TextStyle( + color: Theme.of(context) + .primaryColor, + ), + children: [ + TextSpan( + text: _memberController + .memberInfo + .value + .official!['title'], ), - ), - Text( - _memberController.memberInfo - .value.official!['title']!, - ), - ], + ], + ), + softWrap: true, ), ], const SizedBox(height: 4), if (_memberController .memberInfo.value.sign != '') - Text( - _memberController - .memberInfo.value.sign!, - textAlign: TextAlign.left, - maxLines: 2, - overflow: TextOverflow.ellipsis, + SelectableRegion( + magnifierConfiguration: + const TextMagnifierConfiguration(), + focusNode: FocusNode(), + selectionControls: + MaterialTextSelectionControls(), + child: Text( + _memberController + .memberInfo.value.sign!, + textAlign: TextAlign.left, + maxLines: 2, + overflow: TextOverflow.ellipsis, + ), ), ], ), @@ -261,33 +289,50 @@ class _MemberPageState extends State ? memberInfo.face : _memberController.face, ), - Positioned( - bottom: 0, - left: 14, - child: Container( - padding: const EdgeInsets.fromLTRB(6, 2, 6, 2), - decoration: BoxDecoration( - color: Theme.of(context).colorScheme.primary, - borderRadius: - const BorderRadius.all(Radius.circular(10)), - ), - child: Row(children: [ - Image.asset( - 'assets/images/live.gif', - height: 10, + if (!loadingStatus && + memberInfo.liveRoom != null && + memberInfo.liveRoom.liveStatus == 1) + Positioned( + bottom: 0, + left: 14, + child: GestureDetector( + onTap: () { + LiveItemModel liveItem = LiveItemModel.fromJson({ + 'title': memberInfo.liveRoom.title, + 'uname': memberInfo.name, + 'face': memberInfo.face, + 'roomid': memberInfo.liveRoom.roomId, + }); + Get.toNamed( + '/liveRoom?roomid=${memberInfo.liveRoom.roomId}', + arguments: {'liveItem': liveItem}, + ); + }, + child: Container( + padding: const EdgeInsets.fromLTRB(6, 2, 6, 2), + decoration: BoxDecoration( + color: Theme.of(context).colorScheme.primary, + borderRadius: + const BorderRadius.all(Radius.circular(10)), + ), + child: Row(children: [ + Image.asset( + 'assets/images/live.gif', + height: 10, + ), + Text( + ' 直播中', + style: TextStyle( + color: Colors.white, + fontSize: Theme.of(context) + .textTheme + .labelSmall! + .fontSize), + ) + ]), ), - Text( - ' 直播中', - style: TextStyle( - color: Colors.white, - fontSize: Theme.of(context) - .textTheme - .labelSmall! - .fontSize), - ) - ]), - ), - ) + ), + ) ], )), const SizedBox(width: 12), @@ -356,35 +401,51 @@ class _MemberPageState extends State ), ), const SizedBox(height: 10), - Row( - children: [ - TextButton( - onPressed: () {}, - style: TextButton.styleFrom( - padding: const EdgeInsets.only(left: 42, right: 42), - foregroundColor: !loadingStatus && memberInfo.isFollowed - ? null - : Theme.of(context).colorScheme.onPrimary, - backgroundColor: !loadingStatus && memberInfo.isFollowed - ? Theme.of(context).colorScheme.onInverseSurface - : Theme.of(context).colorScheme.primary, // 设置按钮背景色 + if (_memberController.ownerMid != _memberController.mid) ...[ + Row( + children: [ + TextButton( + onPressed: () {}, + style: TextButton.styleFrom( + padding: const EdgeInsets.only(left: 42, right: 42), + foregroundColor: + !loadingStatus && memberInfo.isFollowed + ? Theme.of(context).colorScheme.outline + : Theme.of(context).colorScheme.onPrimary, + backgroundColor: !loadingStatus && + memberInfo.isFollowed + ? Theme.of(context).colorScheme.onInverseSurface + : Theme.of(context) + .colorScheme + .primary, // 设置按钮背景色 + ), + child: Text(!loadingStatus && memberInfo.isFollowed + ? '取关' + : '关注'), ), - child: Text(!loadingStatus && memberInfo.isFollowed - ? '取关' - : '关注'), + const SizedBox(width: 8), + TextButton( + onPressed: () {}, + style: TextButton.styleFrom( + padding: const EdgeInsets.only(left: 42, right: 42), + backgroundColor: + Theme.of(context).colorScheme.onInverseSurface, + ), + child: const Text('发消息'), + ) + ], + ) + ] else ...[ + TextButton( + onPressed: () {}, + style: TextButton.styleFrom( + padding: const EdgeInsets.only(left: 80, right: 80), + foregroundColor: Theme.of(context).colorScheme.onPrimary, + backgroundColor: Theme.of(context).colorScheme.primary, ), - const SizedBox(width: 8), - TextButton( - onPressed: () {}, - style: TextButton.styleFrom( - padding: const EdgeInsets.only(left: 42, right: 42), - backgroundColor: - Theme.of(context).colorScheme.onInverseSurface, - ), - child: const Text('发消息'), - ) - ], - ) + child: const Text('编辑资料'), + ) + ] ], ), ),