Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Connection dialog popup #50

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 38 additions & 33 deletions lib/features/library/containers/connection_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,39 +113,44 @@ class _ConnectionCardState extends State<ConnectionCard> {
style: const TextStyle(fontWeight: FontWeight.bold)),
trailing: widget.canDisconnect
? TextButton(
onPressed: () => showDialog(
builder: (ctx) {
return AlertDialog(
title: const Text("Confirmation"),
content: SizedBox(
width: MediaQuery.of(context).size.width,
child: Text(
"Are your sure you want to delete ${widget.connection.title}?",
),
),
actions: [
ElevatedButton(
onPressed: () {
Navigator.of(ctx).pop();
},
child: const Text("CANCEL"),
),
FilledButton(
onPressed: () {
_handleConnection(context, ref);
Navigator.of(context).pop();
},
child: const Text("DISCONNECT"),
),
],
);
},
context: context,
),
child: isLoading
? const CircularProgressIndicator()
: const Text("Disconnect"),
)
onPressed: () async { // Make onPressed async
final result = await showDialog<bool>( // Await the dialog result
context: context,
builder: (ctx) {
return AlertDialog(
title: const Text("Confirmation"),
content: SizedBox(
width: MediaQuery.of(context).size.width,
child: Text(
"Are you sure you want to delete ${widget.connection.title}?",
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(ctx).pop(false); // Return false on cancel
},
child: const Text("CANCEL"),
),
FilledButton(
onPressed: () {
Navigator.of(ctx).pop(true); // Return true on disconnect
},
child: const Text("DISCONNECT"),
),
],
);
},
);

if (result == true) { // Check if the user pressed disconnect
_handleConnection(context, ref);
}
},
child: isLoading
? const CircularProgressIndicator()
: const Text("Disconnect"),
)
: null,
),
);
Expand Down
Loading