From 0f99e807f83ff93ace19e89d2437f2c7b429aa46 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Mon, 20 Apr 2020 14:41:09 +0200 Subject: [PATCH] Add confirmation to leave call --- lib/ui/screens/call_screen.dart | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/ui/screens/call_screen.dart b/lib/ui/screens/call_screen.dart index 91a42cd..1092de0 100644 --- a/lib/ui/screens/call_screen.dart +++ b/lib/ui/screens/call_screen.dart @@ -8,7 +8,6 @@ import 'package:comunic/models/call_config.dart'; import 'package:comunic/models/call_member.dart'; import 'package:comunic/models/conversation.dart'; import 'package:comunic/ui/routes/main_route.dart'; -import 'package:comunic/ui/widgets/comunic_back_button_widget.dart'; import 'package:comunic/ui/widgets/safe_state.dart'; import 'package:comunic/utils/account_utils.dart'; import 'package:comunic/utils/intl_utils.dart'; @@ -91,7 +90,7 @@ class _CallScreenState extends SafeState { }); this.listen((e) { - if (e.callID == convID) _leaveCall(); + if (e.callID == convID) _leaveCall(needConfirm: false); }); } catch (e, stack) { print("Could not initialize call! $e\n$stack"); @@ -110,7 +109,12 @@ class _CallScreenState extends SafeState { } // Make us leave the call - void _leaveCall() { + void _leaveCall({bool needConfirm = true}) async { + if (needConfirm && + !await showConfirmDialog( + context: context, + message: tr("Do you really want to leave this call ?"))) return; + MainController.of(context).popPage(); } @@ -123,7 +127,10 @@ class _CallScreenState extends SafeState { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - leading: ComunicBackButton(), + leading: IconButton( + icon: Icon(Icons.arrow_back), + onPressed: () => _leaveCall(), + ), title: _convName == null ? CircularProgressIndicator() : Text(_convName), ),