import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:flutter/cupertino.dart'; import '../utils/font_weight.dart'; class AddFriend extends StatefulWidget { @override State createState() { return _AddFriend(); } } class _AddFriend extends State { ApiService apiService; @override void initState() { super.initState(); } ///离开页面记着销毁和清除 @override void dispose() { super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Color(0xFFFFFFFF), appBar: MyAppBar( title: "添加好友", titleColor: Color(0xFF0D0D0D), titleSize: 17.sp, leading: true, leadingColor: Colors.black, background: Color(0xFFFFFFFF), ), body: Container( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding(padding:EdgeInsets.only(left:18.w), child: Column( children: [ Text( "找人", style: TextStyle( fontSize: 16.sp, color: Color(0xFF060606), fontWeight: FontWeight.bold), ), Container( height: 4.h, width: 32.w, margin:EdgeInsets.only(top:5.h), decoration:BoxDecoration( borderRadius: BorderRadius.circular(4.r), color: Color(0xFF32A060), ) ) ], ),), addFriendSearch(), Padding( padding: EdgeInsets.only(left:18.w,bottom: 16.h), child: Text( "好友推荐", style: TextStyle( fontSize: 16.sp, color: Color(0xFF060606), fontWeight: FontWeight.bold), ), ), Expanded( child: ListView.builder( itemCount: 10, physics: BouncingScrollPhysics(), shrinkWrap: true, itemBuilder: (context, position) { return addFriendItem(); }, )), ], ), ), ); } ///添加好友列表 Widget addFriendItem() { return Container( margin: EdgeInsets.only(left:16.w,right:16.w,bottom: 24.h), child: Row(children: [ Container( padding: EdgeInsets.only(right: 4.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(26.5.r), ), child: Image.asset( "assets/image/bs_mine_heading.webp", width: 54.h, height: 54.h, fit: BoxFit.fill, ), ), Expanded( child: Text( "哈喽喽哈", style: TextStyle( fontSize: 16.sp, color: Color(0xFF060606), fontWeight: FontWeight.w500), ), ), GestureDetector( behavior: HitTestBehavior.opaque, onTap:(){ showFriendVerificationDialog(); }, child: Container( padding: EdgeInsets.symmetric(horizontal:18.w,vertical:6.h), decoration: BoxDecoration( borderRadius: BorderRadius.circular(26.5.r), color: Color(0xFF32A060), boxShadow: [ BoxShadow( color: Color(0xFF32A060).withOpacity(0.2), spreadRadius: 0, blurRadius: 4, offset: Offset(0, 4), // changes position of shadow ), ], ), child: Text( "添加", style: TextStyle( fontSize: 12.sp, color: Colors.white, fontWeight:MyFontWeight.regular), ), ), ) ]), ); } ///好友验证弹窗 showFriendVerificationDialog() { showDialog( context: context, builder: (context) { return AlertDialog( contentPadding: EdgeInsets.zero, // 移除默认内边距 content: Container( // width: MediaQuery.of(context).size.width - 84, height: 130.h, decoration: BoxDecoration( borderRadius: BorderRadius.circular(4), ), child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding(padding:EdgeInsets.symmetric(vertical:16.h), child: Text( "好友验证", style: TextStyle( color: Color(0xFF060606), fontSize: 16.sp, fontWeight: MyFontWeight.bold, ), ),), Expanded(child:Text( "我是秀才8856", style: TextStyle( color: Color(0xFF060606), fontSize: 12.sp, fontWeight: MyFontWeight.regular, ), )), // Spacer(), Container( margin:EdgeInsets.only(top:18.h), height:1.h, width: double.infinity, color:Color(0xFFEDEDED), ), Row( children: [ Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pop(); }, child: Container( // height: 38.h, child: Text( "取消", textAlign: TextAlign.center, style: TextStyle( fontSize: 16.sp, color: Color(0xFF060606), ) ) ) ) ), Container( height:45, width: 1.w, color: Color(0xFFEDEDED), ), Expanded( child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context).pop(); }, child: Container( // height: 38.h, child: Text( "确认", textAlign: TextAlign.center, style: TextStyle( color: Color(0xFF060606), ) ) ) ) ) ], ) ], ), ), ); }, ); } /// 搜索框 Widget addFriendSearch() { return GestureDetector( behavior: HitTestBehavior.opaque, onTap:(){Navigator.of(context).pushNamed('/router/im_search');}, child: Container( margin: EdgeInsets.fromLTRB(16.w,22.h, 16.w, 24.h), padding: EdgeInsets.symmetric(vertical: 13.h), decoration: BoxDecoration( color: Color(0xFFFDFCFC), borderRadius: BorderRadius.circular(4), ), child: Row( children: [ Padding( padding: EdgeInsets.only(left: 15.w, right: 5.w), child: Image.asset( "assets/image/icon_search.webp", width: 14.h, height: 14.h, color: Color(0xFF353535), ), ), Text( "搜索", style: TextStyle( color: Color(0xFFA29E9E), fontSize: 16.sp, fontWeight: MyFontWeight.regular, ), ), ], ) ), ); } }