Skip to content

Commit

Permalink
Merge pull request #418 from mhuang-cht/master
Browse files Browse the repository at this point in the history
Use ElevatedButtons instead of AppBar action IconButtons in example app
  • Loading branch information
hiennguyen92 authored Mar 5, 2024
2 parents 9ec0254 + b255b9e commit bdaea1b
Showing 1 changed file with 66 additions and 58 deletions.
124 changes: 66 additions & 58 deletions example/lib/home_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,69 +41,74 @@ class HomePageState extends State<HomePage> {
return Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
actions: <Widget>[
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<void> 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."
});
}

Expand Down Expand Up @@ -205,7 +210,8 @@ class HomePageState extends State<HomePage> {
}

Future<void> getDevicePushTokenVoIP() async {
var devicePushTokenVoIP = await FlutterCallkitIncoming.getDevicePushTokenVoIP();
var devicePushTokenVoIP =
await FlutterCallkitIncoming.getDevicePushTokenVoIP();
print(devicePushTokenVoIP);
}

Expand All @@ -224,7 +230,8 @@ class HomePageState extends State<HomePage> {
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
Expand Down Expand Up @@ -269,13 +276,14 @@ class HomePageState extends State<HomePage> {

//check with https://webhook.site/#!/2748bc41-8599-4093-b8ad-93fd328f1cd2
Future<void> 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';
});
}
}

0 comments on commit bdaea1b

Please sign in to comment.