feat: no pop when deleting the config

This commit is contained in:
cialloo
2024-07-22 20:36:36 +08:00
parent 8e2dda50a4
commit 5847a92714

View File

@@ -302,10 +302,13 @@ class _ControlPageState extends State<ControlPage> {
),
TextButton(
onPressed: () {
SavedConnection? selectedSavedConnection;
showDialog<String>(
context: context,
builder: (BuildContext context) => Dialog(
builder: (BuildContext context) => StatefulBuilder(
builder:
(BuildContext context, StateSetter setState) {
SavedConnection? selectedSavedConnection;
return Dialog(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
@@ -315,7 +318,8 @@ class _ControlPageState extends State<ControlPage> {
Builder(builder: (context) {
String jsonString =
SharedPrefSingleton().savedConnection;
List<dynamic> nodeList = jsonDecode(jsonString);
List<dynamic> nodeList =
jsonDecode(jsonString);
List<SavedConnection> nodes = nodeList
.cast<Map<String, dynamic>>()
.map((nodeData) =>
@@ -355,9 +359,11 @@ class _ControlPageState extends State<ControlPage> {
onPressed: () {
if (selectedSavedConnection != null) {
_supernodeController.text =
selectedSavedConnection!.supernode;
selectedSavedConnection!
.supernode;
_communityController.text =
selectedSavedConnection!.community;
selectedSavedConnection!
.community;
_keyController.text =
selectedSavedConnection!
.communityKey;
@@ -369,8 +375,8 @@ class _ControlPageState extends State<ControlPage> {
Navigator.pop(context);
return;
},
child:
Text(AppLocalizations.of(context)!.use),
child: Text(
AppLocalizations.of(context)!.use),
),
TextButton(
onPressed: () {
@@ -380,7 +386,8 @@ class _ControlPageState extends State<ControlPage> {
}
String jsonString =
SharedPrefSingleton().savedConnection;
SharedPrefSingleton()
.savedConnection;
List<dynamic> nodeList =
jsonDecode(jsonString);
List<SavedConnection> nodes = nodeList
@@ -405,7 +412,8 @@ class _ControlPageState extends State<ControlPage> {
.setSavedConnection(
jsonEncode(nodeMaps))
.then((onValue) {
Navigator.pop(context);
setState(() {});
// Navigator.pop(context);
return;
});
},
@@ -425,7 +433,8 @@ class _ControlPageState extends State<ControlPage> {
],
),
),
),
);
}),
);
},
child: Text(AppLocalizations.of(context)!.useConfig)),