From b255b9e1cc5bb6f75ddb8e5aeb35805e18a3f6e2 Mon Sep 17 00:00:00 2001 From: mhuang Date: Fri, 5 Jan 2024 17:35:32 -0500 Subject: [PATCH] Use ElevatedButtons instead of AppBar action IconButtons in example app --- example/lib/home_page.dart | 124 ++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 58 deletions(-) diff --git a/example/lib/home_page.dart b/example/lib/home_page.dart index 8434412a..019ee4f6 100644 --- a/example/lib/home_page.dart +++ b/example/lib/home_page.dart @@ -41,69 +41,74 @@ class HomePageState extends State { return Scaffold( appBar: AppBar( title: const Text('Plugin example app'), - actions: [ - IconButton( - icon: const Icon( - Icons.call, - color: Colors.white, - ), - onPressed: makeFakeCallInComing, - ), - IconButton( - icon: const Icon( - Icons.call_end, - color: Colors.white, - ), - onPressed: endCurrentCall, - ), - IconButton( - icon: const Icon( - Icons.call_made, - color: Colors.white, - ), - onPressed: startOutGoingCall, - ), - IconButton( - icon: const Icon( - Icons.call_merge, - color: Colors.white, - ), - onPressed: activeCalls, - ), - IconButton( - icon: const Icon( - Icons.clear_all_sharp, - color: Colors.white, - ), - onPressed: endAllCalls, - ) - ], ), - body: LayoutBuilder( - builder: (BuildContext context, BoxConstraints viewportConstraints) { - if (textEvents.isNotEmpty) { - return SingleChildScrollView( - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: viewportConstraints.maxHeight, + body: Padding( + padding: const EdgeInsets.all(10.0), + child: Column( + children: [ + Column( + children: [ + ElevatedButton.icon( + icon: const Icon(Icons.call), + label: Text('Make fake call incoming'), + onPressed: makeFakeCallInComing, + ), + ElevatedButton.icon( + icon: const Icon(Icons.call_end), + label: Text('End current call'), + onPressed: endCurrentCall, ), - child: Text(textEvents), + ElevatedButton.icon( + icon: const Icon(Icons.call_made), + label: Text('Start outgoing call'), + onPressed: startOutGoingCall, + ), + ElevatedButton.icon( + icon: const Icon(Icons.call_merge), + label: Text('Active calls'), + onPressed: activeCalls, + ), + ElevatedButton.icon( + icon: const Icon(Icons.clear_all_sharp), + label: Text('End all calls'), + onPressed: endAllCalls, + ), + const Divider(), + ], + ), + Expanded( + child: LayoutBuilder( + builder: + (BuildContext context, BoxConstraints viewportConstraints) { + if (textEvents.isNotEmpty) { + return SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: viewportConstraints.maxHeight, + ), + child: Text(textEvents), + ), + ); + } else { + return const Center( + child: Text('No Event'), + ); + } + }, ), - ); - } else { - return const Center( - child: Text('No Event'), - ); - } - }, + ), + ], + ), ), ); } Future requestNotificationPermission() async { await FlutterCallkitIncoming.requestNotificationPermission({ - "rationaleMessagePermission": "Notification permission is required, to show notification.", - "postNotificationMessageRequired": "Notification permission is required, Please allow notification permission from setting." + "rationaleMessagePermission": + "Notification permission is required, to show notification.", + "postNotificationMessageRequired": + "Notification permission is required, Please allow notification permission from setting." }); } @@ -205,7 +210,8 @@ class HomePageState extends State { } Future getDevicePushTokenVoIP() async { - var devicePushTokenVoIP = await FlutterCallkitIncoming.getDevicePushTokenVoIP(); + var devicePushTokenVoIP = + await FlutterCallkitIncoming.getDevicePushTokenVoIP(); print(devicePushTokenVoIP); } @@ -224,7 +230,8 @@ class HomePageState extends State { case Event.actionCallAccept: // TODO: accepted an incoming call // TODO: show screen calling in Flutter - NavigationService.instance.pushNamedIfNotCurrent(AppRoute.callingPage, args: event.body); + NavigationService.instance + .pushNamedIfNotCurrent(AppRoute.callingPage, args: event.body); break; case Event.actionCallDecline: // TODO: declined an incoming call @@ -269,13 +276,14 @@ class HomePageState extends State { //check with https://webhook.site/#!/2748bc41-8599-4093-b8ad-93fd328f1cd2 Future requestHttp(content) async { - get(Uri.parse('https://webhook.site/2748bc41-8599-4093-b8ad-93fd328f1cd2?data=$content')); + get(Uri.parse( + 'https://webhook.site/2748bc41-8599-4093-b8ad-93fd328f1cd2?data=$content')); } void onEvent(CallEvent event) { if (!mounted) return; setState(() { - textEvents += '${event.toString()}\n'; + textEvents += '---\n${event.toString()}\n'; }); } }