import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; class DefaultDialerPromptScreen extends StatelessWidget { const DefaultDialerPromptScreen({super.key}); Future _requestDefaultDialer(BuildContext context) async { const channel = MethodChannel('call_service'); try { await channel.invokeMethod('requestDefaultDialer'); // Navigate to home page after requesting default dialer Navigator.of(context).pushReplacementNamed('/home'); } catch (e) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text('Error requesting default dialer: $e')), ); } } void _exploreApp(BuildContext context) { // Navigate to home page without requesting default dialer Navigator.of(context).pushReplacementNamed('/home'); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, body: SafeArea( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Expanded( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'Set as Default Dialer', style: TextStyle( fontSize: 24, fontWeight: FontWeight.bold, color: Colors.white, ), textAlign: TextAlign.center, ), SizedBox(height: 16), Text( 'To handle calls effectively, Icing needs to be your default dialer app. This allows Icing to manage incoming and outgoing calls seamlessly.\n\nWithout the permission, Icing will not be able to encrypt calls.', style: TextStyle( fontSize: 16, color: Colors.white70, ), textAlign: TextAlign.center, ), ], ), ), Row( children: [ Expanded( flex: 1, child: Padding( padding: const EdgeInsets.only(right: 8.0), child: ElevatedButton( onPressed: () => _exploreApp(context), style: ElevatedButton.styleFrom( backgroundColor: Colors.grey[800], foregroundColor: Colors.white, padding: EdgeInsets.symmetric( horizontal: 16, vertical: 12), ), child: Text('Explore App first'), ), ), ), Expanded( flex: 1, child: Padding( padding: const EdgeInsets.only(left: 8.0), child: ElevatedButton( onPressed: () => _requestDefaultDialer(context), style: ElevatedButton.styleFrom( backgroundColor: Colors.blue, foregroundColor: Colors.white, padding: EdgeInsets.symmetric( horizontal: 16, vertical: 12), ), child: Text('Set as Default Dialer'), ), ), ), ], ), ], ), ), ), ); } }