消息加载动画

This commit is contained in:
18631081161 2024-08-04 14:37:38 +08:00
parent 245c647260
commit d691411025
3 changed files with 90 additions and 10 deletions

View File

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../beans/character_info_bean.dart';
import '../../beans/chat_info_bean.dart';
@ -53,6 +54,9 @@ class _ChatPageState extends State<ChatPage> {
bool isHalf = false;
///
bool isSend = true;
///
String text = "";
@ -104,12 +108,13 @@ class _ChatPageState extends State<ChatPage> {
_scrollToBottom();
break;
case "sendMessage":
isSend = true;
chatList.removeLast();
sendMessageBean = newData['data'];
chatList.addAll(sendMessageBean.chatList!);
Future.delayed(Duration(milliseconds: 200), () {
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
});
EasyLoading.dismiss();
break;
case "delChatByIds":
@ -467,8 +472,13 @@ class _ChatPageState extends State<ChatPage> {
)
: GestureDetector(
onTap: () {
EasyLoading.show(status: 'loading...');
if (!isSend) {
return;
}
chatList.add(ChatInfoBean(0, "user", text, "timestamp", "claudeType", 0, "userIcon"));
isSend = false;
chatList.add(ChatInfoBean(0, "loading", "", "", "", 0, ""));
_viewmodel.sendMessage(widget.characterId, text);
_chatController.clear();
text = "";
@ -619,17 +629,47 @@ class _ChatPageState extends State<ChatPage> {
///
_item(index, key) {
final size = MediaQuery.of(context).size;
final b20 = size.width / 18;
final l50 = size.width / 7.2;
final w135 = size.width / 2.666666666;
final h40 = size.width / 9;
final h35 = size.width / 10.285714285714;
// if (index == 0) {
// return Container();
// }
CustomPopupMenuController customController = CustomPopupMenuController();
///
if (chatList[index].role == 'loading') {
return Row(
children: [
Container(
alignment: Alignment.centerLeft,
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
decoration: const BoxDecoration(
color: Color(0xFFFF9000),
borderRadius: BorderRadius.only(topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)),
),
child: SizedBox(
width: l50,
height: h35,
child: const SpinKitThreeBounce(
color: Colors.white,
size: 15.0,
),
),
),
],
);
}
///
if (chatList[index].role == 'profile') {
return Center(
key: key,
child: Container(
margin: EdgeInsets.only(left: 12, right: 12, bottom: 20),
margin: EdgeInsets.only(left: 12, right: 12, bottom: b20),
padding: EdgeInsets.only(left: 20, right: 20, top: 12, bottom: 12),
decoration: BoxDecoration(color: Color(0x99000000), borderRadius: BorderRadius.all(Radius.circular(13))),
child: ExpandableText(
@ -703,7 +743,7 @@ class _ChatPageState extends State<ChatPage> {
child: CustomPopup(
controller: customController,
menuBuilder: () {
return popupView(chatList[index].id!, chatList[index].content!, index, customController);
return popupView(chatList[index].id!, chatList[index].content!, index, customController, w135, h40);
},
barrierColor: Colors.transparent,
//
@ -790,10 +830,10 @@ class _ChatPageState extends State<ChatPage> {
return text.replaceAll(RegExp(r'[()]|[\uFF08\uFF09]'), '*');
}
popupView(int id, String content, index, customController) {
popupView(int id, String content, index, customController, w135, h40) {
return Container(
width: 135,
height: 40,
width: w135,
height: h40,
decoration: BoxDecoration(
color: Color(0xFF222222),
borderRadius: BorderRadius.all(Radius.circular(2)),
@ -813,6 +853,7 @@ class _ChatPageState extends State<ChatPage> {
children: [
Image(width: 11, height: 11, image: AssetImage('assets/images/ic_copy.png')),
Container(
margin: EdgeInsets.only(top: 5),
child: Text(
'复制',
style: TextStyle(fontSize: 8, color: Color(0xFF9D9D9D)),
@ -837,6 +878,7 @@ class _ChatPageState extends State<ChatPage> {
children: [
Image(width: 11, height: 11, image: AssetImage('assets/images/ic_delete.png')),
Container(
margin: EdgeInsets.only(top: 5),
child: Text(
'删除',
style: TextStyle(fontSize: 8, color: Color(0xFF9D9D9D)),

View File

@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import '../../beans/character_info_bean.dart';
import '../../beans/chat_info_bean.dart';
@ -53,6 +54,9 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
bool isHalf = false;
///
bool isSend = true;
///
String text = "";
@ -93,12 +97,13 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
EasyLoading.dismiss();
break;
case "sendMessage":
isSend = true;
chatList.removeLast();
sendMessageBean = newData['data'];
chatList.addAll(sendMessageBean.chatList!);
Future.delayed(Duration(milliseconds: 200), () {
_scrollController.jumpTo(_scrollController.position.maxScrollExtent);
});
EasyLoading.dismiss();
break;
case "delChatByIds":
@ -458,8 +463,14 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
Navigator.of(context).pushNamed('/LoginPage');
return;
}
EasyLoading.show(status: 'loading...');
if (!isSend) {
return;
}
chatList.add(ChatInfoBean(0, "user", text, "timestamp", "claudeType", 0, "userIcon"));
isSend = false;
chatList.add(ChatInfoBean(0, "loading", "", "", "", 0, ""));
_viewmodel.sendMessage(widget.characterId, text);
_chatController.clear();
text = "";
@ -621,11 +632,36 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
final l50 = size.width / 7.2;
final w135 = size.width / 2.666666666;
final h40 = size.width / 9;
final h35 = size.width / 10.285714285714;
// if (index == 0) {
// return Container();
// }
CustomPopupMenuController customController = CustomPopupMenuController();
///
if (chatList[index].role == 'loading') {
return Row(
children: [
Container(
alignment: Alignment.centerLeft,
margin: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
decoration: const BoxDecoration(
color: Color(0xFFFF9000),
borderRadius: BorderRadius.only(topRight: Radius.circular(16.0), bottomLeft: Radius.circular(16.0), bottomRight: Radius.circular(16.0)),
),
child: SizedBox(
width: l50,
height: h35,
child: const SpinKitThreeBounce(
color: Colors.white,
size: 15.0,
),
),
),
],
);
}
///
if (chatList[index].role == 'profile') {
return Center(
@ -815,6 +851,7 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
children: [
Image(width: 11, height: 11, image: AssetImage('assets/images/ic_copy.png')),
Container(
margin: EdgeInsets.only(top: 5),
child: Text(
'复制',
style: TextStyle(fontSize: 8, color: Color(0xFF9D9D9D)),
@ -840,6 +877,7 @@ class _HomeChatPageState extends State<HomeChatPage> with AutomaticKeepAliveClie
children: [
Image(width: 11, height: 11, image: AssetImage('assets/images/ic_delete.png')),
Container(
margin: EdgeInsets.only(top: 5),
child: Text(
'删除',
style: TextStyle(fontSize: 8, color: Color(0xFF9D9D9D)),

View File

@ -38,7 +38,7 @@ class _LoginPageState extends State<LoginPage> {
setState(() {});
}
int _timeLeft = 5; //
int _timeLeft = 60; //
bool _isCountingDown = false;
///