Skip to content

Commit

Permalink
Update server_page.dart
Browse files Browse the repository at this point in the history
  • Loading branch information
khederkasem committed Oct 1, 2023
1 parent 2121a3c commit dafe554
Showing 1 changed file with 109 additions and 109 deletions.
218 changes: 109 additions & 109 deletions flutter/lib/mobile/pages/server_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,115 +21,115 @@ class ServerPage extends StatefulWidget implements PageShape {
@override
final icon = const Icon(Icons.mobile_screen_share);

// @override
// final appBarActions = [
// PopupMenuButton<String>(
// tooltip: "",
// icon: const Icon(Icons.more_vert),
// itemBuilder: (context) {
// listTile(String text, bool checked) {
// return ListTile(
// title: Text(translate(text)),
// trailing: Icon(
// Icons.check,
// color: checked ? null : Colors.transparent,
// ));
// }

// final approveMode = gFFI.serverModel.approveMode;
// final verificationMethod = gFFI.serverModel.verificationMethod;
// final showPasswordOption = approveMode != 'click';
// return [
// PopupMenuItem(
// enabled: gFFI.serverModel.connectStatus > 0,
// padding: const EdgeInsets.symmetric(horizontal: 16.0),
// value: "changeID",
// child: Text(translate("Change ID")),
// ),
// const PopupMenuDivider(),
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 0.0),
// value: 'AcceptSessionsViaPassword',
// child: listTile(
// 'Accept sessions via password', approveMode == 'password'),
// ),
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 0.0),
// value: 'AcceptSessionsViaClick',
// child:
// listTile('Accept sessions via click', approveMode == 'click'),
// ),
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 0.0),
// value: "AcceptSessionsViaBoth",
// child: listTile("Accept sessions via both",
// approveMode != 'password' && approveMode != 'click'),
// ),
// if (showPasswordOption) const PopupMenuDivider(),
// if (showPasswordOption &&
// verificationMethod != kUseTemporaryPassword)
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 16.0),
// value: "setPermanentPassword",
// child: Text(translate("Set permanent password")),
// ),
// if (showPasswordOption &&
// verificationMethod != kUsePermanentPassword)
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 16.0),
// value: "setTemporaryPasswordLength",
// child: Text(translate("One-time password length")),
// ),
// if (showPasswordOption) const PopupMenuDivider(),
// if (showPasswordOption)
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 0.0),
// value: kUseTemporaryPassword,
// child: listTile('Use one-time password',
// verificationMethod == kUseTemporaryPassword),
// ),
// if (showPasswordOption)
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 0.0),
// value: kUsePermanentPassword,
// child: listTile('Use permanent password',
// verificationMethod == kUsePermanentPassword),
// ),
// if (showPasswordOption)
// PopupMenuItem(
// padding: const EdgeInsets.symmetric(horizontal: 0.0),
// value: kUseBothPasswords,
// child: listTile(
// 'Use both passwords',
// verificationMethod != kUseTemporaryPassword &&
// verificationMethod != kUsePermanentPassword),
// ),
// ];
// },
// onSelected: (value) {
// if (value == "changeID") {
// changeIdDialog();
// } else if (value == "setPermanentPassword") {
// setPermanentPasswordDialog(gFFI.dialogManager);
// } else if (value == "setTemporaryPasswordLength") {
// setTemporaryPasswordLengthDialog(gFFI.dialogManager);
// } else if (value == kUsePermanentPassword ||
// value == kUseTemporaryPassword ||
// value == kUseBothPasswords) {
// bind.mainSetOption(key: "verification-method", value: value);
// gFFI.serverModel.updatePasswordModel();
// } else if (value.startsWith("AcceptSessionsVia")) {
// value = value.substring("AcceptSessionsVia".length);
// if (value == "Password") {
// gFFI.serverModel.setApproveMode('password');
// } else if (value == "Click") {
// gFFI.serverModel.setApproveMode('click');
// } else {
// gFFI.serverModel.setApproveMode('');
// }
// }
// })
// ];
@override
final appBarActions = [
PopupMenuButton<String>(
tooltip: "",
icon: const Icon(Icons.more_vert),
itemBuilder: (context) {
listTile(String text, bool checked) {
return ListTile(
title: Text(translate(text)),
trailing: Icon(
Icons.check,
color: checked ? null : Colors.transparent,
));
}

final approveMode = gFFI.serverModel.approveMode;
final verificationMethod = gFFI.serverModel.verificationMethod;
final showPasswordOption = approveMode != 'click';
return [
PopupMenuItem(
enabled: gFFI.serverModel.connectStatus > 0,
padding: const EdgeInsets.symmetric(horizontal: 16.0),
value: "changeID",
child: Text(translate("Change ID")),
),
const PopupMenuDivider(),
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: 'AcceptSessionsViaPassword',
child: listTile(
'Accept sessions via password', approveMode == 'password'),
),
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: 'AcceptSessionsViaClick',
child:
listTile('Accept sessions via click', approveMode == 'click'),
),
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: "AcceptSessionsViaBoth",
child: listTile("Accept sessions via both",
approveMode != 'password' && approveMode != 'click'),
),
if (showPasswordOption) const PopupMenuDivider(),
if (showPasswordOption &&
verificationMethod != kUseTemporaryPassword)
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
value: "setPermanentPassword",
child: Text(translate("Set permanent password")),
),
if (showPasswordOption &&
verificationMethod != kUsePermanentPassword)
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
value: "setTemporaryPasswordLength",
child: Text(translate("One-time password length")),
),
if (showPasswordOption) const PopupMenuDivider(),
if (showPasswordOption)
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: kUseTemporaryPassword,
child: listTile('Use one-time password',
verificationMethod == kUseTemporaryPassword),
),
if (showPasswordOption)
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: kUsePermanentPassword,
child: listTile('Use permanent password',
verificationMethod == kUsePermanentPassword),
),
if (showPasswordOption)
PopupMenuItem(
padding: const EdgeInsets.symmetric(horizontal: 0.0),
value: kUseBothPasswords,
child: listTile(
'Use both passwords',
verificationMethod != kUseTemporaryPassword &&
verificationMethod != kUsePermanentPassword),
),
];
},
onSelected: (value) {
if (value == "changeID") {
changeIdDialog();
} else if (value == "setPermanentPassword") {
setPermanentPasswordDialog(gFFI.dialogManager);
} else if (value == "setTemporaryPasswordLength") {
setTemporaryPasswordLengthDialog(gFFI.dialogManager);
} else if (value == kUsePermanentPassword ||
value == kUseTemporaryPassword ||
value == kUseBothPasswords) {
bind.mainSetOption(key: "verification-method", value: value);
gFFI.serverModel.updatePasswordModel();
} else if (value.startsWith("AcceptSessionsVia")) {
value = value.substring("AcceptSessionsVia".length);
if (value == "Password") {
gFFI.serverModel.setApproveMode('password');
} else if (value == "Click") {
gFFI.serverModel.setApproveMode('click');
} else {
gFFI.serverModel.setApproveMode('');
}
}
})
];

ServerPage({Key? key}) : super(key: key);

Expand Down

0 comments on commit dafe554

Please sign in to comment.