mirror of
https://github.com/Linloir/Simple-TCP-Client.git
synced 2025-12-18 17:28:11 +08:00
Feature:
- Image status indicator (sending, done, failed)
This commit is contained in:
parent
7803294ef4
commit
828fb1b5b9
@ -1,14 +1,18 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-10-14 17:04:20
|
||||
* @LastEditTime : 2022-10-22 23:05:24
|
||||
* @LastEditTime : 2022-10-23 10:52:45
|
||||
* @Description :
|
||||
*/
|
||||
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tcp_client/chat/cubit/chat_cubit.dart';
|
||||
import 'package:tcp_client/chat/model/chat_history.dart';
|
||||
import 'package:tcp_client/repositories/tcp_repository/models/tcp_request.dart';
|
||||
|
||||
class ImageBox extends StatelessWidget {
|
||||
const ImageBox({
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-10-14 17:04:12
|
||||
* @LastEditTime : 2022-10-22 23:06:38
|
||||
* @LastEditTime : 2022-10-23 10:49:14
|
||||
* @Description :
|
||||
*/
|
||||
|
||||
@ -67,7 +67,7 @@ class TextBox extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6.0,),
|
||||
const SizedBox(width: 8.0,),
|
||||
],
|
||||
if(history.status == ChatHistoryStatus.done)
|
||||
...[
|
||||
|
||||
@ -1,15 +1,20 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-10-13 14:03:45
|
||||
* @LastEditTime : 2022-10-22 21:30:26
|
||||
* @LastEditTime : 2022-10-23 10:55:42
|
||||
* @Description :
|
||||
*/
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tcp_client/chat/cubit/chat_cubit.dart';
|
||||
import 'package:tcp_client/chat/model/chat_history.dart';
|
||||
import 'package:tcp_client/chat/view/in_message_box.dart';
|
||||
import 'package:tcp_client/chat/view/out_message_box.dart';
|
||||
import 'package:tcp_client/common/avatar/avatar.dart';
|
||||
import 'package:tcp_client/repositories/common_models/message.dart';
|
||||
import 'package:tcp_client/repositories/tcp_repository/models/tcp_request.dart';
|
||||
|
||||
class HistoryTile extends StatelessWidget {
|
||||
const HistoryTile({
|
||||
@ -55,7 +60,56 @@ class HistoryTile extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
Flexible(
|
||||
child: OutMessageBox(history: history),
|
||||
child: history.message.type == MessageType.image ? Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
if(history.type == ChatHistoryType.outcome && history.status == ChatHistoryStatus.sending)
|
||||
...[
|
||||
SizedBox(
|
||||
height: 12.0,
|
||||
width: 12.0,
|
||||
child: CircularProgressIndicator(
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
strokeWidth: 2.0,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 12.0,),
|
||||
],
|
||||
if(history.type == ChatHistoryType.outcome && history.status == ChatHistoryStatus.done)
|
||||
...[
|
||||
Icon(
|
||||
Icons.check_rounded,
|
||||
color: Colors.grey.withOpacity(0.5),
|
||||
size: 18,
|
||||
),
|
||||
const SizedBox(width: 8.0,),
|
||||
],
|
||||
if(history.type == ChatHistoryType.outcome && history.status == ChatHistoryStatus.failed)
|
||||
...[
|
||||
ClipOval(
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
child: Icon(
|
||||
Icons.error_rounded,
|
||||
color: Colors.white.withOpacity(0.5),
|
||||
size: 18,
|
||||
),
|
||||
onTap: () async {
|
||||
context.read<ChatCubit>().tcpRepository.pushRequest(SendMessageRequest(
|
||||
message: history.message,
|
||||
token: (await SharedPreferences.getInstance()).getInt('token')
|
||||
));
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8.0,),
|
||||
],
|
||||
OutMessageBox(history: history),
|
||||
],
|
||||
) : OutMessageBox(history: history),
|
||||
),
|
||||
const SizedBox(width: 16.0,),
|
||||
UserAvatar(userid: history.message.senderID, size: 42,),
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* @Author : Linloir
|
||||
* @Date : 2022-10-10 08:04:53
|
||||
* @LastEditTime : 2022-10-23 10:32:16
|
||||
* @LastEditTime : 2022-10-23 10:44:13
|
||||
* @Description :
|
||||
*/
|
||||
import 'package:flutter/gestures.dart';
|
||||
@ -49,7 +49,7 @@ class SplashPage extends StatelessWidget {
|
||||
return BlocProvider<InitializationCubit>(
|
||||
create: (context) {
|
||||
return InitializationCubit(
|
||||
serverAddress: '127.0.0.1',
|
||||
serverAddress: 'chat.linloir.cn',
|
||||
serverPort: 20706
|
||||
);
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user