Merge pull request #1604 from Kingtous/master

opt: cm chat window alignment & home button hide/show logic
This commit is contained in:
RustDesk 2022-09-23 11:13:57 +08:00 committed by GitHub
commit e789b2c3a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 31 deletions

View File

@ -490,6 +490,15 @@ class _ListView extends StatelessWidget {
this.tabBuilder, this.tabBuilder,
this.labelGetter}); this.labelGetter});
/// Check whether to show ListView
///
/// Conditions:
/// - hide single item when only has one item (home) on [DesktopTabPage].
bool isHideSingleItem() {
return state.value.tabs.length == 1 &&
controller.tabType == DesktopTabType.main;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Obx(() => ListView( return Obx(() => ListView(
@ -497,7 +506,9 @@ class _ListView extends StatelessWidget {
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
shrinkWrap: true, shrinkWrap: true,
physics: const BouncingScrollPhysics(), physics: const BouncingScrollPhysics(),
children: state.value.tabs.asMap().entries.map((e) { children: isHideSingleItem()
? List.empty()
: state.value.tabs.asMap().entries.map((e) {
final index = e.key; final index = e.key;
final tab = e.value; final tab = e.value;
return _Tab( return _Tab(
@ -519,7 +530,8 @@ class _ListView extends StatelessWidget {
onSelected: () => controller.jumpTo(index), onSelected: () => controller.jumpTo(index),
tabBuilder: tabBuilder == null tabBuilder: tabBuilder == null
? null ? null
: (Widget icon, Widget labelWidget, TabThemeConf themeConf) { : (Widget icon, Widget labelWidget,
TabThemeConf themeConf) {
return tabBuilder!( return tabBuilder!(
tab.label, tab.label,
icon, icon,

View File

@ -167,8 +167,10 @@ class ChatModel with ChangeNotifier {
_isShowChatPage = !_isShowChatPage; _isShowChatPage = !_isShowChatPage;
notifyListeners(); notifyListeners();
await windowManager.setSize(Size(400, 600)); await windowManager.setSize(Size(400, 600));
await windowManager.setAlignment(Alignment.topRight);
} else { } else {
await windowManager.setSize(Size(800, 600)); await windowManager.setSize(Size(800, 600));
await windowManager.center();
await Future.delayed(Duration(milliseconds: 100)); await Future.delayed(Duration(milliseconds: 100));
_isShowChatPage = !_isShowChatPage; _isShowChatPage = !_isShowChatPage;
notifyListeners(); notifyListeners();