Add TWP Softphone Flutter app and complete mobile backend API
All checks were successful
Create Release / build (push) Successful in 4s
All checks were successful
Create Release / build (push) Successful in 4s
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>
This commit is contained in:
51
mobile/lib/widgets/agent_status_toggle.dart
Normal file
51
mobile/lib/widgets/agent_status_toggle.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../models/agent_status.dart';
|
||||
import '../providers/agent_provider.dart';
|
||||
|
||||
class AgentStatusToggle extends StatelessWidget {
|
||||
const AgentStatusToggle({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final agent = context.watch<AgentProvider>();
|
||||
final current = agent.status?.status ?? AgentStatusValue.offline;
|
||||
|
||||
return Card(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('Agent Status',
|
||||
style: Theme.of(context).textTheme.titleSmall),
|
||||
const SizedBox(height: 12),
|
||||
SegmentedButton<AgentStatusValue>(
|
||||
segments: const [
|
||||
ButtonSegment(
|
||||
value: AgentStatusValue.available,
|
||||
label: Text('Available'),
|
||||
icon: Icon(Icons.circle, color: Colors.green, size: 12),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: AgentStatusValue.busy,
|
||||
label: Text('Busy'),
|
||||
icon: Icon(Icons.circle, color: Colors.orange, size: 12),
|
||||
),
|
||||
ButtonSegment(
|
||||
value: AgentStatusValue.offline,
|
||||
label: Text('Offline'),
|
||||
icon: Icon(Icons.circle, color: Colors.red, size: 12),
|
||||
),
|
||||
],
|
||||
selected: {current},
|
||||
onSelectionChanged: (selection) {
|
||||
agent.updateStatus(selection.first);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
118
mobile/lib/widgets/call_controls.dart
Normal file
118
mobile/lib/widgets/call_controls.dart
Normal file
@@ -0,0 +1,118 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/call_info.dart';
|
||||
|
||||
class CallControls extends StatelessWidget {
|
||||
final CallInfo callInfo;
|
||||
final VoidCallback onMute;
|
||||
final VoidCallback onSpeaker;
|
||||
final VoidCallback onHold;
|
||||
final VoidCallback onDialpad;
|
||||
final VoidCallback onTransfer;
|
||||
final VoidCallback onHangUp;
|
||||
|
||||
const CallControls({
|
||||
super.key,
|
||||
required this.callInfo,
|
||||
required this.onMute,
|
||||
required this.onSpeaker,
|
||||
required this.onHold,
|
||||
required this.onDialpad,
|
||||
required this.onTransfer,
|
||||
required this.onHangUp,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
_ControlButton(
|
||||
icon: callInfo.isMuted ? Icons.mic_off : Icons.mic,
|
||||
label: 'Mute',
|
||||
active: callInfo.isMuted,
|
||||
onTap: onMute,
|
||||
),
|
||||
_ControlButton(
|
||||
icon: callInfo.isSpeakerOn
|
||||
? Icons.volume_up
|
||||
: Icons.volume_down,
|
||||
label: 'Speaker',
|
||||
active: callInfo.isSpeakerOn,
|
||||
onTap: onSpeaker,
|
||||
),
|
||||
_ControlButton(
|
||||
icon: callInfo.isOnHold ? Icons.play_arrow : Icons.pause,
|
||||
label: callInfo.isOnHold ? 'Resume' : 'Hold',
|
||||
active: callInfo.isOnHold,
|
||||
onTap: onHold,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
_ControlButton(
|
||||
icon: Icons.dialpad,
|
||||
label: 'Dialpad',
|
||||
onTap: onDialpad,
|
||||
),
|
||||
_ControlButton(
|
||||
icon: Icons.phone_forwarded,
|
||||
label: 'Transfer',
|
||||
onTap: onTransfer,
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
FloatingActionButton.large(
|
||||
onPressed: onHangUp,
|
||||
backgroundColor: Colors.red,
|
||||
child: const Icon(Icons.call_end, color: Colors.white, size: 36),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ControlButton extends StatelessWidget {
|
||||
final IconData icon;
|
||||
final String label;
|
||||
final bool active;
|
||||
final VoidCallback onTap;
|
||||
|
||||
const _ControlButton({
|
||||
required this.icon,
|
||||
required this.label,
|
||||
this.active = false,
|
||||
required this.onTap,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton.filled(
|
||||
onPressed: onTap,
|
||||
icon: Icon(icon),
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: active
|
||||
? Theme.of(context).colorScheme.primaryContainer
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest,
|
||||
foregroundColor: active
|
||||
? Theme.of(context).colorScheme.primary
|
||||
: Theme.of(context).colorScheme.onSurface,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(label, style: Theme.of(context).textTheme.labelSmall),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
55
mobile/lib/widgets/dialpad.dart
Normal file
55
mobile/lib/widgets/dialpad.dart
Normal file
@@ -0,0 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Dialpad extends StatelessWidget {
|
||||
final void Function(String digit) onDigit;
|
||||
final VoidCallback onClose;
|
||||
|
||||
const Dialpad({super.key, required this.onDigit, required this.onClose});
|
||||
|
||||
static const _keys = [
|
||||
['1', '2', '3'],
|
||||
['4', '5', '6'],
|
||||
['7', '8', '9'],
|
||||
['*', '0', '#'],
|
||||
];
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 48),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
..._keys.map((row) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: row
|
||||
.map((key) => Padding(
|
||||
padding: const EdgeInsets.all(4),
|
||||
child: InkWell(
|
||||
onTap: () => onDigit(key),
|
||||
borderRadius: BorderRadius.circular(40),
|
||||
child: Container(
|
||||
width: 64,
|
||||
height: 64,
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
key,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.headlineSmall,
|
||||
),
|
||||
),
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
)),
|
||||
const SizedBox(height: 8),
|
||||
TextButton(
|
||||
onPressed: onClose,
|
||||
child: const Text('Close'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
37
mobile/lib/widgets/queue_card.dart
Normal file
37
mobile/lib/widgets/queue_card.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/queue_state.dart';
|
||||
|
||||
class QueueCard extends StatelessWidget {
|
||||
final QueueInfo queue;
|
||||
|
||||
const QueueCard({super.key, required this.queue});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: queue.waitingCount > 0
|
||||
? Colors.orange.shade100
|
||||
: Colors.green.shade100,
|
||||
child: Text(
|
||||
'${queue.waitingCount}',
|
||||
style: TextStyle(
|
||||
color: queue.waitingCount > 0 ? Colors.orange : Colors.green,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(queue.name),
|
||||
subtitle: Text(
|
||||
queue.waitingCount > 0
|
||||
? '${queue.waitingCount} waiting'
|
||||
: 'No calls waiting',
|
||||
),
|
||||
trailing: queue.extension != null
|
||||
? Chip(label: Text('Ext ${queue.extension}'))
|
||||
: null,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user