diff --git a/flutter/lib/desktop/pages/connection_page.dart b/flutter/lib/desktop/pages/connection_page.dart index 261b23f53..0b17c5f47 100644 --- a/flutter/lib/desktop/pages/connection_page.dart +++ b/flutter/lib/desktop/pages/connection_page.dart @@ -14,6 +14,7 @@ import '../../common/formatter/id_formatter.dart'; import '../../common/widgets/peer_tab_page.dart'; import '../../common/widgets/peers_view.dart'; import '../../models/platform_model.dart'; +import '../widgets/button.dart'; /// Connection page for connecting to a remote peer. class ConnectionPage extends StatefulWidget { @@ -109,10 +110,6 @@ class _ConnectionPageState extends State { /// UI for the remote ID TextField. /// Search for a peer and connect to it if the id exists. Widget _buildRemoteIDTextField(BuildContext context) { - RxBool ftHover = false.obs; - RxBool ftPressed = false.obs; - RxBool connHover = false.obs; - RxBool connPressed = false.obs; RxBool inputFocused = false.obs; FocusNode focusNode = FocusNode(); focusNode.addListener(() { @@ -189,84 +186,17 @@ class _ConnectionPageState extends State { child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Obx(() => InkWell( - onTapDown: (_) => ftPressed.value = true, - onTapUp: (_) => ftPressed.value = false, - onTapCancel: () => ftPressed.value = false, - onHover: (value) => ftHover.value = value, - onTap: () { - onConnect(isFileTransfer: true); - }, - child: Container( - height: 27, - alignment: Alignment.center, - decoration: BoxDecoration( - color: ftPressed.value - ? MyTheme.accent - : Colors.transparent, - border: Border.all( - color: ftPressed.value - ? MyTheme.accent - : ftHover.value - ? MyTheme.hoverBorder - : MyTheme.border, - ), - borderRadius: BorderRadius.circular(5), - ), - child: Text( - translate( - "Transfer File", - ), - style: TextStyle( - fontSize: 12, - color: ftPressed.value - ? MyTheme.color(context).bg - : MyTheme.color(context).text), - ).marginSymmetric(horizontal: 12), - ), - )), + Button( + isOutline: true, + onTap: () { + onConnect(isFileTransfer: true); + }, + text: "Transfer File", + ), const SizedBox( width: 17, ), - Obx( - () => InkWell( - onTapDown: (_) => connPressed.value = true, - onTapUp: (_) => connPressed.value = false, - onTapCancel: () => connPressed.value = false, - onHover: (value) => connHover.value = value, - onTap: onConnect, - child: ConstrainedBox( - constraints: BoxConstraints( - minWidth: 80.0, - ), - child: Container( - height: 27, - decoration: BoxDecoration( - color: connPressed.value - ? MyTheme.accent - : MyTheme.button, - border: Border.all( - color: connPressed.value - ? MyTheme.accent - : connHover.value - ? MyTheme.hoverBorder - : MyTheme.button, - ), - borderRadius: BorderRadius.circular(5), - ), - child: Center( - child: Text( - translate( - "Connect", - ), - style: TextStyle( - fontSize: 12, - color: MyTheme.color(context).bg), - ), - ).marginSymmetric(horizontal: 12), - )), - ), - ), + Button(onTap: onConnect, text: "Connect"), ], ), ) diff --git a/flutter/lib/desktop/pages/desktop_home_page.dart b/flutter/lib/desktop/pages/desktop_home_page.dart index 833a914cd..e39e4f372 100644 --- a/flutter/lib/desktop/pages/desktop_home_page.dart +++ b/flutter/lib/desktop/pages/desktop_home_page.dart @@ -26,6 +26,7 @@ class _DesktopHomePageState extends State with TrayListener, WindowListener, AutomaticKeepAliveClientMixin { @override bool get wantKeepAlive => true; + var updateUrl = ''; @override void onWindowClose() async { @@ -74,6 +75,7 @@ class _DesktopHomePageState extends State buildTip(context), buildIDBoard(context), buildPasswordBoard(context), + buildHelpCards(), ], ), ), @@ -288,6 +290,46 @@ class _DesktopHomePageState extends State ); } + Widget buildHelpCards() { + if (Platform.isWindows) { + if (!bind.mainIsInstalled()) { + return buildInstallCard(); + } else if (bind.mainIsInstalledLowerVersion()) { + return buildUpgradeCard(); + } + } + if (updateUrl.isNotEmpty) { + return buildUpdateCard(); + } + if (Platform.isMacOS) {} + if (bind.mainIsInstalledLowerVersion()) {} + return Container(); + } + + Widget buildUpdateCard() { + return Container(); + } + + Widget buildUpgradeCard() { + return Container(); + } + + Widget buildInstallCard() { + return Container( + margin: EdgeInsets.only(top: 20), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + translate("install_tip"), + style: TextStyle(fontWeight: FontWeight.normal, fontSize: 19), + ), + ], + ), + ); + } + @override void onTrayMenuItemClick(MenuItem menuItem) { debugPrint('click ${menuItem.key}'); @@ -305,6 +347,10 @@ class _DesktopHomePageState extends State @override void initState() { super.initState(); + Timer(const Duration(seconds: 5), () async { + updateUrl = await bind.mainGetSoftwareUpdateUrl(); + if (updateUrl.isNotEmpty) setState(() {}); + }); trayManager.addListener(this); windowManager.addListener(this); rustDeskWinManager.setMethodHandler((call, fromWindowId) async { diff --git a/flutter/lib/desktop/widgets/button.dart b/flutter/lib/desktop/widgets/button.dart new file mode 100644 index 000000000..dc0cc6a2c --- /dev/null +++ b/flutter/lib/desktop/widgets/button.dart @@ -0,0 +1,73 @@ +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; + +import '../../common.dart'; + +class Button extends StatefulWidget { + GestureTapCallback onTap; + String text; + double? minWidth; + bool isOutline; + + Button({ + Key? key, + this.minWidth, + this.isOutline = false, + required this.onTap, + required this.text, + }) : super(key: key); + + @override + State