import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:aslan/chatvibe_core/utilities/at_loading_manager.dart'; import 'package:aslan/chatvibe_data/sources/repositories/user_repository_impl.dart'; import 'package:provider/provider.dart'; import 'package:aslan/app_localizations.dart'; import 'package:aslan/chatvibe_ui/components/appbar/chatvibe_appbar.dart'; import 'package:aslan/chatvibe_ui/components/at_compontent.dart'; import 'package:aslan/chatvibe_ui/components/chatvibe_gradient_button.dart'; import 'package:aslan/chatvibe_ui/components/text/at_text.dart'; import 'package:aslan/chatvibe_core/routes/at_fluro_navigator.dart'; import 'package:aslan/chatvibe_data/sources/local/user_manager.dart'; import 'package:aslan/chatvibe_ui/components/dialog/dialog_base.dart'; import 'package:aslan/chatvibe_ui/components/at_page_list.dart'; import 'package:aslan/chatvibe_core/constants/at_room_msg_type.dart'; import 'package:aslan/chatvibe_data/models/message/big_broadcast_group_message.dart'; import 'package:aslan/chatvibe_data/models/message/at_floating_message.dart'; import 'package:aslan/chatvibe_domain/models/res/follow_user_res.dart'; import 'package:aslan/chatvibe_managers/rtc_manager.dart'; import 'package:aslan/chatvibe_managers/rtm_manager.dart'; import 'package:aslan/chatvibe_features/index/main_route.dart'; class InvGamePage extends ATPageList { @override _InvGamePageState createState() => _InvGamePageState(); } class _InvGamePageState extends ATPageListState with SingleTickerProviderStateMixin { final TextEditingController _textEditingController = TextEditingController(); String? lastId; @override void initState() { super.initState(); enablePullUp = true; backgroundColor = Colors.transparent; loadData(1); } @override Widget build(BuildContext context) { return Stack( children: [ Image.asset( "atu_images/index/at_icon_coupon_head_bg.png", width: ScreenUtil().screenWidth, height: 150.w, fit: BoxFit.fill, ), Scaffold( backgroundColor: Colors.transparent, resizeToAvoidBottomInset: false, appBar: ChatVibeStandardAppBar( title: ATAppLocalizations.of(context)!.fansList, actions: [], ), body: SafeArea( top: false, child: Container( margin: EdgeInsetsDirectional.only(top: 15.w), width: ScreenUtil().screenWidth, height: ScreenUtil().screenHeight, decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadiusDirectional.only( topStart: Radius.circular(35.w), ), ), child: Column( children: [ SizedBox(height: 10.w), Row( children: [ SizedBox(width: 10.w), Expanded( child: searchWidget( hint: ATAppLocalizations.of(context)!.searchUserId, controller: _textEditingController, borderColor: Colors.black12, textColor: Colors.grey, ), ), chatvibeGradientButton( text: ATAppLocalizations.of(context)!.search, radius: 25, textSize: 14.sp, textColor: Colors.black, gradient: LinearGradient( colors: [Colors.transparent, Colors.transparent], begin: Alignment.centerLeft, end: Alignment.centerRight, ), onPress: () { if (_textEditingController.text.isNotEmpty) { _searchUser(); }else{ ATLoadingManager.exhibitOperation(); loadData(1); } }, ), SizedBox(width: 10.w), ], ), SizedBox(height: 8.w,), Expanded(child: buildList(context)), ], ), ), ), ), ], ); } @override Widget buildItem(FollowUserRes res) { return GestureDetector( child: Container( decoration: BoxDecoration(), child: Row( children: [ SizedBox(width: 10.w), GestureDetector(onTap: (){ ATNavigatorUtils.push( context, "${MainRoute.person}?isMe=${AccountStorage().getCurrentUser()?.userProfile?.id == res.userProfile?.id}&tageId=${res.userProfile?.id}", ); },child: head( url: res.userProfile?.userAvatar ?? "", width: 55.w, headdress: res.userProfile?.getHeaddress()?.sourceUrl, ),), SizedBox(width: 5.w), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ chatvibeNickNameText( res.userProfile ?.userNickname ?? "", fontSize: 14.sp, textColor: Colors.black, type: res.userProfile ?.getVIP() ?.name ?? "", needScroll: ( res.userProfile ?.userNickname ?.characters.length ?? 0) > 22, ), Row( children: [ Container( height: 35.w, decoration: BoxDecoration( image: DecorationImage( image: AssetImage( (res.userProfile?.hasSpecialId() ?? false) ? "atu_images/general/at_icon_special_id_bg.png" : "atu_images/general/at_icon_id_bg.png", ), fit: BoxFit.contain, ), ), child: Row( textDirection: TextDirection.ltr, children: [ SizedBox(width: 38.w), text( "${res.userProfile?.getID()}", fontSize: 12.sp, textColor: Colors.white, fontWeight: FontWeight.bold, ), SizedBox(width: 5.w), Image.asset( "atu_images/room/at_icon_user_card_copy_id.png", width: 12.w, height: 12.w, ), SizedBox(width: 8.w), ], ), ), SizedBox(width: 12.w), Container( width: (res.userProfile?.age ?? 0) > 999 ? 58.w : 48.w, height: 24.w, decoration: BoxDecoration( image: DecorationImage( image: AssetImage( res.userProfile?.userSex == 0 ? "atu_images/login/at_icon_sex_woman_bg.png" : "atu_images/login/at_icon_sex_man_bg.png", ), ), ), child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ xb(res.userProfile?.userSex), text( "${res.userProfile?.age}", textColor: Colors.white, fontSize: 15.sp, fontWeight: FontWeight.w600, ), SizedBox(width: 3.w), ], ), ), SizedBox(width: 8.w), getWealthLevel( res.userProfile?.wealthLevel ?? 0, width: 58.w, height: 30.w, ), SizedBox(width: 8.w), getUserLevel( res.userProfile?.charmLevel ?? 0, width: 58.w, height: 30.w, ), ], ), ], ), ), SizedBox(width: 15.w), ], ), ), onTap: () { _showSendConfirm(res.userProfile?.account??"",res.userProfile?.id??""); }, ); } void _searchUser() async { try { ATLoadingManager.exhibitOperation(); items.clear(); var result = await AccountRepository().fansMyList( account: _textEditingController.text, ); items.addAll(result); ATLoadingManager.veilRoutine(); setState(() {}); } catch (e) { ATLoadingManager.veilRoutine(); } } @override builderDivider() { // return Divider( // height: 1.w, // color: Color(0xff3D3277).withOpacity(0.5), // indent: 15.w, // ); return Container(height: 8.w); } ///加载数据 @override loadPage({ required int page, required Function(List) onSuccess, Function? onErr, }) async { if (page == 1) { lastId = null; } try { var fansList = await AccountRepository().fansMyList(lastId: lastId); ATLoadingManager.veilRoutine(); if (fansList.isNotEmpty) { lastId = fansList.last.id; } onSuccess(fansList); } catch (e) { ATLoadingManager.veilRoutine(); if (onErr != null) { onErr(); } } } void _showSendConfirm(String account,String userId) { SmartDialog.show( tag: "showConfirmDialog", alignment: Alignment.center, animationType: SmartAnimationType.fade, builder: (_) { return MsgDialog( title: ATAppLocalizations.of(context)!.tips, msg: ATAppLocalizations.of( context, )!.confirmInviteThisUserToTheRoom("$account"), btnText: ATAppLocalizations.of(context)!.confirm, onEnsure: () { BigBroadcastGroupMessage msg = BigBroadcastGroupMessage( ATRoomMsgType.inviteRoom, ATFloatingMessage( userId: AccountStorage().getCurrentUser()?.userProfile?.account, toUserId: userId, userAvatarUrl: AccountStorage().getCurrentUser()?.userProfile?.userAvatar ?? "", roomId: Provider.of( context, listen: false, ).currenRoom?.roomProfile?.roomProfile?.id ?? "", ), ); Provider.of( context, listen: false, ).sendBigBroadcastGroup(msg); SmartDialog.dismiss(tag: "showConfirmDialog"); }, ); }, ); } }