mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-04-06 20:11:26 +03:00
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:
@@ -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),
|
||||
],
|
||||
|
||||
@@ -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),
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
@@ -29,6 +29,7 @@ class TabInfo {
|
||||
final IconData? unselectedIcon;
|
||||
final bool closable;
|
||||
final VoidCallback? onTabCloseButton;
|
||||
final VoidCallback? onTap;
|
||||
final Widget page;
|
||||
|
||||
TabInfo(
|
||||
@@ -38,6 +39,7 @@ class TabInfo {
|
||||
this.unselectedIcon,
|
||||
this.closable = true,
|
||||
this.onTabCloseButton,
|
||||
this.onTap,
|
||||
required this.page});
|
||||
}
|
||||
|
||||
@@ -56,6 +58,8 @@ class DesktopTabState {
|
||||
final PageController pageController = PageController();
|
||||
int selected = 0;
|
||||
|
||||
TabInfo get selectedTabInfo => tabs[selected];
|
||||
|
||||
DesktopTabState() {
|
||||
scrollController.itemCount = tabs.length;
|
||||
}
|
||||
@@ -73,7 +77,7 @@ class DesktopTabController {
|
||||
|
||||
int get length => state.value.tabs.length;
|
||||
|
||||
void add(TabInfo tab, {bool authorized = false}) {
|
||||
void add(TabInfo tab) {
|
||||
if (!isDesktop) return;
|
||||
final index = state.value.tabs.indexWhere((e) => e.key == tab.key);
|
||||
int toIndex;
|
||||
@@ -87,16 +91,6 @@ class DesktopTabController {
|
||||
toIndex = state.value.tabs.length - 1;
|
||||
assert(toIndex >= 0);
|
||||
}
|
||||
if (tabType == DesktopTabType.cm) {
|
||||
Future.delayed(Duration.zero, () async {
|
||||
window_on_top(null);
|
||||
});
|
||||
if (authorized) {
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
windowManager.minimize();
|
||||
});
|
||||
}
|
||||
}
|
||||
try {
|
||||
jumpTo(toIndex);
|
||||
} catch (e) {
|
||||
@@ -127,12 +121,12 @@ class DesktopTabController {
|
||||
if (!isDesktop || index < 0) return;
|
||||
state.update((val) {
|
||||
val!.selected = index;
|
||||
Future.delayed(Duration.zero, (() {
|
||||
Future.delayed(Duration(milliseconds: 100), (() {
|
||||
if (val.pageController.hasClients) {
|
||||
val.pageController.jumpToPage(index);
|
||||
}
|
||||
val.scrollController.itemCount = val.tabs.length;
|
||||
if (val.scrollController.hasClients &&
|
||||
val.scrollController.canScroll &&
|
||||
val.scrollController.itemCount > index) {
|
||||
val.scrollController
|
||||
.scrollToItem(index, center: false, animate: true);
|
||||
@@ -183,7 +177,6 @@ typedef LabelGetter = Rx<String> Function(String key);
|
||||
int _lastClickTime = DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
class DesktopTab extends StatelessWidget {
|
||||
final Function(String)? onTabClose;
|
||||
final bool showTabBar;
|
||||
final bool showLogo;
|
||||
final bool showTitle;
|
||||
@@ -211,7 +204,6 @@ class DesktopTab extends StatelessWidget {
|
||||
DesktopTab({
|
||||
Key? key,
|
||||
required this.controller,
|
||||
this.onTabClose,
|
||||
this.showTabBar = true,
|
||||
this.showLogo = true,
|
||||
this.showTitle = true,
|
||||
@@ -367,7 +359,6 @@ class DesktopTab extends StatelessWidget {
|
||||
},
|
||||
child: _ListView(
|
||||
controller: controller,
|
||||
onTabClose: onTabClose,
|
||||
tabBuilder: tabBuilder,
|
||||
labelGetter: labelGetter,
|
||||
maxLabelWidth: maxLabelWidth,
|
||||
@@ -623,7 +614,6 @@ Future<bool> closeConfirmDialog() async {
|
||||
|
||||
class _ListView extends StatelessWidget {
|
||||
final DesktopTabController controller;
|
||||
final Function(String key)? onTabClose;
|
||||
|
||||
final TabBuilder? tabBuilder;
|
||||
final LabelGetter? labelGetter;
|
||||
@@ -635,7 +625,6 @@ class _ListView extends StatelessWidget {
|
||||
|
||||
const _ListView(
|
||||
{required this.controller,
|
||||
required this.onTabClose,
|
||||
this.tabBuilder,
|
||||
this.labelGetter,
|
||||
this.maxLabelWidth,
|
||||
@@ -664,7 +653,9 @@ class _ListView extends StatelessWidget {
|
||||
final index = e.key;
|
||||
final tab = e.value;
|
||||
return _Tab(
|
||||
key: ValueKey(tab.key),
|
||||
index: index,
|
||||
tabInfoKey: tab.key,
|
||||
label: labelGetter == null
|
||||
? Rx<String>(tab.label)
|
||||
: labelGetter!(tab.label),
|
||||
@@ -679,18 +670,11 @@ class _ListView extends StatelessWidget {
|
||||
controller.remove(index);
|
||||
}
|
||||
},
|
||||
onSelected: () => controller.jumpTo(index),
|
||||
tabBuilder: tabBuilder == null
|
||||
? null
|
||||
: (String key, Widget icon, Widget labelWidget,
|
||||
TabThemeConf themeConf) {
|
||||
return tabBuilder!(
|
||||
tab.label,
|
||||
icon,
|
||||
labelWidget,
|
||||
themeConf,
|
||||
);
|
||||
},
|
||||
onTap: () {
|
||||
controller.jumpTo(index);
|
||||
tab.onTap?.call();
|
||||
},
|
||||
tabBuilder: tabBuilder,
|
||||
maxLabelWidth: maxLabelWidth,
|
||||
selectedTabBackgroundColor: selectedTabBackgroundColor,
|
||||
unSelectedTabBackgroundColor: unSelectedTabBackgroundColor,
|
||||
@@ -701,13 +685,14 @@ class _ListView extends StatelessWidget {
|
||||
|
||||
class _Tab extends StatefulWidget {
|
||||
final int index;
|
||||
final String tabInfoKey;
|
||||
final Rx<String> label;
|
||||
final IconData? selectedIcon;
|
||||
final IconData? unselectedIcon;
|
||||
final bool closable;
|
||||
final int selected;
|
||||
final Function() onClose;
|
||||
final Function() onSelected;
|
||||
final Function() onTap;
|
||||
final TabBuilder? tabBuilder;
|
||||
final double? maxLabelWidth;
|
||||
final Color? selectedTabBackgroundColor;
|
||||
@@ -716,6 +701,7 @@ class _Tab extends StatefulWidget {
|
||||
const _Tab({
|
||||
Key? key,
|
||||
required this.index,
|
||||
required this.tabInfoKey,
|
||||
required this.label,
|
||||
this.selectedIcon,
|
||||
this.unselectedIcon,
|
||||
@@ -723,7 +709,7 @@ class _Tab extends StatefulWidget {
|
||||
required this.closable,
|
||||
required this.selected,
|
||||
required this.onClose,
|
||||
required this.onSelected,
|
||||
required this.onTap,
|
||||
this.maxLabelWidth,
|
||||
this.selectedTabBackgroundColor,
|
||||
this.unSelectedTabBackgroundColor,
|
||||
@@ -773,7 +759,7 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return widget.tabBuilder!(widget.label.value, icon, labelWidget,
|
||||
return widget.tabBuilder!(widget.tabInfoKey, icon, labelWidget,
|
||||
TabThemeConf(iconSize: _kIconSize));
|
||||
}
|
||||
}
|
||||
@@ -790,7 +776,7 @@ class _TabState extends State<_Tab> with RestorationMixin {
|
||||
hover.value = value;
|
||||
restoreHover.value = value;
|
||||
},
|
||||
onTap: () => widget.onSelected(),
|
||||
onTap: () => widget.onTap(),
|
||||
child: Container(
|
||||
color: isSelected
|
||||
? widget.selectedTabBackgroundColor
|
||||
|
||||
Reference in New Issue
Block a user