circle_app/circle_app/lib/app/msg/view.dart

339 lines
10 KiB
Dart

import 'dart:math';
import 'package:circle_app/app/circle/logic.dart';
import 'package:circle_app/common/Widgets/open_vip_tip/view.dart';
import 'package:circle_app/main.dart';
import 'package:circle_app/network/api.dart';
import 'package:circle_app/network/dio_manager.dart';
import 'package:circle_app/router/app_routers.dart';
import 'package:circle_app/util/util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:scroll_to_index/scroll_to_index.dart';
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
import 'package:tencent_cloud_chat_uikit/ui/controller/tim_uikit_conversation_controller.dart';
import '../../util/eventBus.dart';
import 'TIMUIKitConversation/tim_uikit_conversation.dart';
import 'logic.dart';
class MsgPage extends StatelessWidget {
MsgPage({Key? key}) : super(key: key);
final ctr = Get.put(MsgLogic());
void getPipeiData() async {
var data = await DioManager.instance
.get(url: Api.getMatch);
if(data['code'] == 200) {
//发送消息
bool isSuccess = await createCustomMsg(data['data']['account_id'].toString().split('_').last,data['data']['account_id']);
if (!isSuccess) {
await sendTextMsg(data['data']['account_id']);
}
} else if(data['code'] == 21201){
showOKToast(data['msg']);
showRechargeDialog();
}else{
showOKToast(data['msg']);
}
}
showRechargeDialog(){
Get.bottomSheet(
Scaffold(
backgroundColor: Colors.transparent,
body: Open_vip_tipPage(true),
),
isScrollControlled: true,
enableDrag: false);
}
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
body: Stack(
children: [
Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
decoration: BoxDecoration(
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage(getBaseImage('home_back')))),
),
SafeArea(
child: GetBuilder(builder: (MsgLogic controller) {
return Column(
children: [
navigatorItem(controller),
// tipWidget(),
// reconmandWidget(),
// Text(controller.state.msg),
Expanded(child: msgWdiget(context))
],
);
}),
)
],
),
);
}
navigatorItem(MsgLogic ctr) {
var logic = Get.find<CircleLogic>();
String count = '0';
if (logic != null) {
count = (logic.statistics.value.likeMeCount ?? 0).toString();
}
return Container(
width: Get.width,
padding: EdgeInsets.only(left: 18.sp, right: 18.sp),
height: 44.sp,
child: Stack(
alignment: Alignment.center,
children: [
Positioned(
left: 0,
child: GestureDetector(
onTap: () {
Get.toNamed(AppRoutes.LikeListActivity);
},
child: Stack(
children: [
SizedBox(
width: count.length > 2
? 45.sp
: count.length > 1
? 38.sp
: 35.sp,
height: 30.sp,
),
Image.asset(
getMsgImage('msg_love'),
width: 30.sp,
),
int.parse(count) > 0
? Positioned(
right: 0,
child: Container(
padding:
EdgeInsets.only(left: 5.sp, right: 5.sp),
height: 14.sp,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(7.sp),
gradient: const LinearGradient(
colors: [
Color(0xFFC343F9),
Color(0xFFFB34B2),
],
)),
alignment: Alignment.center,
child: Text(
int.parse(count) > 99 ? '99+' : count,
style: TextStyle(
color: Colors.white,
fontSize: 10.sp,
fontWeight: FontWeight.w500),
),
))
: Container(),
],
))),
ShaderMask(
shaderCallback: (Rect bounds) {
return const LinearGradient(
begin: Alignment(0.0, -1.0),
end: Alignment.bottomCenter,
colors: [Color(0xff71F3F2), Color(0xffF657FF)],
).createShader(Offset.zero & bounds.size);
},
child: GestureDetector(
onTap: () {
logic.listScrollController.animateTo(
0.0,
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
);
},
child: Text(
'消息',
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.w600,
color: Colors.white,
shadows: const [
Shadow(color: Color(0xffF657FF), offset: Offset(0.0, -1))
]),
),
),
),
Positioned(
right: 0,
child: GestureDetector(
onTap: () {
getPipeiData();
},
child: Image.asset(
getMsgImage('msg_pipei'),
width: 85.sp,
),
)),
],
),
);
}
tipWidget() {
return Container(
margin: EdgeInsets.only(top: 18.sp, bottom: 15.sp),
padding: EdgeInsets.only(left: 16.sp, right: 18.sp),
width: Get.width,
height: 20,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'想要聊天的圈友',
style: TextStyle(
color: Colors.white,
fontSize: 16.sp,
fontWeight: FontWeight.w500),
),
GestureDetector(
onTap: () async{
V2TimConversation conv = V2TimConversation(
type: 1,
userID: '10040818',
conversationID: 'c2c_10040818',
showName: '456');
Get.toNamed(AppRoutes.Chat, arguments: conv);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ShaderMask(
shaderCallback: (Rect bounds) {
return const LinearGradient(
begin: Alignment.centerRight,
end: Alignment.centerLeft,
colors: [Color(0xff71F3F2), Color(0xffF657FF)],
).createShader(Offset.zero & bounds.size);
},
child: Text(
'n人等您聊',
style: TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w600,
color: Colors.white),
),
),
Image.asset(
getMsgImage('msg_arr'),
width: 24.sp,
)
],
),
)
],
),
);
}
reconmandWidget() {
return Container(
padding: EdgeInsets.only(left: 16.sp, right: 18.sp),
width: Get.width,
child: Row(
children: [
Column(
children: [
Image.asset(
getMsgImage('msg_first'),
width: 50.sp,
),
SizedBox(
height: 4.sp,
),
Text(
'抢占第一',
style: TextStyle(color: Colors.white, fontSize: 12.sp),
),
],
),
Expanded(
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Container(
// width: 50.sp * 10,
child: Row(
children: [
peopleWidget(),
peopleWidget(),
peopleWidget(),
peopleWidget(),
peopleWidget(),
peopleWidget(),
peopleWidget(),
peopleWidget(),
peopleWidget(),
peopleWidget(),
],
),
),
))
],
),
);
}
peopleWidget() {
return Container(
margin: EdgeInsets.only(left: 18.sp),
child: Column(
children: [
Image.asset(
getMsgImage('msg_first'),
width: 50.sp,
),
SizedBox(
height: 4.sp,
),
Text(
'抢占第一',
style: TextStyle(color: Colors.white, fontSize: 12.sp),
),
],
),
);
}
msgWdiget(context) {
var logic = Get.find<CircleLogic>();
return TIMConversation(
autoScrollController: logic.scrollController,
scrollController: logic.listScrollController,
onTapItem: (selectedConv) async{
String type = selectedConv.userID!.split('_')[2];
if (int.parse(type) == 11) {
Get.toNamed(AppRoutes.Sys_notify_list, arguments: selectedConv);
return;
}
Get.toNamed(AppRoutes.Chat, arguments: selectedConv);
},
);
}
Widget msgItem(conv, status) {
return Container();
}
}