Merge pull request #1831 from Heap-Hop/feat/cm_chat_page_unread_msg

feat: desktop cm chat page unread msg
This commit is contained in:
RustDesk
2022-10-27 06:53:32 +08:00
committed by GitHub
10 changed files with 162 additions and 124 deletions

View File

@@ -175,7 +175,7 @@ class _FileManagerPageState extends State<FileManagerPage>
},
child: IconButton(
icon: const Icon(Icons.more_vert),
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
onPressed: () => mod_menu.showMenu(
context: context,
position: menuPos,
@@ -482,12 +482,12 @@ class _FileManagerPageState extends State<FileManagerPage>
onPressed: () {
model.resumeJob(item.id);
},
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
icon: const Icon(Icons.restart_alt_rounded)),
),
IconButton(
icon: const Icon(Icons.delete_forever_outlined),
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
onPressed: () {
model.jobTable.removeAt(index);
model.cancelJob(item.id);
@@ -556,7 +556,7 @@ class _FileManagerPageState extends State<FileManagerPage>
children: [
IconButton(
icon: const Icon(Icons.arrow_back),
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
onPressed: () {
selectedItems.clear();
model.goBack(isLocal: isLocal);
@@ -564,7 +564,7 @@ class _FileManagerPageState extends State<FileManagerPage>
),
IconButton(
icon: const Icon(Icons.arrow_upward),
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
onPressed: () {
selectedItems.clear();
model.goToParentDirectory(isLocal: isLocal);
@@ -614,13 +614,13 @@ class _FileManagerPageState extends State<FileManagerPage>
Future.delayed(
Duration.zero, () => focusNode.requestFocus());
},
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
icon: Icon(Icons.search));
case LocationStatus.pathLocation:
return IconButton(
color: Theme.of(context).disabledColor,
onPressed: null,
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
icon: Icon(Icons.close));
case LocationStatus.fileSearchBar:
return IconButton(
@@ -638,7 +638,7 @@ class _FileManagerPageState extends State<FileManagerPage>
breadCrumbScrollToEnd(isLocal);
model.refresh(isLocal: isLocal);
},
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
icon: const Icon(Icons.refresh)),
],
),
@@ -655,7 +655,7 @@ class _FileManagerPageState extends State<FileManagerPage>
model.goHome(isLocal: isLocal);
},
icon: const Icon(Icons.home_outlined),
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
),
IconButton(
onPressed: () {
@@ -704,7 +704,7 @@ class _FileManagerPageState extends State<FileManagerPage>
);
});
},
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
icon: const Icon(Icons.create_new_folder_outlined)),
IconButton(
onPressed: validItems(selectedItems)
@@ -714,7 +714,7 @@ class _FileManagerPageState extends State<FileManagerPage>
selectedItems.clear();
}
: null,
splashRadius: 20,
splashRadius: kDesktopIconButtonSplashRadius,
icon: const Icon(Icons.delete_forever_outlined)),
menu(isLocal: isLocal),
],

View File

@@ -5,7 +5,6 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_hbb/consts.dart';
import 'package:flutter_hbb/desktop/widgets/tabbar_widget.dart';
import 'package:flutter_hbb/mobile/pages/chat_page.dart';
import 'package:flutter_hbb/models/chat_model.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
@@ -13,6 +12,7 @@ import 'package:window_manager/window_manager.dart';
import 'package:flutter_svg/flutter_svg.dart';
import '../../common.dart';
import '../../common/widgets/chat_page.dart';
import '../../models/platform_model.dart';
import '../../models/server_model.dart';
@@ -107,6 +107,13 @@ class ConnectionManagerState extends State<ConnectionManager> {
@override
Widget build(BuildContext context) {
final serverModel = Provider.of<ServerModel>(context);
final pointerHandler = serverModel.cmHiddenTimer != null
? (PointerEvent e) {
serverModel.cmHiddenTimer!.cancel();
serverModel.cmHiddenTimer = null;
debugPrint("CM hidden timer has been canceled");
}
: null;
return serverModel.clients.isEmpty
? Column(
children: [
@@ -118,35 +125,44 @@ class ConnectionManagerState extends State<ConnectionManager> {
),
],
)
: DesktopTab(
showTitle: false,
showMaximize: false,
showMinimize: true,
showClose: true,
controller: serverModel.tabController,
maxLabelWidth: 100,
tail: buildScrollJumper(),
selectedTabBackgroundColor:
Theme.of(context).hintColor.withOpacity(0.2),
tabBuilder: (key, icon, label, themeConf) {
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
icon,
Tooltip(
message: key,
waitDuration: Duration(seconds: 1),
child: label),
],
);
},
pageViewBuilder: (pageView) => Row(children: [
Expanded(child: pageView),
Consumer<ChatModel>(
builder: (_, model, child) => model.isShowChatPage
? Expanded(child: Scaffold(body: ChatPage()))
: Offstage())
]));
: Listener(
onPointerDown: pointerHandler,
onPointerMove: pointerHandler,
child: DesktopTab(
showTitle: false,
showMaximize: false,
showMinimize: true,
showClose: true,
controller: serverModel.tabController,
maxLabelWidth: 100,
tail: buildScrollJumper(),
selectedTabBackgroundColor:
Theme.of(context).hintColor.withOpacity(0.2),
tabBuilder: (key, icon, label, themeConf) {
final client = serverModel.clients.firstWhereOrNull(
(client) => client.id.toString() == key);
return Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Tooltip(
message: key,
waitDuration: Duration(seconds: 1),
child: label),
Obx(() => Offstage(
offstage:
!(client?.hasUnreadChatMessage.value ?? false),
child:
Icon(Icons.circle, color: Colors.red, size: 10)))
],
);
},
pageViewBuilder: (pageView) => Row(children: [
Expanded(child: pageView),
Consumer<ChatModel>(
builder: (_, model, child) => model.isShowChatPage
? Expanded(child: Scaffold(body: ChatPage()))
: Offstage())
])));
}
Widget buildTitleBar() {
@@ -334,10 +350,10 @@ class _CmHeaderState extends State<_CmHeader>
Offstage(
offstage: !client.authorized || client.isFileTransfer,
child: IconButton(
onPressed: () => checkClickTime(
client.id, () => gFFI.chatModel.toggleCMChatPage(client.id)),
icon: Icon(Icons.message_outlined),
),
onPressed: () => checkClickTime(
client.id, () => gFFI.chatModel.toggleCMChatPage(client.id)),
icon: Icon(Icons.message_outlined),
splashRadius: kDesktopIconButtonSplashRadius),
)
],
);