android direct ip access

This commit is contained in:
csf
2022-09-29 13:07:20 +08:00
parent 0abda2edef
commit 9911f4d2f5
7 changed files with 153 additions and 38 deletions

View File

@@ -155,3 +155,54 @@ void changeWhiteList({Function()? callback}) async {
);
});
}
Future<String> changeDirectAccessPort(
String currentIP, String currentPort) async {
final controller = TextEditingController(text: currentPort);
await gFFI.dialogManager.show((setState, close) {
return CustomAlertDialog(
title: Text(translate("Change Local Port")),
content: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 8.0),
Row(
children: [
Expanded(
child: TextField(
maxLines: null,
keyboardType: TextInputType.number,
decoration: InputDecoration(
hintText: '21118',
isCollapsed: true,
prefix: Text('$currentIP : '),
suffix: IconButton(
padding: EdgeInsets.zero,
icon: const Icon(Icons.clear, size: 16),
onPressed: () => controller.clear())),
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])$')),
],
controller: controller,
focusNode: FocusNode()..requestFocus()),
),
],
),
],
),
actions: [
TextButton(onPressed: close, child: Text(translate("Cancel"))),
TextButton(
onPressed: () async {
await bind.mainSetOption(
key: 'direct-access-port', value: controller.text);
close();
},
child: Text(translate("OK"))),
],
onCancel: close,
);
});
return controller.text;
}