Skip to content

Commit 54b83ad

Browse files
committed
feat: add call capability configuration to DialogInfo
1 parent b1807e7 commit 54b83ad

2 files changed

Lines changed: 39 additions & 17 deletions

File tree

lib/features/messaging/features/chat_conversation/view/conversation_screen.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ class _ChatConversationScreenState extends State<ChatConversationScreen> {
4040
value: conversationCubit,
4141
child: ClipRRect(
4242
borderRadius: const BorderRadius.vertical(top: Radius.circular(16)),
43-
child: DialogInfo(userId, state.credentials.participantId!),
43+
child: DialogInfo(
44+
userId,
45+
state.credentials.participantId!,
46+
isAudioCallEnabled: true,
47+
isVideoCallEnabled: messagingBloc.state.messagingConfig.contactInfoVideoCallSupport,
48+
),
4449
),
4550
),
4651
);

lib/features/messaging/features/chat_conversation/widgets/dialog_info.dart

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,25 @@ import 'package:flutter/material.dart';
44

55
import 'package:flutter_bloc/flutter_bloc.dart';
66

7+
import 'package:webtrit_phone/app/notifications/notifications.dart';
78
import 'package:webtrit_phone/features/features.dart';
89
import 'package:webtrit_phone/l10n/l10n.dart';
910
import 'package:webtrit_phone/models/models.dart';
10-
import 'package:webtrit_phone/app/notifications/notifications.dart';
1111
import 'package:webtrit_phone/widgets/widgets.dart' hide ConfirmDialog;
1212

1313
class DialogInfo extends StatefulWidget {
14-
const DialogInfo(this.userId, this.participantId, {super.key});
14+
const DialogInfo(
15+
this.userId,
16+
this.participantId, {
17+
required this.isAudioCallEnabled,
18+
required this.isVideoCallEnabled,
19+
super.key,
20+
});
1521

1622
final String userId;
1723
final String participantId;
24+
final bool isAudioCallEnabled;
25+
final bool isVideoCallEnabled;
1826

1927
@override
2028
State<DialogInfo> createState() => _DialogInfoState();
@@ -110,31 +118,22 @@ class _DialogInfoState extends State<DialogInfo> {
110118
),
111119
const SizedBox(height: 24),
112120
if (contact != null && contact.kind == ContactKind.visible) ...[
113-
Divider(),
121+
const Divider(),
114122
Expanded(
115123
child: ListView(
116124
children: [
117125
for (ContactPhone contactPhone in contact.phones)
118126
ListTile(
127+
contentPadding: EdgeInsets.zero,
119128
title: Text(contactPhone.number),
120129
trailing: Row(
121130
mainAxisSize: MainAxisSize.min,
122-
children: [
123-
IconButton(
124-
splashRadius: 24,
125-
icon: const Icon(Icons.call),
126-
onPressed: () => _onCall(contactPhone, contact, false),
127-
),
128-
IconButton(
129-
splashRadius: 24,
130-
icon: const Icon(Icons.videocam),
131-
onPressed: () => _onCall(contactPhone, contact, true),
132-
),
133-
],
131+
children: _buildCallActions(contactPhone, contact),
134132
),
135133
),
136134
for (ContactEmail contactEmail in contact.emails)
137135
ListTile(
136+
contentPadding: EdgeInsets.zero,
138137
title: Text(contactEmail.address),
139138
trailing: IconButton(
140139
splashRadius: 24,
@@ -147,7 +146,7 @@ class _DialogInfoState extends State<DialogInfo> {
147146
),
148147
const SizedBox(height: 8),
149148
] else
150-
Spacer(),
149+
const Spacer(),
151150
],
152151
),
153152
);
@@ -170,4 +169,22 @@ class _DialogInfoState extends State<DialogInfo> {
170169
},
171170
);
172171
}
172+
173+
/// Returns a list of call action buttons based on provided configuration.
174+
List<Widget> _buildCallActions(ContactPhone contactPhone, Contact contact) {
175+
return [
176+
if (widget.isAudioCallEnabled)
177+
IconButton(
178+
splashRadius: 24,
179+
icon: const Icon(Icons.call),
180+
onPressed: () => _onCall(contactPhone, contact, false),
181+
),
182+
if (widget.isVideoCallEnabled)
183+
IconButton(
184+
splashRadius: 24,
185+
icon: const Icon(Icons.videocam),
186+
onPressed: () => _onCall(contactPhone, contact, true),
187+
),
188+
];
189+
}
173190
}

0 commit comments

Comments
 (0)