底部导航栏新增:心聊板块 im首页ui绘制;(删除操作暂未处理) 聊天框ui绘制; 好友分组列表ui绘制; 添加好友ui绘制; tab新增下划线圆角处理; 个人中心底部导航栏暂未处理完; 聊天框键盘表情包更多功能收缩效果待优化;dart3_last
After Width: | Height: | Size: 523 B |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 868 B |
After Width: | Height: | Size: 582 B |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 566 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 956 B |
Before Width: | Height: | Size: 948 B After Width: | Height: | Size: 434 B |
After Width: | Height: | Size: 761 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 701 B |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 819 B |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 609 B |
Before Width: | Height: | Size: 946 B |
After Width: | Height: | Size: 342 B |
Before Width: | Height: | Size: 974 B After Width: | Height: | Size: 479 B |
After Width: | Height: | Size: 320 B |
Before Width: | Height: | Size: 762 B After Width: | Height: | Size: 330 B |
Before Width: | Height: | Size: 780 B After Width: | Height: | Size: 505 B |
Before Width: | Height: | Size: 704 B After Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 3.0 KiB |
@ -0,0 +1,191 @@
|
||||
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<StatefulWidget> createState() { |
||||
return _AddFriend(); |
||||
} |
||||
} |
||||
|
||||
class _AddFriend extends State<AddFriend> { |
||||
ApiService apiService; |
||||
final TextEditingController editingController = TextEditingController(); |
||||
FocusNode _focusNode = FocusNode(); |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
} |
||||
|
||||
///离开页面记着销毁和清除 |
||||
@override |
||||
void dispose() { |
||||
_focusNode.unfocus(); |
||||
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), |
||||
) |
||||
) |
||||
], |
||||
),), |
||||
friendGroupSearch(), |
||||
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), |
||||
), |
||||
), |
||||
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), |
||||
), |
||||
) |
||||
]), |
||||
); |
||||
} |
||||
|
||||
/// 搜索框 |
||||
Widget friendGroupSearch() { |
||||
return Container( |
||||
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w,29.h), |
||||
padding: EdgeInsets.symmetric(vertical: 13.h), |
||||
decoration: BoxDecoration( |
||||
color: Color(0xFFFDFCFC), |
||||
borderRadius: BorderRadius.circular(4), |
||||
), |
||||
child: TextField( |
||||
textInputAction: TextInputAction.search, |
||||
onEditingComplete: () { |
||||
FocusScope.of(context).requestFocus(FocusNode()); |
||||
}, |
||||
controller: editingController, |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
), |
||||
decoration: InputDecoration( |
||||
hintText: "搜索", |
||||
hintStyle: TextStyle( |
||||
fontSize: 14.sp, |
||||
color: Color(0xFFA29E9E), |
||||
), |
||||
isCollapsed: true, |
||||
prefixIcon: 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(0xFFB3B3B3), |
||||
), |
||||
), |
||||
prefixIconConstraints: BoxConstraints(), |
||||
border: InputBorder.none, |
||||
), |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,134 @@
|
||||
import 'dart:ui'; |
||||
|
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter/rendering.dart'; |
||||
import 'package:flutter/services.dart'; |
||||
import 'package:flutter_easyloading/flutter_easyloading.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 '../../generated/l10n.dart'; |
||||
import '../../utils/font_weight.dart'; |
||||
import '../main.dart'; |
||||
import '../utils/event_type.dart'; |
||||
import '../view_widget/my_tab.dart'; |
||||
import 'im_view/custom_underline_tabIndicator.dart'; |
||||
import 'im_view/friend_groip_list.dart'; |
||||
|
||||
class ChatFriendGroup extends StatefulWidget { |
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _ChatFriendGroup(); |
||||
} |
||||
} |
||||
|
||||
class _ChatFriendGroup extends State<ChatFriendGroup> |
||||
with SingleTickerProviderStateMixin { |
||||
ApiService apiService; |
||||
TabController tabController; |
||||
List<GlobalKey> _allKey = []; |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
tabController = TabController(length: 3, vsync: this, initialIndex: 0); |
||||
loadFinish(); |
||||
} |
||||
|
||||
loadFinish() { |
||||
_allKey = [GlobalKey(), GlobalKey(), GlobalKey(), GlobalKey()]; |
||||
setState(() {}); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
backgroundColor: Color(0xFFFFFFFF), |
||||
appBar: MyAppBar( |
||||
title: "好友(2)", |
||||
titleColor: Color(0xFF0D0D0D), |
||||
titleSize: 17.sp, |
||||
leading: true, |
||||
leadingColor: Colors.black, |
||||
background: Color(0xFFFFFFFF), |
||||
action: GestureDetector( |
||||
behavior: HitTestBehavior.opaque, |
||||
onTap: () { |
||||
Navigator.of(context).pushNamed('/router/add_friend'); |
||||
}, |
||||
child: Container( |
||||
padding: EdgeInsets.all(12), |
||||
decoration: BoxDecoration( |
||||
color: Color(0xFFFFFFFF), |
||||
borderRadius: BorderRadius.circular(20.r), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Color(0xFF000000).withAlpha(25), |
||||
offset: Offset(0, 0), |
||||
blurRadius: 4, |
||||
spreadRadius: 0, |
||||
) |
||||
], |
||||
), |
||||
child: Image.asset( |
||||
"assets/image/add_friend.webp", |
||||
fit: BoxFit.fill, |
||||
height: 14.h,width: 14.h, |
||||
), |
||||
), |
||||
), |
||||
), |
||||
body: Container( |
||||
child: Column( |
||||
children: [ |
||||
Align( |
||||
alignment: Alignment.centerLeft, |
||||
child: Theme( |
||||
data: ThemeData( |
||||
splashColor: Colors.transparent, // 点击时的水波纹颜色设置为透明 |
||||
highlightColor: Colors.transparent, // 点击时的背景高亮颜色设置为透明 |
||||
), |
||||
child: TabBar( |
||||
controller: tabController, |
||||
isScrollable: true, |
||||
//可滚动 |
||||
labelColor: Color(0xFF060606), |
||||
labelStyle: TextStyle( |
||||
fontSize: 16.sp, |
||||
fontWeight: FontWeight.bold, |
||||
), |
||||
unselectedLabelStyle: TextStyle( |
||||
fontSize: 15.sp, |
||||
fontWeight: FontWeight.normal, |
||||
), |
||||
//未选中文字颜色 |
||||
unselectedLabelColor: Color(0XFFA29E9E), |
||||
indicator: CustomUnderlineTabIndicator( |
||||
insets: EdgeInsets.only(top: 10.w, bottom: 2.w), |
||||
borderSide: BorderSide(width: 5.w, color: Color(0XFF32A060)),), |
||||
indicatorSize: TabBarIndicatorSize.label, |
||||
//指示器与文字等宽 |
||||
tabs: <Widget>[ |
||||
MyTab(text: S.of(context).haoyou), |
||||
MyTab(text: S.of(context).guanzhu), |
||||
MyTab(text: S.of(context).fensi), |
||||
], |
||||
)), |
||||
), |
||||
Expanded( |
||||
child: TabBarView( |
||||
controller: tabController, |
||||
children: [ |
||||
FriendGroupList(_allKey[0]), |
||||
FriendGroupList(_allKey[1]), |
||||
FriendGroupList(_allKey[2]), |
||||
], |
||||
), |
||||
) |
||||
], |
||||
), |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart'; |
||||
|
||||
|
||||
|
||||
///参考UnderlineTabIndicator,仅仅修改画笔StrokeCap.square 为 StrokeCap.round |
||||
class CustomUnderlineTabIndicator extends Decoration { |
||||
/// Create an underline style selected tab indicator. |
||||
/// |
||||
/// The [borderSide] and [insets] arguments must not be null. |
||||
const CustomUnderlineTabIndicator({ |
||||
this.borderSide = const BorderSide(width: 2.0, color: Colors.white), |
||||
this.insets = EdgeInsets.zero, |
||||
}) : assert(borderSide != null), |
||||
assert(insets != null); |
||||
|
||||
/// The color and weight of the horizontal line drawn below the selected tab. |
||||
final BorderSide borderSide; |
||||
|
||||
/// Locates the selected tab's underline relative to the tab's boundary. |
||||
/// |
||||
/// The [TabBar.indicatorSize] property can be used to define the tab |
||||
/// indicator's bounds in terms of its (centered) tab widget with |
||||
/// [TabBarIndicatorSize.label], or the entire tab with |
||||
/// [TabBarIndicatorSize.tab]. |
||||
final EdgeInsetsGeometry insets; |
||||
|
||||
@override |
||||
Decoration lerpFrom(Decoration a, double t) { |
||||
if (a is UnderlineTabIndicator) { |
||||
return UnderlineTabIndicator( |
||||
borderSide: BorderSide.lerp(a.borderSide, borderSide, t), |
||||
insets: EdgeInsetsGeometry.lerp(a.insets, insets, t), |
||||
); |
||||
} |
||||
return super.lerpFrom(a, t); |
||||
} |
||||
|
||||
@override |
||||
Decoration lerpTo(Decoration b, double t) { |
||||
if (b is UnderlineTabIndicator) { |
||||
return UnderlineTabIndicator( |
||||
borderSide: BorderSide.lerp(borderSide, b.borderSide, t), |
||||
insets: EdgeInsetsGeometry.lerp(insets, b.insets, t), |
||||
); |
||||
} |
||||
return super.lerpTo(b, t); |
||||
} |
||||
|
||||
@override |
||||
_UnderlinePainter createBoxPainter([VoidCallback onChanged]) { |
||||
return _UnderlinePainter(this, onChanged); |
||||
} |
||||
|
||||
Rect _indicatorRectFor(Rect rect, TextDirection textDirection) { |
||||
assert(rect != null); |
||||
assert(textDirection != null); |
||||
final Rect indicator = insets.resolve(textDirection).deflateRect(rect); |
||||
return Rect.fromLTWH( |
||||
indicator.left, |
||||
indicator.bottom - borderSide.width, |
||||
indicator.width, |
||||
borderSide.width, |
||||
); |
||||
} |
||||
|
||||
@override |
||||
Path getClipPath(Rect rect, TextDirection textDirection) { |
||||
return Path()..addRect(_indicatorRectFor(rect, textDirection)); |
||||
} |
||||
} |
||||
|
||||
class _UnderlinePainter extends BoxPainter { |
||||
_UnderlinePainter(this.decoration, VoidCallback onChanged) |
||||
: assert(decoration != null), |
||||
super(onChanged); |
||||
|
||||
final CustomUnderlineTabIndicator decoration; |
||||
|
||||
BorderSide get borderSide => decoration?.borderSide; |
||||
|
||||
EdgeInsetsGeometry get insets => decoration?.insets; |
||||
|
||||
@override |
||||
void paint(Canvas canvas, Offset offset, ImageConfiguration configuration) { |
||||
assert(configuration != null); |
||||
assert(configuration.size != null); |
||||
final Rect rect = offset & configuration.size; |
||||
final TextDirection textDirection = configuration.textDirection; |
||||
final Rect indicator = decoration._indicatorRectFor(rect, textDirection) |
||||
.deflate(decoration.borderSide.width / 2.0); |
||||
final Paint paint = decoration.borderSide.toPaint(); |
||||
paint.strokeWidth = 5; |
||||
paint.strokeCap = StrokeCap.round; //主要是修改此处 圆角 |
||||
canvas.drawLine(indicator.bottomLeft, indicator.bottomRight, paint); |
||||
} |
||||
} |
@ -0,0 +1,125 @@
|
||||
import 'package:flutter/cupertino.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
|
||||
import '../../retrofit/retrofit_api.dart'; |
||||
|
||||
class FriendGroupList extends StatefulWidget { |
||||
FriendGroupList( |
||||
Key key, |
||||
) : super(key: key); |
||||
|
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _FriendGroupList(); |
||||
} |
||||
} |
||||
|
||||
class _FriendGroupList extends State<FriendGroupList> { |
||||
ApiService apiService; |
||||
final TextEditingController editingController = TextEditingController(); |
||||
FocusNode _focusNode = FocusNode(); |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
} |
||||
|
||||
///离开页面记着销毁和清除 |
||||
@override |
||||
void dispose() { |
||||
_focusNode.unfocus(); |
||||
super.dispose(); |
||||
} |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Container( |
||||
color: Colors.white, |
||||
child: Column( |
||||
children: [ |
||||
friendGroupSearch(), |
||||
Expanded( |
||||
child: ListView.builder( |
||||
itemCount: 10, |
||||
physics: BouncingScrollPhysics(), |
||||
shrinkWrap: true, |
||||
itemBuilder: (context, position) { |
||||
return friendGroupItem(); |
||||
}, |
||||
)), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
|
||||
Widget friendGroupItem() { |
||||
return Container( |
||||
margin: EdgeInsets.only(left:16.w,right:16.w,bottom: 24.h), |
||||
child: Row(children: [ |
||||
Container( |
||||
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, |
||||
), |
||||
), |
||||
Padding( |
||||
padding: EdgeInsets.only(left: 4.w), |
||||
child: Text( |
||||
"哈喽喽哈", |
||||
style: TextStyle( |
||||
fontSize: 16.sp, |
||||
color: Color(0xFF060606), |
||||
fontWeight: FontWeight.w500), |
||||
), |
||||
) |
||||
]), |
||||
); |
||||
} |
||||
|
||||
/// 搜索框 |
||||
Widget friendGroupSearch() { |
||||
return Container( |
||||
margin: EdgeInsets.fromLTRB(16.w, 8.h, 16.w,24.h), |
||||
padding: EdgeInsets.symmetric(vertical: 13.h), |
||||
decoration: BoxDecoration( |
||||
color: Color(0xFFFDFCFC), |
||||
borderRadius: BorderRadius.circular(4), |
||||
), |
||||
child: TextField( |
||||
textInputAction: TextInputAction.search, |
||||
onEditingComplete: () { |
||||
FocusScope.of(context).requestFocus(FocusNode()); |
||||
}, |
||||
controller: editingController, |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
), |
||||
decoration: InputDecoration( |
||||
hintText: "搜索", |
||||
hintStyle: TextStyle( |
||||
fontSize: 14.sp, |
||||
color: Color(0xFFA29E9E), |
||||
), |
||||
isCollapsed: true, |
||||
prefixIcon: 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(0xFFB3B3B3), |
||||
), |
||||
), |
||||
prefixIconConstraints: BoxConstraints(), |
||||
border: InputBorder.none, |
||||
), |
||||
), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,388 @@
|
||||
import 'package:dio/dio.dart'; |
||||
import 'package:flutter/material.dart'; |
||||
import 'package:flutter_easyloading/flutter_easyloading.dart'; |
||||
import 'package:huixiang/generated/l10n.dart'; |
||||
import 'package:huixiang/retrofit/data/base_data.dart'; |
||||
import 'package:huixiang/retrofit/data/message.dart'; |
||||
import 'package:huixiang/retrofit/data/msg_stats.dart'; |
||||
import 'package:huixiang/retrofit/data/page.dart'; |
||||
import 'package:huixiang/retrofit/retrofit_api.dart'; |
||||
import 'package:huixiang/utils/font_weight.dart'; |
||||
import 'package:huixiang/view_widget/classic_header.dart'; |
||||
import 'package:huixiang/view_widget/my_footer.dart'; |
||||
import 'package:huixiang/view_widget/round_button.dart'; |
||||
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
||||
import 'package:shared_preferences/shared_preferences.dart'; |
||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
||||
import 'on_chat_message.dart'; |
||||
import 'on_chat_msg_instance.dart'; |
||||
|
||||
class IMPage extends StatefulWidget { |
||||
|
||||
IMPage(Key key): super(key: key); |
||||
@override |
||||
State<StatefulWidget> createState() { |
||||
return _IMPage(); |
||||
} |
||||
} |
||||
|
||||
class _IMPage extends State<IMPage> implements OnChatMessage { |
||||
ApiService apiService; |
||||
int pageNum = 1; |
||||
List<Message> messages = []; |
||||
Map<String, int> msgNumber = { |
||||
"1": 0, |
||||
"2": 0, |
||||
"3": 0, |
||||
"4": 0, |
||||
"5": 0, |
||||
"6": 0, |
||||
}; |
||||
int state = 0; |
||||
final TextEditingController imEditingController = TextEditingController(); |
||||
|
||||
@override |
||||
void onMessage(txt){ |
||||
// SmartDialog.showToast("列表 $txt", alignment: Alignment.center); |
||||
} |
||||
|
||||
@override |
||||
void dispose() { |
||||
super.dispose(); |
||||
OnChatMsgInstance.instance.onChatMessage = null; |
||||
} |
||||
|
||||
@override |
||||
void initState() { |
||||
super.initState(); |
||||
OnChatMsgInstance.instance.onChatMessage = this; |
||||
|
||||
SharedPreferences.getInstance().then((value) { |
||||
apiService = |
||||
ApiService(Dio(), token: value.getString("token"), context: context); |
||||
queryMessage(); |
||||
queryMsgStats(); |
||||
}); |
||||
} |
||||
|
||||
_refresh() { |
||||
pageNum = 1; |
||||
queryMessage(); |
||||
queryMsgStats(); |
||||
} |
||||
|
||||
queryMessage() async { |
||||
BaseData<PageInfo<Message>> baseData = await apiService.msgList({ |
||||
"pageNum": pageNum, |
||||
"pageSize": 10, |
||||
"searchKey": "", |
||||
"state": "", |
||||
"typed": "" |
||||
}).catchError((onError) { |
||||
_refreshController.loadFailed(); |
||||
_refreshController.refreshFailed(); |
||||
}); |
||||
|
||||
if (baseData != null && baseData.isSuccess) { |
||||
if (pageNum == 1) { |
||||
messages.clear(); |
||||
} |
||||
List<Message> message = []; |
||||
message.addAll(baseData.data.list); |
||||
message.forEach((element) { |
||||
if (element.typed == 2 || element.typed == 3) { |
||||
messages.add(element); |
||||
} |
||||
}); |
||||
_refreshController.loadComplete(); |
||||
_refreshController.refreshCompleted(); |
||||
if (mounted) setState(() {}); |
||||
if (pageNum * 10 > int.tryParse(baseData.data.total)) { |
||||
_refreshController.loadNoData(); |
||||
} else { |
||||
pageNum += 1; |
||||
} |
||||
} else { |
||||
_refreshController.loadFailed(); |
||||
_refreshController.refreshFailed(); |
||||
} |
||||
} |
||||
|
||||
queryMsgStats() async { |
||||
if (apiService == null) { |
||||
SharedPreferences value = await SharedPreferences.getInstance(); |
||||
apiService = ApiService( |
||||
Dio(), |
||||
context: context, |
||||
token: value.getString("token"), |
||||
); |
||||
} |
||||
BaseData<List<MsgStats>> baseData = |
||||
await apiService.stats().catchError((onError) {}); |
||||
if (baseData != null && baseData.isSuccess) { |
||||
setState(() { |
||||
msgNumber.forEach((key, value) { |
||||
msgNumber[key] = 0; |
||||
}); |
||||
baseData.data.forEach((element) { |
||||
if (msgNumber.containsKey(element.name)) { |
||||
msgNumber[element.name] = element.number; |
||||
} |
||||
}); |
||||
}); |
||||
_refreshController.loadComplete(); |
||||
_refreshController.refreshCompleted(); |
||||
} |
||||
EasyLoading.dismiss(); |
||||
} |
||||
|
||||
RefreshController _refreshController = RefreshController(); |
||||
|
||||
@override |
||||
Widget build(BuildContext context) { |
||||
return Scaffold( |
||||
backgroundColor: Color(0xFFFFFFFF), |
||||
body: SmartRefresher( |
||||
enablePullDown: true, |
||||
enablePullUp: false, |
||||
header: MyHeader(), |
||||
physics: BouncingScrollPhysics(), |
||||
footer: CustomFooter( |
||||
loadStyle: LoadStyle.ShowWhenLoading, |
||||
builder: (BuildContext context, LoadStatus mode) { |
||||
return (messages.length == 0) ? Container() : MyFooter(mode); |
||||
}, |
||||
), |
||||
controller: _refreshController, |
||||
onRefresh: _refresh, |
||||
onLoading: () { |
||||
setState(() { |
||||
_refresh(); |
||||
}); |
||||
}, |
||||
child: Container( |
||||
// color: Colors.white, |
||||
decoration: BoxDecoration( |
||||
gradient: LinearGradient( |
||||
begin: Alignment.topCenter, |
||||
end: Alignment.bottomCenter, |
||||
colors: [ |
||||
Color(0xFFD9FFDE), |
||||
Color(0xFFD9FFDE), |
||||
Color(0xFFFFFFFF), |
||||
Color(0xFFFFFFFF), |
||||
], |
||||
stops: [ |
||||
0, |
||||
0.2, |
||||
0.4, |
||||
1 |
||||
]), |
||||
), |
||||
child: SingleChildScrollView( |
||||
physics: BouncingScrollPhysics(), |
||||
child: Container( |
||||
padding: EdgeInsets.only(bottom: 30.h), |
||||
child: Column( |
||||
children: [ |
||||
Container( |
||||
padding: EdgeInsets.only( |
||||
top: MediaQuery.of(context).padding.top + 12.h, |
||||
bottom: 15.h,right: 16.w,left: 16.w), |
||||
child: Row( |
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween, |
||||
crossAxisAlignment: CrossAxisAlignment.center, |
||||
children: [ |
||||
Expanded( |
||||
child: Text( |
||||
S.of(context).xiaoxi, |
||||
style: TextStyle( |
||||
color: Colors.black, |
||||
fontSize: 18.sp, |
||||
fontWeight: MyFontWeight.bold, |
||||
), |
||||
)), |
||||
GestureDetector( |
||||
behavior: HitTestBehavior.opaque, |
||||
onTap: () { |
||||
Navigator.of(context).pushNamed('/router/chat_friend_group'); |
||||
}, |
||||
child: Container( |
||||
padding: EdgeInsets.all(12), |
||||
decoration: BoxDecoration( |
||||
color: Color(0xFFFFFFFF), |
||||
borderRadius: BorderRadius.circular(20.r), |
||||
), |
||||
child: Image.asset( |
||||
"assets/image/friend_grouping.webp", |
||||
fit: BoxFit.fill, |
||||
height: 14.h,width: 14.h, |
||||
), |
||||
), |
||||
), |
||||
], |
||||
), |
||||
), |
||||
imSearchItem(), |
||||
chatList(), |
||||
// buildMessage(),fgg |
||||
], |
||||
), |
||||
), |
||||
), |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
///搜索 |
||||
Widget imSearchItem() { |
||||
return Container( |
||||
margin: EdgeInsets.fromLTRB(16.w, 0, 16.w, 0), |
||||
padding: EdgeInsets.symmetric(vertical:13.h), |
||||
decoration: BoxDecoration( |
||||
color: Color(0xFFFFFFFF), |
||||
borderRadius: BorderRadius.circular(4), |
||||
boxShadow: [ |
||||
BoxShadow( |
||||
color: Colors.black.withAlpha(12), |
||||
offset: Offset(0, 3), |
||||
blurRadius: 14, |
||||
spreadRadius: 0, |
||||
), |
||||
], |
||||
), |
||||
child: TextField( |
||||
textInputAction: TextInputAction.search, |
||||
onEditingComplete: () { |
||||
FocusScope.of(context).requestFocus(FocusNode()); |
||||
}, |
||||
controller: imEditingController, |
||||
style: TextStyle( |
||||
fontSize: 14.sp, |
||||
), |
||||
decoration: InputDecoration( |
||||
hintText: "搜索", |
||||
hintStyle: TextStyle( |
||||
fontSize: 14.sp, |
||||
color: Color(0xFFA29E9E), |
||||
), |
||||
isCollapsed: true, |
||||
prefixIcon: 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), |
||||
), |
||||
), |
||||
prefixIconConstraints: BoxConstraints(), |
||||
border: InputBorder.none, |
||||
), |
||||
), |
||||
); |
||||
} |
||||
|
||||
///聊天列表 |
||||
Widget chatList(){ |
||||
return Container( |
||||
child: ListView.builder( |
||||
padding: EdgeInsets.only(top: 16), |
||||
itemCount: 6, |
||||
shrinkWrap: true, |
||||
physics: NeverScrollableScrollPhysics(), |
||||
itemBuilder: (context, position) { |
||||
return GestureDetector( |
||||
behavior:HitTestBehavior.opaque, |
||||
onTap: () { |
||||
Navigator.of(context).pushNamed('/router/chat_details_page'); |
||||
}, |
||||
child: chatItem(), |
||||
); |
||||
}), |
||||
); |
||||
} |
||||
|
||||
Widget chatItem(){ |
||||
return Container( |
||||
padding: EdgeInsets.only(left: 16.w,right: 17.w,bottom:18.h), |
||||
child: Row( |
||||
children: [ |
||||
// MImage( |
||||
// "", |
||||
// isCircle: true, |
||||
// width: 40, |
||||
// height: 40, |
||||
// fit: BoxFit.cover, |
||||
// errorSrc: "assets/image/default_user.webp", |
||||
// fadeSrc: "assets/image/default_user.webp", |
||||
// ), |
||||
Image.asset( |
||||
"assets/image/fuka_zj.webp", |
||||
height:54.h, |
||||
width:54.h, |
||||
), |
||||
SizedBox(width: 12.w,), |
||||
Expanded(child: |
||||
Column( |
||||
crossAxisAlignment: CrossAxisAlignment.start, |
||||
children: [ |
||||
Row( |
||||
children: [ |
||||
Expanded(child: Text( |
||||
"喽哈", |
||||
overflow: TextOverflow.ellipsis, |
||||
maxLines: 1, |
||||
style: TextStyle( |
||||
fontSize: 16.sp, |
||||
color: Color(0xFF060606), |
||||
fontWeight: MyFontWeight.semi_bold, |
||||
)),), |
||||
Text( |
||||
"2021.03.08 13:22", |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
color: Color(0xFFA29E9E), |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
), |
||||
], |
||||
), |
||||
SizedBox(height: 7.h,), |
||||
Row( |
||||
children: [ |
||||
Expanded(child:Text( |
||||
"新开的火锅店好吃得很", |
||||
maxLines: 1, |
||||
overflow: TextOverflow.ellipsis, |
||||
style: TextStyle( |
||||
fontSize: 12.sp, |
||||
color: Color(0xFF353535), |
||||
fontWeight: MyFontWeight.regular, |
||||
), |
||||
)), |
||||
Container( |
||||
width: 16, |
||||
height: 16, |
||||
decoration: BoxDecoration( |
||||
borderRadius: BorderRadius.circular(100), |
||||
color: Color(0xFFFF441A), |
||||
), |
||||
child: RoundButton( |
||||
text:"99", |
||||
textColor: Colors.white, |
||||
fontWeight: MyFontWeight.regular, |
||||
backgroup: Color(0xFFFF441A), |
||||
fontSize: 10.sp, |
||||
radius: 100, |
||||
)) |
||||
], |
||||
) |
||||
], |
||||
)), |
||||
], |
||||
), |
||||
); |
||||
} |
||||
} |