2026-03-07 17:11:02 -08:00
|
|
|
import 'dart:io';
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
import 'package:flutter/material.dart';
|
2026-03-07 17:11:02 -08:00
|
|
|
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
import 'package:provider/provider.dart';
|
2026-03-07 17:11:02 -08:00
|
|
|
import 'package:twilio_voice/twilio_voice.dart';
|
|
|
|
|
import '../models/queue_state.dart';
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
import '../providers/agent_provider.dart';
|
2026-03-07 17:11:02 -08:00
|
|
|
import '../providers/auth_provider.dart';
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
import '../providers/call_provider.dart';
|
|
|
|
|
import '../widgets/agent_status_toggle.dart';
|
2026-03-06 15:32:22 -08:00
|
|
|
import '../widgets/dialpad.dart';
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
import '../widgets/queue_card.dart';
|
|
|
|
|
import 'settings_screen.dart';
|
|
|
|
|
|
|
|
|
|
class DashboardScreen extends StatefulWidget {
|
|
|
|
|
const DashboardScreen({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<DashboardScreen> createState() => _DashboardScreenState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _DashboardScreenState extends State<DashboardScreen> {
|
2026-03-07 17:11:02 -08:00
|
|
|
bool _phoneAccountEnabled = true; // assume true until checked
|
|
|
|
|
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
context.read<AgentProvider>().refresh();
|
2026-03-07 17:11:02 -08:00
|
|
|
_checkPhoneAccount();
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 17:11:02 -08:00
|
|
|
Future<void> _checkPhoneAccount() async {
|
|
|
|
|
if (!kIsWeb && Platform.isAndroid) {
|
|
|
|
|
final enabled = await TwilioVoice.instance.isPhoneAccountEnabled();
|
|
|
|
|
if (mounted && !enabled) {
|
|
|
|
|
setState(() => _phoneAccountEnabled = false);
|
|
|
|
|
_showPhoneAccountDialog();
|
|
|
|
|
} else if (mounted) {
|
|
|
|
|
setState(() => _phoneAccountEnabled = true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _showPhoneAccountDialog() {
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierDismissible: false,
|
|
|
|
|
builder: (ctx) => AlertDialog(
|
|
|
|
|
title: const Text('Enable Phone Account'),
|
|
|
|
|
content: const Text(
|
|
|
|
|
'TWP Softphone needs to be enabled as a calling account to make and receive calls.\n\n'
|
|
|
|
|
'Tap "Open Settings" below, then find "TWP Softphone" in the list and toggle it ON.',
|
|
|
|
|
),
|
|
|
|
|
actions: [
|
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () => Navigator.pop(ctx),
|
|
|
|
|
child: const Text('Later'),
|
|
|
|
|
),
|
|
|
|
|
FilledButton(
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
Navigator.pop(ctx);
|
|
|
|
|
await TwilioVoice.instance.openPhoneAccountSettings();
|
|
|
|
|
// Poll until enabled or user comes back
|
|
|
|
|
for (int i = 0; i < 30; i++) {
|
|
|
|
|
await Future.delayed(const Duration(seconds: 1));
|
|
|
|
|
if (!mounted) return;
|
|
|
|
|
final enabled = await TwilioVoice.instance.isPhoneAccountEnabled();
|
|
|
|
|
if (enabled) {
|
|
|
|
|
setState(() => _phoneAccountEnabled = true);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Re-check one more time when coming back
|
|
|
|
|
_checkPhoneAccount();
|
|
|
|
|
},
|
|
|
|
|
child: const Text('Open Settings'),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-06 15:32:22 -08:00
|
|
|
void _showDialer(BuildContext context) {
|
|
|
|
|
final numberController = TextEditingController();
|
2026-03-07 17:11:02 -08:00
|
|
|
final phoneNumbers = context.read<AgentProvider>().phoneNumbers;
|
|
|
|
|
// Auto-select first phone number as caller ID
|
|
|
|
|
String? selectedCallerId =
|
|
|
|
|
phoneNumbers.isNotEmpty ? phoneNumbers.first.phoneNumber : null;
|
2026-03-06 15:32:22 -08:00
|
|
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
isScrollControlled: true,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
|
|
|
|
),
|
|
|
|
|
builder: (ctx) {
|
2026-03-06 18:05:54 -08:00
|
|
|
return StatefulBuilder(
|
|
|
|
|
builder: (ctx, setSheetState) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: EdgeInsets.only(
|
|
|
|
|
bottom: MediaQuery.of(ctx).viewInsets.bottom,
|
|
|
|
|
top: 16,
|
|
|
|
|
left: 16,
|
|
|
|
|
right: 16,
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
// Number display
|
|
|
|
|
TextField(
|
|
|
|
|
controller: numberController,
|
|
|
|
|
keyboardType: TextInputType.phone,
|
|
|
|
|
autofillHints: const [AutofillHints.telephoneNumber],
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: Theme.of(ctx).textTheme.headlineSmall,
|
|
|
|
|
decoration: InputDecoration(
|
|
|
|
|
hintText: 'Enter phone number',
|
|
|
|
|
suffixIcon: IconButton(
|
|
|
|
|
icon: const Icon(Icons.backspace_outlined),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
final text = numberController.text;
|
|
|
|
|
if (text.isNotEmpty) {
|
|
|
|
|
numberController.text =
|
|
|
|
|
text.substring(0, text.length - 1);
|
|
|
|
|
numberController.selection = TextSelection.fromPosition(
|
|
|
|
|
TextPosition(offset: numberController.text.length),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
2026-03-07 17:11:02 -08:00
|
|
|
// Caller ID selector (only if multiple numbers)
|
|
|
|
|
if (phoneNumbers.length > 1) ...[
|
2026-03-06 18:05:54 -08:00
|
|
|
const SizedBox(height: 12),
|
|
|
|
|
DropdownButtonFormField<String>(
|
|
|
|
|
initialValue: selectedCallerId,
|
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
|
labelText: 'Caller ID',
|
|
|
|
|
isDense: true,
|
|
|
|
|
contentPadding: EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
|
|
|
|
),
|
2026-03-07 17:11:02 -08:00
|
|
|
items: phoneNumbers.map((p) => DropdownMenuItem<String>(
|
|
|
|
|
value: p.phoneNumber,
|
|
|
|
|
child: Text('${p.friendlyName} (${p.phoneNumber})'),
|
|
|
|
|
)).toList(),
|
2026-03-06 18:05:54 -08:00
|
|
|
onChanged: (value) {
|
|
|
|
|
setSheetState(() {
|
|
|
|
|
selectedCallerId = value;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
2026-03-07 17:11:02 -08:00
|
|
|
] else if (phoneNumbers.length == 1) ...[
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
Text(
|
|
|
|
|
'Caller ID: ${phoneNumbers.first.phoneNumber}',
|
|
|
|
|
style: Theme.of(ctx).textTheme.bodySmall?.copyWith(
|
|
|
|
|
color: Theme.of(ctx).colorScheme.onSurfaceVariant,
|
|
|
|
|
),
|
|
|
|
|
),
|
2026-03-06 18:05:54 -08:00
|
|
|
],
|
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
// Dialpad
|
|
|
|
|
Dialpad(
|
|
|
|
|
onDigit: (digit) {
|
|
|
|
|
numberController.text += digit;
|
|
|
|
|
numberController.selection = TextSelection.fromPosition(
|
|
|
|
|
TextPosition(offset: numberController.text.length),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
onClose: () => Navigator.pop(ctx),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
// Call button
|
|
|
|
|
ElevatedButton.icon(
|
|
|
|
|
style: ElevatedButton.styleFrom(
|
|
|
|
|
backgroundColor: Colors.green,
|
|
|
|
|
foregroundColor: Colors.white,
|
|
|
|
|
minimumSize: const Size(double.infinity, 48),
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.circular(24),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
icon: const Icon(Icons.call),
|
|
|
|
|
label: const Text('Call'),
|
2026-03-06 15:32:22 -08:00
|
|
|
onPressed: () {
|
2026-03-06 18:05:54 -08:00
|
|
|
final number = numberController.text.trim();
|
2026-03-07 17:11:02 -08:00
|
|
|
if (number.isEmpty) return;
|
|
|
|
|
if (selectedCallerId == null) {
|
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
|
|
|
const SnackBar(content: Text('No caller ID available. Add a phone number first.')),
|
|
|
|
|
);
|
|
|
|
|
return;
|
2026-03-06 15:32:22 -08:00
|
|
|
}
|
2026-03-07 17:11:02 -08:00
|
|
|
context.read<CallProvider>().makeCall(number, callerId: selectedCallerId);
|
|
|
|
|
Navigator.pop(ctx);
|
2026-03-06 15:32:22 -08:00
|
|
|
},
|
|
|
|
|
),
|
2026-03-06 18:05:54 -08:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
|
],
|
2026-03-06 15:32:22 -08:00
|
|
|
),
|
2026-03-06 18:05:54 -08:00
|
|
|
);
|
|
|
|
|
},
|
2026-03-06 15:32:22 -08:00
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-07 17:11:02 -08:00
|
|
|
void _showQueueCalls(BuildContext context, QueueInfo queue) {
|
|
|
|
|
final voiceService = context.read<AuthProvider>().voiceService;
|
|
|
|
|
final callProvider = context.read<CallProvider>();
|
|
|
|
|
|
|
|
|
|
showModalBottomSheet(
|
|
|
|
|
context: context,
|
|
|
|
|
shape: const RoundedRectangleBorder(
|
|
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16)),
|
|
|
|
|
),
|
|
|
|
|
builder: (ctx) {
|
|
|
|
|
return FutureBuilder<List<Map<String, dynamic>>>(
|
|
|
|
|
future: voiceService.getQueueCalls(queue.id),
|
|
|
|
|
builder: (context, snapshot) {
|
|
|
|
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
|
|
|
|
return const Padding(
|
|
|
|
|
padding: EdgeInsets.all(32),
|
|
|
|
|
child: Center(child: CircularProgressIndicator()),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (snapshot.hasError) {
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.all(24),
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text('Error loading calls: ${snapshot.error}'),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
final calls = (snapshot.data ?? [])
|
|
|
|
|
.map((c) => QueueCall.fromJson(c))
|
|
|
|
|
.toList();
|
|
|
|
|
|
|
|
|
|
if (calls.isEmpty) {
|
|
|
|
|
return const Padding(
|
|
|
|
|
padding: EdgeInsets.all(24),
|
|
|
|
|
child: Center(child: Text('No calls waiting')),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 16),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
|
|
|
child: Text(
|
|
|
|
|
'${queue.name} - Waiting Calls',
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
...calls.map((call) => ListTile(
|
|
|
|
|
leading: const CircleAvatar(
|
|
|
|
|
child: Icon(Icons.phone_in_talk),
|
|
|
|
|
),
|
|
|
|
|
title: Text(call.fromNumber),
|
|
|
|
|
subtitle: Text('Waiting ${_formatWaitTime(call.waitTime)}'),
|
|
|
|
|
trailing: FilledButton.icon(
|
|
|
|
|
icon: const Icon(Icons.call, size: 18),
|
|
|
|
|
label: const Text('Accept'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.pop(ctx);
|
|
|
|
|
callProvider.acceptQueueCall(call.callSid);
|
|
|
|
|
// Cancel queue alert notification
|
|
|
|
|
FlutterLocalNotificationsPlugin().cancel(9001);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String _formatWaitTime(int seconds) {
|
|
|
|
|
if (seconds < 60) return '${seconds}s';
|
|
|
|
|
final minutes = seconds ~/ 60;
|
|
|
|
|
final secs = seconds % 60;
|
|
|
|
|
return '${minutes}m ${secs}s';
|
|
|
|
|
}
|
|
|
|
|
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final agent = context.watch<AgentProvider>();
|
2026-03-07 17:11:02 -08:00
|
|
|
|
|
|
|
|
// Android Telecom framework handles the call UI via the native InCallUI,
|
|
|
|
|
// so we don't navigate to our own ActiveCallScreen.
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
title: const Text('TWP Softphone'),
|
|
|
|
|
actions: [
|
|
|
|
|
// SSE connection indicator
|
|
|
|
|
Padding(
|
|
|
|
|
padding: const EdgeInsets.only(right: 8),
|
|
|
|
|
child: Icon(
|
|
|
|
|
Icons.circle,
|
|
|
|
|
size: 12,
|
|
|
|
|
color: agent.sseConnected ? Colors.green : Colors.red,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: const Icon(Icons.settings),
|
|
|
|
|
onPressed: () => Navigator.push(context,
|
|
|
|
|
MaterialPageRoute(builder: (_) => const SettingsScreen())),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
2026-03-06 15:32:22 -08:00
|
|
|
floatingActionButton: FloatingActionButton(
|
|
|
|
|
onPressed: () => _showDialer(context),
|
|
|
|
|
child: const Icon(Icons.phone),
|
|
|
|
|
),
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
body: RefreshIndicator(
|
|
|
|
|
onRefresh: () => agent.refresh(),
|
|
|
|
|
child: ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
children: [
|
2026-03-07 17:11:02 -08:00
|
|
|
if (!_phoneAccountEnabled)
|
|
|
|
|
Card(
|
|
|
|
|
color: Colors.orange.shade50,
|
|
|
|
|
child: ListTile(
|
|
|
|
|
leading: Icon(Icons.warning, color: Colors.orange.shade700),
|
|
|
|
|
title: const Text('Phone Account Not Enabled'),
|
|
|
|
|
subtitle: const Text('Tap to enable calling in settings'),
|
|
|
|
|
trailing: const Icon(Icons.chevron_right),
|
|
|
|
|
onTap: () => _showPhoneAccountDialog(),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (!_phoneAccountEnabled) const SizedBox(height: 8),
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
const AgentStatusToggle(),
|
|
|
|
|
const SizedBox(height: 24),
|
|
|
|
|
Text('Queues',
|
|
|
|
|
style: Theme.of(context).textTheme.titleMedium),
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
if (agent.queues.isEmpty)
|
|
|
|
|
const Card(
|
|
|
|
|
child: Padding(
|
|
|
|
|
padding: EdgeInsets.all(24),
|
|
|
|
|
child: Center(child: Text('No queues assigned')),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
else
|
|
|
|
|
...agent.queues.map((q) => Padding(
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 8),
|
2026-03-07 17:11:02 -08:00
|
|
|
child: QueueCard(
|
|
|
|
|
queue: q,
|
|
|
|
|
onTap: q.waitingCount > 0
|
|
|
|
|
? () => _showQueueCalls(context, q)
|
|
|
|
|
: null,
|
|
|
|
|
),
|
Add TWP Softphone Flutter app and complete mobile backend API
Backend: Add /voice/token endpoint with AccessToken + VoiceGrant for
mobile VoIP, implement unhold_call() with call leg detection, wire FCM
push notifications into call queue and webhook missed call handlers,
add data-only FCM message support for Android background wake, and add
Twilio API Key / Push Credential settings fields.
Flutter app: Full softphone with Twilio Voice SDK integration, JWT auth
with auto-refresh, SSE real-time queue updates, FCM push notifications,
Material 3 UI with dashboard, active call screen, dialpad, and call
controls (mute/speaker/hold/transfer).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 13:01:23 -08:00
|
|
|
)),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|