commit
64f5f3253c
@ -14,7 +14,7 @@ import 'package:get/get.dart';
|
|||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
import 'mobile/widgets/overlay.dart';
|
import 'common/widgets/overlay.dart';
|
||||||
import 'models/model.dart';
|
import 'models/model.dart';
|
||||||
import 'models/platform_model.dart';
|
import 'models/platform_model.dart';
|
||||||
|
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_hbb/common.dart';
|
import 'package:flutter_hbb/common.dart';
|
||||||
|
|
||||||
|
import '../../desktop/widgets/tabbar_widget.dart';
|
||||||
|
import '../../mobile/pages/chat_page.dart';
|
||||||
import '../../models/chat_model.dart';
|
import '../../models/chat_model.dart';
|
||||||
import '../pages/chat_page.dart';
|
|
||||||
|
|
||||||
class DraggableChatWindow extends StatelessWidget {
|
class DraggableChatWindow extends StatelessWidget {
|
||||||
DraggableChatWindow(
|
const DraggableChatWindow(
|
||||||
{this.position = Offset.zero,
|
{Key? key,
|
||||||
|
this.position = Offset.zero,
|
||||||
required this.width,
|
required this.width,
|
||||||
required this.height,
|
required this.height,
|
||||||
required this.chatModel});
|
required this.chatModel})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
final Offset position;
|
final Offset position;
|
||||||
final double width;
|
final double width;
|
||||||
@ -30,46 +33,84 @@ class DraggableChatWindow extends StatelessWidget {
|
|||||||
resizeToAvoidBottomInset: false,
|
resizeToAvoidBottomInset: false,
|
||||||
appBar: CustomAppBar(
|
appBar: CustomAppBar(
|
||||||
onPanUpdate: onPanUpdate,
|
onPanUpdate: onPanUpdate,
|
||||||
appBar: Container(
|
appBar: isDesktop
|
||||||
color: MyTheme.accent50,
|
? _buildDesktopAppBar()
|
||||||
height: 50,
|
: _buildMobileAppBar(),
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
|
||||||
child: Text(
|
|
||||||
translate("Chat"),
|
|
||||||
style: TextStyle(
|
|
||||||
color: Colors.white,
|
|
||||||
fontFamily: 'WorkSans',
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 20),
|
|
||||||
)),
|
|
||||||
Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
chatModel.hideChatWindowOverlay();
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.keyboard_arrow_down)),
|
|
||||||
IconButton(
|
|
||||||
onPressed: () {
|
|
||||||
chatModel.hideChatWindowOverlay();
|
|
||||||
chatModel.hideChatIconOverlay();
|
|
||||||
},
|
|
||||||
icon: Icon(Icons.close))
|
|
||||||
],
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
body: ChatPage(chatModel: chatModel),
|
body: ChatPage(chatModel: chatModel),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _buildMobileAppBar() {
|
||||||
|
return Container(
|
||||||
|
color: MyTheme.accent50,
|
||||||
|
height: 50,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
child: Text(
|
||||||
|
translate("Chat"),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontFamily: 'WorkSans',
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 20),
|
||||||
|
)),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
chatModel.hideChatWindowOverlay();
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_down)),
|
||||||
|
IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
chatModel.hideChatWindowOverlay();
|
||||||
|
chatModel.hideChatIconOverlay();
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.close))
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _buildDesktopAppBar() {
|
||||||
|
return Container(
|
||||||
|
color: MyTheme.accent50,
|
||||||
|
height: 35,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
child: Text(
|
||||||
|
translate("Chat"),
|
||||||
|
style: const TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontFamily: 'WorkSans',
|
||||||
|
fontWeight: FontWeight.bold),
|
||||||
|
)),
|
||||||
|
Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
ActionIcon(
|
||||||
|
message: 'Close',
|
||||||
|
icon: IconFont.close,
|
||||||
|
onTap: chatModel.hideChatWindowOverlay,
|
||||||
|
isClose: true,
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
@ -86,7 +127,7 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Size get preferredSize => new Size.fromHeight(kToolbarHeight);
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// floating buttons of back/home/recent actions for android
|
/// floating buttons of back/home/recent actions for android
|
||||||
@ -161,13 +202,15 @@ class DraggableMobileActions extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Draggable extends StatefulWidget {
|
class Draggable extends StatefulWidget {
|
||||||
Draggable(
|
const Draggable(
|
||||||
{this.checkKeyboard = false,
|
{Key? key,
|
||||||
|
this.checkKeyboard = false,
|
||||||
this.checkScreenSize = false,
|
this.checkScreenSize = false,
|
||||||
this.position = Offset.zero,
|
this.position = Offset.zero,
|
||||||
required this.width,
|
required this.width,
|
||||||
required this.height,
|
required this.height,
|
||||||
required this.builder});
|
required this.builder})
|
||||||
|
: super(key: key);
|
||||||
|
|
||||||
final bool checkKeyboard;
|
final bool checkKeyboard;
|
||||||
final bool checkScreenSize;
|
final bool checkScreenSize;
|
||||||
@ -224,7 +267,6 @@ class _DraggableState extends State<Draggable> {
|
|||||||
final bottomHeight = MediaQuery.of(context).viewInsets.bottom;
|
final bottomHeight = MediaQuery.of(context).viewInsets.bottom;
|
||||||
final currentVisible = bottomHeight != 0;
|
final currentVisible = bottomHeight != 0;
|
||||||
|
|
||||||
debugPrint(bottomHeight.toString() + currentVisible.toString());
|
|
||||||
// save
|
// save
|
||||||
if (!_keyboardVisible && currentVisible) {
|
if (!_keyboardVisible && currentVisible) {
|
||||||
_saveHeight = _position.dy;
|
_saveHeight = _position.dy;
|
@ -75,9 +75,7 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
|||||||
backgroundColor: MyTheme.color(context).bg,
|
backgroundColor: MyTheme.color(context).bg,
|
||||||
body: DesktopTab(
|
body: DesktopTab(
|
||||||
controller: tabController,
|
controller: tabController,
|
||||||
onWindowCloseButton: () {
|
onWindowCloseButton: handleWindowCloseButton,
|
||||||
tabController.clear();
|
|
||||||
},
|
|
||||||
tail: const AddButton().paddingOnly(left: 10),
|
tail: const AddButton().paddingOnly(left: 10),
|
||||||
)),
|
)),
|
||||||
),
|
),
|
||||||
@ -103,4 +101,21 @@ class _FileManagerTabPageState extends State<FileManagerTabPage> {
|
|||||||
tabController.closeBy(peerId);
|
tabController.closeBy(peerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> handleWindowCloseButton() async {
|
||||||
|
final connLength = tabController.state.value.tabs.length;
|
||||||
|
if (connLength < 1) {
|
||||||
|
return true;
|
||||||
|
} else if (connLength == 1) {
|
||||||
|
final currentConn = tabController.state.value.tabs[0];
|
||||||
|
handleTabCloseButton(currentConn.key);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
final res = await closeConfirmDialog();
|
||||||
|
if (res) {
|
||||||
|
tabController.clear();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,9 @@ class _PortForwardTabPageState extends State<PortForwardTabPage> {
|
|||||||
backgroundColor: MyTheme.color(context).bg,
|
backgroundColor: MyTheme.color(context).bg,
|
||||||
body: DesktopTab(
|
body: DesktopTab(
|
||||||
controller: tabController,
|
controller: tabController,
|
||||||
onWindowCloseButton: () {
|
onWindowCloseButton: () async {
|
||||||
tabController.clear();
|
tabController.clear();
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
tail: AddButton().paddingOnly(left: 10),
|
tail: AddButton().paddingOnly(left: 10),
|
||||||
)),
|
)),
|
||||||
|
@ -97,9 +97,7 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
body: DesktopTab(
|
body: DesktopTab(
|
||||||
controller: tabController,
|
controller: tabController,
|
||||||
showTabBar: fullscreen.isFalse,
|
showTabBar: fullscreen.isFalse,
|
||||||
onWindowCloseButton: () {
|
onWindowCloseButton: handleWindowCloseButton,
|
||||||
tabController.clear();
|
|
||||||
},
|
|
||||||
tail: AddButton().paddingOnly(left: 10),
|
tail: AddButton().paddingOnly(left: 10),
|
||||||
pageViewBuilder: (pageView) {
|
pageViewBuilder: (pageView) {
|
||||||
WindowController.fromWindowId(windowId())
|
WindowController.fromWindowId(windowId())
|
||||||
@ -167,4 +165,21 @@ class _ConnectionTabPageState extends State<ConnectionTabPage> {
|
|||||||
tabController.closeBy(peerId);
|
tabController.closeBy(peerId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> handleWindowCloseButton() async {
|
||||||
|
final connLength = tabController.state.value.tabs.length;
|
||||||
|
if (connLength < 1) {
|
||||||
|
return true;
|
||||||
|
} else if (connLength == 1) {
|
||||||
|
final currentConn = tabController.state.value.tabs[0];
|
||||||
|
handleTabCloseButton(currentConn.key);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
final res = await closeConfirmDialog();
|
||||||
|
if (res) {
|
||||||
|
tabController.clear();
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ class DesktopTab extends StatelessWidget {
|
|||||||
final bool showClose;
|
final bool showClose;
|
||||||
final Widget Function(Widget pageView)? pageViewBuilder;
|
final Widget Function(Widget pageView)? pageViewBuilder;
|
||||||
final Widget? tail;
|
final Widget? tail;
|
||||||
final VoidCallback? onWindowCloseButton;
|
final Future<bool> Function()? onWindowCloseButton;
|
||||||
final TabBuilder? tabBuilder;
|
final TabBuilder? tabBuilder;
|
||||||
final LabelGetter? labelGetter;
|
final LabelGetter? labelGetter;
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ class WindowActionPanel extends StatelessWidget {
|
|||||||
final bool showMinimize;
|
final bool showMinimize;
|
||||||
final bool showMaximize;
|
final bool showMaximize;
|
||||||
final bool showClose;
|
final bool showClose;
|
||||||
final VoidCallback? onClose;
|
final Future<bool> Function()? onClose;
|
||||||
|
|
||||||
const WindowActionPanel(
|
const WindowActionPanel(
|
||||||
{Key? key,
|
{Key? key,
|
||||||
@ -433,7 +433,8 @@ class WindowActionPanel extends StatelessWidget {
|
|||||||
message: 'Close',
|
message: 'Close',
|
||||||
icon: IconFont.close,
|
icon: IconFont.close,
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
action() {
|
final res = await onClose?.call() ?? true;
|
||||||
|
if (res) {
|
||||||
if (mainTab) {
|
if (mainTab) {
|
||||||
windowManager.close();
|
windowManager.close();
|
||||||
} else {
|
} else {
|
||||||
@ -442,14 +443,6 @@ class WindowActionPanel extends StatelessWidget {
|
|||||||
WindowController.fromWindowId(windowId!).hide();
|
WindowController.fromWindowId(windowId!).hide();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onClose?.call();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tabType != DesktopTabType.main &&
|
|
||||||
state.value.tabs.length > 1) {
|
|
||||||
closeConfirmDialog(action);
|
|
||||||
} else {
|
|
||||||
action();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isClose: true,
|
isClose: true,
|
||||||
@ -457,30 +450,28 @@ class WindowActionPanel extends StatelessWidget {
|
|||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
closeConfirmDialog(Function() callback) async {
|
Future<bool> closeConfirmDialog() async {
|
||||||
final res = await gFFI.dialogManager.show<bool>((setState, close) {
|
final res = await gFFI.dialogManager.show<bool>((setState, close) {
|
||||||
submit() => close(true);
|
submit() => close(true);
|
||||||
return CustomAlertDialog(
|
return CustomAlertDialog(
|
||||||
title: Row(children: [
|
title: Row(children: [
|
||||||
const Icon(Icons.warning_amber_sharp,
|
const Icon(Icons.warning_amber_sharp,
|
||||||
color: Colors.redAccent, size: 28),
|
color: Colors.redAccent, size: 28),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
Text(translate("Warning")),
|
Text(translate("Warning")),
|
||||||
]),
|
]),
|
||||||
content: Text(translate("Disconnect all devices?")),
|
content: Text(translate("Disconnect all devices?")),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(onPressed: close, child: Text(translate("Cancel"))),
|
TextButton(onPressed: close, child: Text(translate("Cancel"))),
|
||||||
ElevatedButton(onPressed: submit, child: Text(translate("OK"))),
|
ElevatedButton(onPressed: submit, child: Text(translate("OK"))),
|
||||||
],
|
],
|
||||||
onSubmit: submit,
|
onSubmit: submit,
|
||||||
onCancel: close,
|
onCancel: close,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
if (res == true) {
|
return res == true;
|
||||||
callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ignore: must_be_immutable
|
// ignore: must_be_immutable
|
||||||
|
@ -4,8 +4,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_hbb/models/platform_model.dart';
|
import 'package:flutter_hbb/models/platform_model.dart';
|
||||||
import 'package:window_manager/window_manager.dart';
|
import 'package:window_manager/window_manager.dart';
|
||||||
|
|
||||||
import '../../mobile/widgets/overlay.dart';
|
|
||||||
import '../common.dart';
|
import '../common.dart';
|
||||||
|
import '../common/widgets/overlay.dart';
|
||||||
import 'model.dart';
|
import 'model.dart';
|
||||||
|
|
||||||
class MessageBody {
|
class MessageBody {
|
||||||
@ -128,7 +128,10 @@ class ChatModel with ChangeNotifier {
|
|||||||
if (overlayState == null) return;
|
if (overlayState == null) return;
|
||||||
final overlay = OverlayEntry(builder: (context) {
|
final overlay = OverlayEntry(builder: (context) {
|
||||||
return DraggableChatWindow(
|
return DraggableChatWindow(
|
||||||
position: Offset(20, 80), width: 250, height: 350, chatModel: this);
|
position: const Offset(20, 80),
|
||||||
|
width: 250,
|
||||||
|
height: 350,
|
||||||
|
chatModel: this);
|
||||||
});
|
});
|
||||||
overlayState.insert(overlay);
|
overlayState.insert(overlay);
|
||||||
chatWindowOverlayEntry = overlay;
|
chatWindowOverlayEntry = overlay;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user