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