android and approve mode
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
bb679bf25a
commit
f38ebb7b3c
@ -25,6 +25,18 @@ class ServerPage extends StatefulWidget implements PageShape {
|
|||||||
PopupMenuButton<String>(
|
PopupMenuButton<String>(
|
||||||
icon: const Icon(Icons.more_vert),
|
icon: const Icon(Icons.more_vert),
|
||||||
itemBuilder: (context) {
|
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 [
|
return [
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
enabled: gFFI.serverModel.connectStatus > 0,
|
enabled: gFFI.serverModel.connectStatus > 0,
|
||||||
@ -32,62 +44,64 @@ class ServerPage extends StatefulWidget implements PageShape {
|
|||||||
value: "changeID",
|
value: "changeID",
|
||||||
child: Text(translate("Change ID")),
|
child: Text(translate("Change ID")),
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
value: "setPermanentPassword",
|
|
||||||
enabled:
|
|
||||||
gFFI.serverModel.verificationMethod != kUseTemporaryPassword,
|
|
||||||
child: Text(translate("Set permanent password")),
|
|
||||||
),
|
|
||||||
PopupMenuItem(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
value: "setTemporaryPasswordLength",
|
|
||||||
enabled:
|
|
||||||
gFFI.serverModel.verificationMethod != kUsePermanentPassword,
|
|
||||||
child: Text(translate("One-time password length")),
|
|
||||||
),
|
|
||||||
const PopupMenuDivider(),
|
const PopupMenuDivider(),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
||||||
value: kUseTemporaryPassword,
|
value: 'AcceptSessionsViaPassword',
|
||||||
child: ListTile(
|
child: listTile(
|
||||||
title: Text(translate("Use one-time password")),
|
'Accept sessions via password', approveMode == 'password'),
|
||||||
trailing: Icon(
|
|
||||||
Icons.check,
|
|
||||||
color: gFFI.serverModel.verificationMethod ==
|
|
||||||
kUseTemporaryPassword
|
|
||||||
? null
|
|
||||||
: Colors.transparent,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
||||||
value: kUsePermanentPassword,
|
value: 'AcceptSessionsViaClick',
|
||||||
child: ListTile(
|
child:
|
||||||
title: Text(translate("Use permanent password")),
|
listTile('Accept sessions via click', approveMode == 'click'),
|
||||||
trailing: Icon(
|
|
||||||
Icons.check,
|
|
||||||
color: gFFI.serverModel.verificationMethod ==
|
|
||||||
kUsePermanentPassword
|
|
||||||
? null
|
|
||||||
: Colors.transparent,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
padding: const EdgeInsets.symmetric(horizontal: 0.0),
|
||||||
value: kUseBothPasswords,
|
value: "AcceptSessionsViaBoth",
|
||||||
child: ListTile(
|
child: listTile("Accept sessions via both",
|
||||||
title: Text(translate("Use both passwords")),
|
approveMode != 'password' && approveMode != 'click'),
|
||||||
trailing: Icon(
|
|
||||||
Icons.check,
|
|
||||||
color: gFFI.serverModel.verificationMethod !=
|
|
||||||
kUseTemporaryPassword &&
|
|
||||||
gFFI.serverModel.verificationMethod !=
|
|
||||||
kUsePermanentPassword
|
|
||||||
? null
|
|
||||||
: Colors.transparent,
|
|
||||||
)),
|
|
||||||
),
|
),
|
||||||
|
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) {
|
onSelected: (value) {
|
||||||
@ -102,6 +116,15 @@ class ServerPage extends StatefulWidget implements PageShape {
|
|||||||
value == kUseBothPasswords) {
|
value == kUseBothPasswords) {
|
||||||
bind.mainSetOption(key: "verification-method", value: value);
|
bind.mainSetOption(key: "verification-method", value: value);
|
||||||
gFFI.serverModel.updatePasswordModel();
|
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('');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
@ -434,12 +457,14 @@ class ConnectionManager extends StatelessWidget {
|
|||||||
serverModel.sendLoginResponse(
|
serverModel.sendLoginResponse(
|
||||||
client, false);
|
client, false);
|
||||||
}).marginOnly(right: 15),
|
}).marginOnly(right: 15),
|
||||||
ElevatedButton.icon(
|
if (serverModel.approveMode != 'password')
|
||||||
icon: const Icon(Icons.check),
|
ElevatedButton.icon(
|
||||||
label: Text(translate("Accept")),
|
icon: const Icon(Icons.check),
|
||||||
onPressed: () {
|
label: Text(translate("Accept")),
|
||||||
serverModel.sendLoginResponse(client, true);
|
onPressed: () {
|
||||||
}),
|
serverModel.sendLoginResponse(
|
||||||
|
client, true);
|
||||||
|
}),
|
||||||
]),
|
]),
|
||||||
])))
|
])))
|
||||||
.toList());
|
.toList());
|
||||||
|
@ -520,7 +520,8 @@ class ServerModel with ChangeNotifier {
|
|||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
dialogButton("Dismiss", onPressed: cancel, isOutline: true),
|
dialogButton("Dismiss", onPressed: cancel, isOutline: true),
|
||||||
dialogButton("Accept", onPressed: submit),
|
if (approveMode != 'password')
|
||||||
|
dialogButton("Accept", onPressed: submit),
|
||||||
],
|
],
|
||||||
onSubmit: submit,
|
onSubmit: submit,
|
||||||
onCancel: cancel,
|
onCancel: cancel,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user