2022-07-29 16:47:24 +08:00
|
|
|
import 'package:contextmenu/contextmenu.dart';
|
2022-07-27 22:56:28 +08:00
|
|
|
import 'package:flutter/material.dart';
|
2022-08-26 11:35:28 +08:00
|
|
|
import 'package:flutter/services.dart';
|
2022-07-27 22:56:28 +08:00
|
|
|
import 'package:flutter_hbb/utils/multi_window_manager.dart';
|
|
|
|
import 'package:get/get.dart';
|
|
|
|
|
|
|
|
import '../../common.dart';
|
|
|
|
import '../../models/model.dart';
|
|
|
|
import '../../models/peer_model.dart';
|
2022-08-23 17:21:50 +08:00
|
|
|
import '../../models/platform_model.dart';
|
2022-09-01 18:56:12 +08:00
|
|
|
import './material_mod_popup_menu.dart' as mod_menu;
|
|
|
|
import './popup_menu.dart';
|
|
|
|
|
|
|
|
class _PopupMenuTheme {
|
|
|
|
static const Color commonColor = MyTheme.accent;
|
|
|
|
// kMinInteractiveDimension
|
|
|
|
static const double height = 25.0;
|
|
|
|
static const double dividerHeight = 12.0;
|
|
|
|
}
|
2022-07-27 22:56:28 +08:00
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
typedef PopupMenuEntryBuilder = Future<List<mod_menu.PopupMenuEntry<String>>>
|
|
|
|
Function(BuildContext);
|
2022-07-28 14:06:02 +08:00
|
|
|
|
2022-08-23 17:21:50 +08:00
|
|
|
enum PeerUiType { grid, list }
|
|
|
|
|
|
|
|
final peerCardUiType = PeerUiType.grid.obs;
|
|
|
|
|
2022-07-27 22:56:28 +08:00
|
|
|
class _PeerCard extends StatefulWidget {
|
|
|
|
final Peer peer;
|
2022-09-01 18:56:12 +08:00
|
|
|
final RxString alias;
|
|
|
|
final Function(BuildContext, String) connect;
|
|
|
|
final PopupMenuEntryBuilder popupMenuEntryBuilder;
|
2022-07-27 22:56:28 +08:00
|
|
|
|
2022-08-03 22:03:31 +08:00
|
|
|
_PeerCard(
|
|
|
|
{required this.peer,
|
2022-09-01 18:56:12 +08:00
|
|
|
required this.alias,
|
|
|
|
required this.connect,
|
|
|
|
required this.popupMenuEntryBuilder,
|
|
|
|
Key? key})
|
2022-07-27 22:56:28 +08:00
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_PeerCardState createState() => _PeerCardState();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// State for the connection page.
|
2022-07-29 16:47:24 +08:00
|
|
|
class _PeerCardState extends State<_PeerCard>
|
|
|
|
with AutomaticKeepAliveClientMixin {
|
2022-08-24 11:01:58 +08:00
|
|
|
final double _cardRadis = 20;
|
|
|
|
final double _borderWidth = 2;
|
2022-08-26 13:02:15 +08:00
|
|
|
final RxBool _iconMoreHover = false.obs;
|
2022-07-27 22:56:28 +08:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-07-29 16:47:24 +08:00
|
|
|
super.build(context);
|
2022-07-27 22:56:28 +08:00
|
|
|
final peer = super.widget.peer;
|
|
|
|
var deco = Rx<BoxDecoration?>(BoxDecoration(
|
2022-08-24 11:01:58 +08:00
|
|
|
border: Border.all(color: Colors.transparent, width: _borderWidth),
|
2022-08-23 17:21:50 +08:00
|
|
|
borderRadius: peerCardUiType.value == PeerUiType.grid
|
2022-08-24 11:01:58 +08:00
|
|
|
? BorderRadius.circular(_cardRadis)
|
2022-08-23 17:21:50 +08:00
|
|
|
: null));
|
|
|
|
return MouseRegion(
|
|
|
|
onEnter: (evt) {
|
|
|
|
deco.value = BoxDecoration(
|
2022-08-24 11:01:58 +08:00
|
|
|
border: Border.all(color: MyTheme.button, width: _borderWidth),
|
2022-08-23 17:21:50 +08:00
|
|
|
borderRadius: peerCardUiType.value == PeerUiType.grid
|
2022-08-24 11:01:58 +08:00
|
|
|
? BorderRadius.circular(_cardRadis)
|
2022-08-23 17:21:50 +08:00
|
|
|
: null);
|
|
|
|
},
|
|
|
|
onExit: (evt) {
|
|
|
|
deco.value = BoxDecoration(
|
2022-08-24 11:01:58 +08:00
|
|
|
border: Border.all(color: Colors.transparent, width: _borderWidth),
|
2022-08-23 17:21:50 +08:00
|
|
|
borderRadius: peerCardUiType.value == PeerUiType.grid
|
2022-08-24 11:01:58 +08:00
|
|
|
? BorderRadius.circular(_cardRadis)
|
2022-08-23 17:21:50 +08:00
|
|
|
: null);
|
|
|
|
},
|
|
|
|
child: GestureDetector(
|
2022-09-01 18:56:12 +08:00
|
|
|
onDoubleTap: () => widget.connect(context, peer.id),
|
2022-08-23 17:21:50 +08:00
|
|
|
child: Obx(() => peerCardUiType.value == PeerUiType.grid
|
|
|
|
? _buildPeerCard(context, peer, deco)
|
|
|
|
: _buildPeerTile(context, peer, deco))),
|
|
|
|
);
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
|
|
|
|
2022-08-03 22:03:31 +08:00
|
|
|
Widget _buildPeerTile(
|
|
|
|
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
2022-08-24 11:01:58 +08:00
|
|
|
final greyStyle =
|
|
|
|
TextStyle(fontSize: 12, color: MyTheme.color(context).lighterText);
|
2022-07-27 22:56:28 +08:00
|
|
|
return Obx(
|
2022-08-03 22:03:31 +08:00
|
|
|
() => Container(
|
2022-08-24 11:01:58 +08:00
|
|
|
foregroundDecoration: deco.value,
|
2022-08-23 17:21:50 +08:00
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.max,
|
2022-07-27 22:56:28 +08:00
|
|
|
children: [
|
2022-08-23 17:21:50 +08:00
|
|
|
Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: str2color('${peer.id}${peer.platform}', 0x7f),
|
|
|
|
),
|
|
|
|
alignment: Alignment.center,
|
2022-08-24 11:01:58 +08:00
|
|
|
child: _getPlatformImage('${peer.platform}', 30).paddingAll(6),
|
2022-08-23 17:21:50 +08:00
|
|
|
),
|
2022-07-27 22:56:28 +08:00
|
|
|
Expanded(
|
|
|
|
child: Container(
|
2022-08-24 11:01:58 +08:00
|
|
|
decoration: BoxDecoration(color: MyTheme.color(context).bg),
|
2022-07-27 22:56:28 +08:00
|
|
|
child: Row(
|
2022-08-23 17:21:50 +08:00
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
2022-07-27 22:56:28 +08:00
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
2022-08-23 17:21:50 +08:00
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
2022-07-27 22:56:28 +08:00
|
|
|
children: [
|
2022-08-23 17:21:50 +08:00
|
|
|
Row(children: [
|
|
|
|
Padding(
|
2022-08-24 11:01:58 +08:00
|
|
|
padding: EdgeInsets.fromLTRB(0, 4, 4, 4),
|
2022-08-23 17:21:50 +08:00
|
|
|
child: CircleAvatar(
|
|
|
|
radius: 5,
|
|
|
|
backgroundColor: peer.online
|
|
|
|
? Colors.green
|
|
|
|
: Colors.yellow)),
|
2022-08-24 11:01:58 +08:00
|
|
|
Text(
|
|
|
|
'${peer.id}',
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w400),
|
|
|
|
),
|
2022-08-23 17:21:50 +08:00
|
|
|
]),
|
|
|
|
Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: FutureBuilder<String>(
|
|
|
|
future: bind.mainGetPeerOption(
|
|
|
|
id: peer.id, key: 'alias'),
|
|
|
|
builder: (_, snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
final name = snapshot.data!.isEmpty
|
|
|
|
? '${peer.username}@${peer.hostname}'
|
|
|
|
: snapshot.data!;
|
|
|
|
return Tooltip(
|
|
|
|
message: name,
|
2022-08-24 11:01:58 +08:00
|
|
|
waitDuration: Duration(seconds: 1),
|
2022-08-23 17:21:50 +08:00
|
|
|
child: Text(
|
|
|
|
name,
|
|
|
|
style: greyStyle,
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
// alias has not arrived
|
|
|
|
return Text(
|
|
|
|
'${peer.username}@${peer.hostname}',
|
|
|
|
style: greyStyle,
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2022-07-27 22:56:28 +08:00
|
|
|
),
|
|
|
|
],
|
2022-08-23 17:21:50 +08:00
|
|
|
),
|
2022-07-27 22:56:28 +08:00
|
|
|
),
|
2022-08-26 13:02:15 +08:00
|
|
|
_actionMore(peer),
|
2022-07-27 22:56:28 +08:00
|
|
|
],
|
2022-08-24 11:01:58 +08:00
|
|
|
).paddingSymmetric(horizontal: 4.0),
|
2022-07-27 22:56:28 +08:00
|
|
|
),
|
2022-08-23 17:21:50 +08:00
|
|
|
)
|
2022-07-27 22:56:28 +08:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-08-23 17:21:50 +08:00
|
|
|
Widget _buildPeerCard(
|
|
|
|
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
|
|
|
return Card(
|
2022-08-24 11:01:58 +08:00
|
|
|
color: Colors.transparent,
|
|
|
|
elevation: 0,
|
|
|
|
margin: EdgeInsets.zero,
|
2022-08-24 14:57:41 +08:00
|
|
|
child: Obx(
|
|
|
|
() => Container(
|
2022-08-24 11:01:58 +08:00
|
|
|
foregroundDecoration: deco.value,
|
|
|
|
child: ClipRRect(
|
|
|
|
borderRadius: BorderRadius.circular(_cardRadis - _borderWidth),
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Container(
|
2022-08-24 14:57:41 +08:00
|
|
|
color: str2color('${peer.id}${peer.platform}', 0x7f),
|
2022-08-24 11:01:58 +08:00
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: const EdgeInsets.all(6),
|
2022-09-01 18:56:12 +08:00
|
|
|
child: _getPlatformImage(peer.platform, 60),
|
2022-08-24 11:01:58 +08:00
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
Expanded(
|
2022-09-01 18:56:12 +08:00
|
|
|
child: Obx(() {
|
|
|
|
final name = widget.alias.value.isEmpty
|
|
|
|
? '${peer.username}@${peer.hostname}'
|
|
|
|
: widget.alias.value;
|
|
|
|
return Tooltip(
|
|
|
|
message: name,
|
|
|
|
waitDuration: Duration(seconds: 1),
|
|
|
|
child: Text(
|
|
|
|
name,
|
|
|
|
style: TextStyle(
|
|
|
|
color: Colors.white70,
|
|
|
|
fontSize: 12),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}),
|
2022-08-24 14:57:41 +08:00
|
|
|
),
|
2022-08-24 11:01:58 +08:00
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
).paddingAll(4.0),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
2022-08-24 14:57:41 +08:00
|
|
|
),
|
|
|
|
),
|
2022-08-24 11:01:58 +08:00
|
|
|
Container(
|
|
|
|
color: MyTheme.color(context).bg,
|
|
|
|
child: Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
|
children: [
|
|
|
|
Row(children: [
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.fromLTRB(0, 4, 8, 4),
|
|
|
|
child: CircleAvatar(
|
|
|
|
radius: 5,
|
|
|
|
backgroundColor: peer.online
|
|
|
|
? Colors.green
|
|
|
|
: Colors.yellow)),
|
2022-09-01 18:56:12 +08:00
|
|
|
Text(peer.id)
|
2022-08-26 13:02:15 +08:00
|
|
|
]).paddingSymmetric(vertical: 8),
|
|
|
|
_actionMore(peer),
|
2022-08-24 11:01:58 +08:00
|
|
|
],
|
2022-08-26 13:02:15 +08:00
|
|
|
).paddingSymmetric(horizontal: 12.0),
|
2022-08-24 11:01:58 +08:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
2022-08-24 14:57:41 +08:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-08-23 17:21:50 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
Widget _actionMore(Peer peer) {
|
|
|
|
return FutureBuilder(
|
|
|
|
future: widget.popupMenuEntryBuilder(context),
|
|
|
|
initialData: const <mod_menu.PopupMenuEntry<String>>[],
|
|
|
|
builder: (BuildContext context,
|
|
|
|
AsyncSnapshot<List<mod_menu.PopupMenuEntry<String>>> snapshot) {
|
|
|
|
if (snapshot.hasData) {
|
|
|
|
return Listener(
|
|
|
|
child: MouseRegion(
|
|
|
|
onEnter: (_) => _iconMoreHover.value = true,
|
|
|
|
onExit: (_) => _iconMoreHover.value = false,
|
|
|
|
child: CircleAvatar(
|
|
|
|
radius: 14,
|
|
|
|
backgroundColor: _iconMoreHover.value
|
|
|
|
? MyTheme.color(context).grayBg!
|
|
|
|
: MyTheme.color(context).bg!,
|
|
|
|
child: mod_menu.PopupMenuButton(
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
icon: Icon(Icons.more_vert,
|
|
|
|
size: 18,
|
|
|
|
color: _iconMoreHover.value
|
|
|
|
? MyTheme.color(context).text
|
|
|
|
: MyTheme.color(context).lightText),
|
|
|
|
position: mod_menu.PopupMenuPosition.under,
|
|
|
|
itemBuilder: (BuildContext context) => snapshot.data!,
|
|
|
|
))));
|
|
|
|
} else {
|
|
|
|
return Container();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Get the image for the current [platform].
|
|
|
|
Widget _getPlatformImage(String platform, double size) {
|
|
|
|
platform = platform.toLowerCase();
|
|
|
|
if (platform == 'mac os') {
|
|
|
|
platform = 'mac';
|
|
|
|
} else if (platform != 'linux' && platform != 'android') {
|
|
|
|
platform = 'win';
|
|
|
|
}
|
|
|
|
return Image.asset('assets/$platform.png', height: size, width: size);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool get wantKeepAlive => true;
|
|
|
|
}
|
|
|
|
|
|
|
|
abstract class BasePeerCard extends StatelessWidget {
|
|
|
|
final RxString alias = ''.obs;
|
|
|
|
final Peer peer;
|
|
|
|
|
|
|
|
BasePeerCard({required this.peer, Key? key}) : super(key: key) {
|
|
|
|
bind
|
|
|
|
.mainGetPeerOption(id: peer.id, key: 'alias')
|
|
|
|
.then((value) => alias.value = value);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return _PeerCard(
|
|
|
|
peer: peer,
|
|
|
|
alias: alias,
|
|
|
|
connect: (BuildContext context, String id) => _connect(context, id),
|
|
|
|
popupMenuEntryBuilder: _buildPopupMenuEntry,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Future<List<mod_menu.PopupMenuEntry<String>>> _buildPopupMenuEntry(
|
|
|
|
BuildContext context) async =>
|
|
|
|
(await _buildMenuItems(context))
|
|
|
|
.map((e) => e.build(
|
|
|
|
context,
|
|
|
|
const MenuConfig(
|
|
|
|
commonColor: _PopupMenuTheme.commonColor,
|
|
|
|
height: _PopupMenuTheme.height,
|
|
|
|
dividerHeight: _PopupMenuTheme.dividerHeight)))
|
|
|
|
.expand((i) => i)
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
@protected
|
|
|
|
Future<List<MenuEntryBase<String>>> _buildMenuItems(BuildContext context);
|
2022-08-26 13:02:15 +08:00
|
|
|
|
2022-07-27 22:56:28 +08:00
|
|
|
/// Connect to a peer with [id].
|
|
|
|
/// If [isFileTransfer], starts a session only for file transfer.
|
2022-08-26 11:35:28 +08:00
|
|
|
/// If [isTcpTunneling], starts a session only for tcp tunneling.
|
|
|
|
/// If [isRDP], starts a session only for rdp.
|
2022-09-01 18:56:12 +08:00
|
|
|
void _connect(BuildContext context, String id,
|
2022-08-26 11:35:28 +08:00
|
|
|
{bool isFileTransfer = false,
|
|
|
|
bool isTcpTunneling = false,
|
|
|
|
bool isRDP = false}) async {
|
2022-07-27 22:56:28 +08:00
|
|
|
if (id == '') return;
|
|
|
|
id = id.replaceAll(' ', '');
|
2022-08-26 11:35:28 +08:00
|
|
|
assert(!(isFileTransfer && isTcpTunneling && isRDP),
|
|
|
|
"more than one connect type");
|
2022-07-27 22:56:28 +08:00
|
|
|
if (isFileTransfer) {
|
|
|
|
await rustDeskWinManager.new_file_transfer(id);
|
2022-08-26 11:35:28 +08:00
|
|
|
} else if (isTcpTunneling || isRDP) {
|
|
|
|
await rustDeskWinManager.new_port_forward(id, isRDP);
|
2022-07-27 22:56:28 +08:00
|
|
|
} else {
|
|
|
|
await rustDeskWinManager.new_remote_desktop(id);
|
|
|
|
}
|
|
|
|
FocusScopeNode currentFocus = FocusScope.of(context);
|
|
|
|
if (!currentFocus.hasPrimaryFocus) {
|
|
|
|
currentFocus.unfocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
MenuEntryBase<String> _connectCommonAction(
|
|
|
|
BuildContext context, String id, String title,
|
|
|
|
{bool isFileTransfer = false,
|
|
|
|
bool isTcpTunneling = false,
|
|
|
|
bool isRDP = false}) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate(title),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
_connect(
|
|
|
|
context,
|
|
|
|
peer.id,
|
|
|
|
isFileTransfer: isFileTransfer,
|
|
|
|
isTcpTunneling: isTcpTunneling,
|
|
|
|
isRDP: isRDP,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
2022-07-27 22:56:28 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _connectAction(BuildContext context, String id) {
|
|
|
|
return _connectCommonAction(context, id, 'Connect');
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _transferFileAction(BuildContext context, String id) {
|
|
|
|
return _connectCommonAction(
|
|
|
|
context,
|
|
|
|
id,
|
|
|
|
'Transfer File',
|
|
|
|
isFileTransfer: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _tcpTunnelingAction(BuildContext context, String id) {
|
|
|
|
return _connectCommonAction(
|
|
|
|
context,
|
|
|
|
id,
|
|
|
|
'TCP Tunneling',
|
|
|
|
isTcpTunneling: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _rdpAction(BuildContext context, String id) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Row(
|
|
|
|
children: [
|
|
|
|
Text(
|
|
|
|
translate('RDP'),
|
|
|
|
style: style,
|
2022-07-27 22:56:28 +08:00
|
|
|
),
|
2022-09-01 18:56:12 +08:00
|
|
|
SizedBox(width: 20),
|
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.edit),
|
|
|
|
onPressed: () => _rdpDialog(id),
|
|
|
|
)
|
|
|
|
],
|
2022-07-27 22:56:28 +08:00
|
|
|
),
|
2022-09-01 18:56:12 +08:00
|
|
|
proc: () {
|
|
|
|
_connect(context, id, isRDP: true);
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
2022-07-27 22:56:28 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
@protected
|
|
|
|
Future<MenuEntryBase<String>> _forceAlwaysRelayAction(String id) async {
|
|
|
|
const option = 'force-always-relay';
|
|
|
|
return MenuEntrySwitch<String>(
|
|
|
|
text: translate('Always connect via relay'),
|
|
|
|
getter: () async {
|
|
|
|
return (await bind.mainGetPeerOption(id: id, key: option)).isNotEmpty;
|
|
|
|
},
|
|
|
|
setter: (bool v) async {
|
|
|
|
String value;
|
|
|
|
String oldValue = await bind.mainGetPeerOption(id: id, key: option);
|
|
|
|
if (oldValue.isEmpty) {
|
|
|
|
value = 'Y';
|
|
|
|
} else {
|
|
|
|
value = '';
|
|
|
|
}
|
|
|
|
await bind.mainSetPeerOption(id: id, key: option, value: value);
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _renameAction(String id, bool isAddressBook) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate('Rename'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
_rename(id, isAddressBook);
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
2022-07-27 22:56:28 +08:00
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _removeAction(String id) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate('Remove'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
() async {
|
|
|
|
await bind.mainRemovePeer(id: id);
|
|
|
|
removePreference(id);
|
|
|
|
Get.forceAppUpdate(); // TODO use inner model / state
|
|
|
|
}();
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
2022-07-27 22:56:28 +08:00
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _unrememberPasswordAction(String id) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate('Unremember Password'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
bind.mainForgetPassword(id: id);
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
2022-07-29 12:03:24 +08:00
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _addFavAction(String id) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate('Add to Favorites'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
() async {
|
|
|
|
final favs = (await bind.mainGetFav()).toList();
|
|
|
|
if (!favs.contains(id)) {
|
|
|
|
favs.add(id);
|
|
|
|
bind.mainStoreFav(favs: favs);
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _rmFavAction(String id) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate('Remove from Favorites'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
() async {
|
|
|
|
final favs = (await bind.mainGetFav()).toList();
|
|
|
|
if (favs.remove(id)) {
|
|
|
|
bind.mainStoreFav(favs: favs);
|
|
|
|
Get.forceAppUpdate(); // TODO use inner model / state
|
|
|
|
}
|
|
|
|
}();
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _rename(String id, bool isAddressBook) async {
|
|
|
|
RxBool isInProgress = false.obs;
|
2022-08-08 17:53:51 +08:00
|
|
|
var name = await bind.mainGetPeerOption(id: id, key: 'alias');
|
2022-08-28 21:43:18 +08:00
|
|
|
var controller = TextEditingController(text: name);
|
2022-09-01 18:56:12 +08:00
|
|
|
if (isAddressBook) {
|
2022-07-29 12:03:24 +08:00
|
|
|
final peer = gFFI.abModel.peers.firstWhere((p) => id == p['id']);
|
|
|
|
if (peer == null) {
|
|
|
|
// this should not happen
|
|
|
|
} else {
|
2022-09-01 18:56:12 +08:00
|
|
|
name = peer['alias'] ?? '';
|
2022-07-29 12:03:24 +08:00
|
|
|
}
|
|
|
|
}
|
2022-08-12 18:42:02 +08:00
|
|
|
gFFI.dialogManager.show((setState, close) {
|
2022-07-29 12:03:24 +08:00
|
|
|
return CustomAlertDialog(
|
2022-09-01 18:56:12 +08:00
|
|
|
title: Text(translate('Rename')),
|
2022-07-29 12:03:24 +08:00
|
|
|
content: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
|
|
|
child: Form(
|
|
|
|
child: TextFormField(
|
2022-08-28 21:43:18 +08:00
|
|
|
controller: controller,
|
2022-07-29 12:03:24 +08:00
|
|
|
decoration: InputDecoration(border: OutlineInputBorder()),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2022-09-01 18:56:12 +08:00
|
|
|
Obx(() => Offstage(
|
|
|
|
offstage: isInProgress.isFalse,
|
|
|
|
child: LinearProgressIndicator())),
|
2022-07-29 12:03:24 +08:00
|
|
|
],
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
close();
|
|
|
|
},
|
|
|
|
child: Text(translate("Cancel"))),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () async {
|
2022-09-01 18:56:12 +08:00
|
|
|
isInProgress.value = true;
|
2022-08-28 21:43:18 +08:00
|
|
|
name = controller.text;
|
|
|
|
await bind.mainSetPeerOption(id: id, key: 'alias', value: name);
|
2022-09-01 18:56:12 +08:00
|
|
|
if (isAddressBook) {
|
2022-08-28 21:43:18 +08:00
|
|
|
gFFI.abModel.setPeerOption(id, 'alias', name);
|
|
|
|
await gFFI.abModel.updateAb();
|
2022-07-29 12:03:24 +08:00
|
|
|
}
|
2022-09-01 18:56:12 +08:00
|
|
|
alias.value =
|
|
|
|
await bind.mainGetPeerOption(id: peer.id, key: 'alias');
|
2022-08-28 21:43:18 +08:00
|
|
|
close();
|
2022-09-01 18:56:12 +08:00
|
|
|
isInProgress.value = false;
|
2022-07-29 12:03:24 +08:00
|
|
|
},
|
|
|
|
child: Text(translate("OK"))),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
|
|
|
|
2022-09-01 18:56:12 +08:00
|
|
|
class RecentPeerCard extends BasePeerCard {
|
|
|
|
RecentPeerCard({required Peer peer, Key? key}) : super(peer: peer, key: key);
|
2022-07-27 22:56:28 +08:00
|
|
|
|
|
|
|
@override
|
2022-09-01 18:56:12 +08:00
|
|
|
Future<List<MenuEntryBase<String>>> _buildMenuItems(
|
|
|
|
BuildContext context) async {
|
|
|
|
final List<MenuEntryBase<String>> menuItems = [
|
|
|
|
_connectAction(context, peer.id),
|
|
|
|
_transferFileAction(context, peer.id),
|
|
|
|
_tcpTunnelingAction(context, peer.id),
|
2022-07-27 22:56:28 +08:00
|
|
|
];
|
2022-08-26 11:35:28 +08:00
|
|
|
if (peer.platform == 'Windows') {
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(_rdpAction(context, peer.id));
|
2022-08-26 11:35:28 +08:00
|
|
|
}
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(await _forceAlwaysRelayAction(peer.id));
|
|
|
|
menuItems.add(_renameAction(peer.id, false));
|
|
|
|
menuItems.add(_removeAction(peer.id));
|
|
|
|
menuItems.add(_unrememberPasswordAction(peer.id));
|
|
|
|
menuItems.add(_addFavAction(peer.id));
|
|
|
|
return menuItems;
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class FavoritePeerCard extends BasePeerCard {
|
|
|
|
FavoritePeerCard({required Peer peer, Key? key})
|
2022-09-01 18:56:12 +08:00
|
|
|
: super(peer: peer, key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<MenuEntryBase<String>>> _buildMenuItems(
|
|
|
|
BuildContext context) async {
|
|
|
|
final List<MenuEntryBase<String>> menuItems = [
|
|
|
|
_connectAction(context, peer.id),
|
|
|
|
_transferFileAction(context, peer.id),
|
|
|
|
_tcpTunnelingAction(context, peer.id),
|
2022-07-27 22:56:28 +08:00
|
|
|
];
|
2022-08-26 11:35:28 +08:00
|
|
|
if (peer.platform == 'Windows') {
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(_rdpAction(context, peer.id));
|
2022-08-26 11:35:28 +08:00
|
|
|
}
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(await _forceAlwaysRelayAction(peer.id));
|
|
|
|
menuItems.add(_renameAction(peer.id, false));
|
|
|
|
menuItems.add(_removeAction(peer.id));
|
|
|
|
menuItems.add(_unrememberPasswordAction(peer.id));
|
|
|
|
menuItems.add(_rmFavAction(peer.id));
|
|
|
|
return menuItems;
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class DiscoveredPeerCard extends BasePeerCard {
|
|
|
|
DiscoveredPeerCard({required Peer peer, Key? key})
|
2022-09-01 18:56:12 +08:00
|
|
|
: super(peer: peer, key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<MenuEntryBase<String>>> _buildMenuItems(
|
|
|
|
BuildContext context) async {
|
|
|
|
final List<MenuEntryBase<String>> menuItems = [
|
|
|
|
_connectAction(context, peer.id),
|
|
|
|
_transferFileAction(context, peer.id),
|
|
|
|
_tcpTunnelingAction(context, peer.id),
|
2022-07-27 22:56:28 +08:00
|
|
|
];
|
2022-08-26 11:35:28 +08:00
|
|
|
if (peer.platform == 'Windows') {
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(_rdpAction(context, peer.id));
|
2022-08-26 11:35:28 +08:00
|
|
|
}
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(await _forceAlwaysRelayAction(peer.id));
|
|
|
|
menuItems.add(_renameAction(peer.id, false));
|
|
|
|
menuItems.add(_removeAction(peer.id));
|
|
|
|
menuItems.add(_unrememberPasswordAction(peer.id));
|
|
|
|
menuItems.add(_addFavAction(peer.id));
|
|
|
|
return menuItems;
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class AddressBookPeerCard extends BasePeerCard {
|
|
|
|
AddressBookPeerCard({required Peer peer, Key? key})
|
2022-09-01 18:56:12 +08:00
|
|
|
: super(peer: peer, key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Future<List<MenuEntryBase<String>>> _buildMenuItems(
|
|
|
|
BuildContext context) async {
|
|
|
|
final List<MenuEntryBase<String>> menuItems = [
|
|
|
|
_connectAction(context, peer.id),
|
|
|
|
_transferFileAction(context, peer.id),
|
|
|
|
_tcpTunnelingAction(context, peer.id),
|
2022-07-27 22:56:28 +08:00
|
|
|
];
|
2022-08-26 11:35:28 +08:00
|
|
|
if (peer.platform == 'Windows') {
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(_rdpAction(context, peer.id));
|
2022-08-26 11:35:28 +08:00
|
|
|
}
|
2022-09-01 18:56:12 +08:00
|
|
|
menuItems.add(await _forceAlwaysRelayAction(peer.id));
|
|
|
|
menuItems.add(_renameAction(peer.id, false));
|
|
|
|
menuItems.add(_removeAction(peer.id));
|
|
|
|
menuItems.add(_unrememberPasswordAction(peer.id));
|
|
|
|
menuItems.add(_addFavAction(peer.id));
|
|
|
|
menuItems.add(_editTagAction(peer.id));
|
|
|
|
return menuItems;
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
@override
|
|
|
|
MenuEntryBase<String> _removeAction(String id) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate('Remove'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
() async {
|
|
|
|
gFFI.abModel.deletePeer(id);
|
|
|
|
await gFFI.abModel.updateAb();
|
|
|
|
}();
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
@protected
|
|
|
|
MenuEntryBase<String> _editTagAction(String id) {
|
|
|
|
return MenuEntryButton<String>(
|
|
|
|
childBuilder: (TextStyle? style) => Text(
|
|
|
|
translate('Edit Tag'),
|
|
|
|
style: style,
|
|
|
|
),
|
|
|
|
proc: () {
|
|
|
|
_abEditTag(id);
|
|
|
|
},
|
|
|
|
dismissOnClicked: true,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
void _abEditTag(String id) {
|
|
|
|
var isInProgress = false;
|
|
|
|
|
|
|
|
final tags = List.of(gFFI.abModel.tags);
|
|
|
|
var selectedTag = gFFI.abModel.getPeerTags(id).obs;
|
|
|
|
|
|
|
|
gFFI.dialogManager.show((setState, close) {
|
|
|
|
return CustomAlertDialog(
|
|
|
|
title: Text(translate("Edit Tag")),
|
|
|
|
content: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
|
|
|
child: Wrap(
|
|
|
|
children: tags
|
|
|
|
.map((e) => _buildTag(e, selectedTag, onTap: () {
|
|
|
|
if (selectedTag.contains(e)) {
|
|
|
|
selectedTag.remove(e);
|
|
|
|
} else {
|
|
|
|
selectedTag.add(e);
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
.toList(growable: false),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
Offstage(offstage: !isInProgress, child: LinearProgressIndicator())
|
|
|
|
],
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
close();
|
|
|
|
},
|
|
|
|
child: Text(translate("Cancel"))),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () async {
|
|
|
|
setState(() {
|
|
|
|
isInProgress = true;
|
|
|
|
});
|
|
|
|
gFFI.abModel.changeTagForPeer(id, selectedTag);
|
|
|
|
await gFFI.abModel.updateAb();
|
|
|
|
close();
|
|
|
|
},
|
|
|
|
child: Text(translate("OK"))),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _buildTag(String tagName, RxList<dynamic> rxTags,
|
|
|
|
{Function()? onTap}) {
|
|
|
|
return ContextMenuArea(
|
|
|
|
width: 100,
|
|
|
|
builder: (context) => [
|
|
|
|
ListTile(
|
|
|
|
title: Text(translate("Delete")),
|
|
|
|
onTap: () {
|
|
|
|
gFFI.abModel.deleteTag(tagName);
|
|
|
|
gFFI.abModel.updateAb();
|
|
|
|
Future.delayed(Duration.zero, () => Get.back());
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
child: GestureDetector(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Obx(
|
|
|
|
() => Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: rxTags.contains(tagName) ? Colors.blue : null,
|
|
|
|
border: Border.all(color: MyTheme.darkGray),
|
|
|
|
borderRadius: BorderRadius.circular(10)),
|
|
|
|
margin: EdgeInsets.symmetric(horizontal: 4.0, vertical: 8.0),
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 2.0, horizontal: 8.0),
|
|
|
|
child: Text(
|
|
|
|
tagName,
|
|
|
|
style: TextStyle(
|
|
|
|
color: rxTags.contains(tagName) ? MyTheme.white : null),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2022-07-27 22:56:28 +08:00
|
|
|
}
|
|
|
|
}
|
2022-08-25 14:35:08 +08:00
|
|
|
|
|
|
|
Future<PopupMenuItem<String>> _forceAlwaysRelayMenuItem(String id) async {
|
|
|
|
bool force_always_relay =
|
|
|
|
(await bind.mainGetPeerOption(id: id, key: 'force-always-relay'))
|
|
|
|
.isNotEmpty;
|
|
|
|
return PopupMenuItem<String>(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Offstage(
|
|
|
|
offstage: !force_always_relay,
|
|
|
|
child: Icon(Icons.check),
|
|
|
|
),
|
|
|
|
Text(translate('Always connect via relay')),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
value: 'force-always-relay');
|
|
|
|
}
|
2022-08-26 11:35:28 +08:00
|
|
|
|
|
|
|
PopupMenuItem<String> _rdpMenuItem(String id) {
|
|
|
|
return PopupMenuItem<String>(
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
Text('RDP'),
|
|
|
|
SizedBox(width: 20),
|
|
|
|
IconButton(
|
|
|
|
icon: Icon(Icons.edit),
|
|
|
|
onPressed: () => _rdpDialog(id),
|
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
value: 'RDP');
|
|
|
|
}
|
|
|
|
|
|
|
|
void _rdpDialog(String id) async {
|
|
|
|
final portController = TextEditingController(
|
|
|
|
text: await bind.mainGetPeerOption(id: id, key: 'rdp_port'));
|
|
|
|
final userController = TextEditingController(
|
|
|
|
text: await bind.mainGetPeerOption(id: id, key: 'rdp_username'));
|
|
|
|
final passwordContorller = TextEditingController(
|
|
|
|
text: await bind.mainGetPeerOption(id: id, key: 'rdp_password'));
|
|
|
|
RxBool secure = true.obs;
|
|
|
|
|
|
|
|
gFFI.dialogManager.show((setState, close) {
|
|
|
|
return CustomAlertDialog(
|
|
|
|
title: Text('RDP ' + translate('Settings')),
|
|
|
|
content: ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(minWidth: 500),
|
|
|
|
child: Column(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
children: [
|
|
|
|
SizedBox(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(minWidth: 100),
|
|
|
|
child: Text(
|
|
|
|
"${translate('Port')}:",
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
).marginOnly(bottom: 16.0)),
|
|
|
|
SizedBox(
|
|
|
|
width: 24.0,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: TextField(
|
|
|
|
inputFormatters: [
|
|
|
|
FilteringTextInputFormatter.allow(RegExp(
|
|
|
|
r'^([0-9]|[1-9]\d|[1-9]\d{2}|[1-9]\d{3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[0-5])$'))
|
|
|
|
],
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: OutlineInputBorder(), hintText: '3389'),
|
|
|
|
controller: portController,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(minWidth: 100),
|
|
|
|
child: Text(
|
|
|
|
"${translate('Username')}:",
|
|
|
|
textAlign: TextAlign.start,
|
|
|
|
).marginOnly(bottom: 16.0)),
|
|
|
|
SizedBox(
|
|
|
|
width: 24.0,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: TextField(
|
|
|
|
decoration: InputDecoration(border: OutlineInputBorder()),
|
|
|
|
controller: userController,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
SizedBox(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
Row(
|
|
|
|
children: [
|
|
|
|
ConstrainedBox(
|
|
|
|
constraints: BoxConstraints(minWidth: 100),
|
|
|
|
child: Text("${translate('Password')}:")
|
|
|
|
.marginOnly(bottom: 16.0)),
|
|
|
|
SizedBox(
|
|
|
|
width: 24.0,
|
|
|
|
),
|
|
|
|
Expanded(
|
|
|
|
child: Obx(() => TextField(
|
|
|
|
obscureText: secure.value,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
onPressed: () => secure.value = !secure.value,
|
|
|
|
icon: Icon(secure.value
|
|
|
|
? Icons.visibility_off
|
|
|
|
: Icons.visibility))),
|
|
|
|
controller: passwordContorller,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
actions: [
|
|
|
|
TextButton(
|
|
|
|
onPressed: () {
|
|
|
|
close();
|
|
|
|
},
|
|
|
|
child: Text(translate("Cancel"))),
|
|
|
|
TextButton(
|
|
|
|
onPressed: () async {
|
|
|
|
await bind.mainSetPeerOption(
|
|
|
|
id: id, key: 'rdp_port', value: portController.text.trim());
|
|
|
|
await bind.mainSetPeerOption(
|
|
|
|
id: id, key: 'rdp_username', value: userController.text);
|
|
|
|
await bind.mainSetPeerOption(
|
|
|
|
id: id, key: 'rdp_password', value: passwordContorller.text);
|
|
|
|
close();
|
|
|
|
},
|
|
|
|
child: Text(translate("OK"))),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
});
|
|
|
|
}
|