calling number
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:krow_data_connect/krow_data_connect.dart' as dc;
|
||||
import 'package:krow_domain/krow_domain.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import '../blocs/view_orders_cubit.dart';
|
||||
|
||||
/// A rich card displaying details of a client order/shift.
|
||||
@@ -484,6 +485,7 @@ class _ViewOrderCardState extends State<ViewOrderCard> {
|
||||
|
||||
/// Builds a detailed row for a worker.
|
||||
Widget _buildWorkerRow(Map<String, dynamic> app) {
|
||||
final String? phone = app['phone'] as String?;
|
||||
return Container(
|
||||
margin: const EdgeInsets.only(bottom: 12),
|
||||
padding: const EdgeInsets.all(12),
|
||||
@@ -551,14 +553,46 @@ class _ViewOrderCardState extends State<ViewOrderCard> {
|
||||
],
|
||||
),
|
||||
),
|
||||
if ((app['phone'] as String?)?.isNotEmpty ?? false) ...<Widget>[
|
||||
_buildActionIconButton(icon: UiIcons.phone, onTap: () {}),
|
||||
if (phone != null && phone.isNotEmpty) ...<Widget>[
|
||||
_buildActionIconButton(
|
||||
icon: UiIcons.phone,
|
||||
onTap: () => _confirmAndCall(phone),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _confirmAndCall(String phone) async {
|
||||
final bool? shouldCall = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: const Text('Call'),
|
||||
content: Text('Do you want to call $phone?'),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: const Text('Call'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (shouldCall != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
final Uri uri = Uri(scheme: 'tel', path: phone);
|
||||
await launchUrl(uri);
|
||||
}
|
||||
|
||||
/// Specialized action button for worker rows.
|
||||
Widget _buildActionIconButton({
|
||||
required IconData icon,
|
||||
|
||||
Reference in New Issue
Block a user