2023-08-05 01:00:46 -04:00
|
|
|
import 'package:flutter/foundation.dart';
|
2023-08-04 01:00:38 -04:00
|
|
|
import 'package:flutter/material.dart';
|
2024-01-29 22:38:19 -05:00
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2023-08-04 01:00:38 -04:00
|
|
|
import 'package:flutter_translate/flutter_translate.dart';
|
2024-01-09 20:58:27 -05:00
|
|
|
import '../../proto/proto.dart' as proto;
|
|
|
|
import '../../theme/theme.dart';
|
2024-01-29 22:38:19 -05:00
|
|
|
import '../contact_invitation.dart';
|
2023-08-04 01:00:38 -04:00
|
|
|
|
2024-01-09 20:58:27 -05:00
|
|
|
class ContactInvitationItemWidget extends StatelessWidget {
|
2023-08-04 01:00:38 -04:00
|
|
|
const ContactInvitationItemWidget(
|
2024-02-27 12:45:58 -05:00
|
|
|
{required this.contactInvitationRecord,
|
|
|
|
required this.disabled,
|
|
|
|
super.key});
|
2023-08-04 01:00:38 -04:00
|
|
|
|
|
|
|
final proto.ContactInvitationRecord contactInvitationRecord;
|
2024-02-27 12:45:58 -05:00
|
|
|
final bool disabled;
|
2023-08-04 01:00:38 -04:00
|
|
|
|
2023-08-05 01:00:46 -04:00
|
|
|
@override
|
|
|
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
|
|
|
super.debugFillProperties(properties);
|
2024-02-27 12:45:58 -05:00
|
|
|
properties
|
|
|
|
..add(DiagnosticsProperty<proto.ContactInvitationRecord>(
|
|
|
|
'contactInvitationRecord', contactInvitationRecord))
|
|
|
|
..add(DiagnosticsProperty<bool>('disabled', disabled));
|
2023-08-05 01:00:46 -04:00
|
|
|
}
|
|
|
|
|
2023-08-04 01:00:38 -04:00
|
|
|
@override
|
|
|
|
// ignore: prefer_expression_function_bodies
|
2024-01-09 20:58:27 -05:00
|
|
|
Widget build(BuildContext context) {
|
2024-05-27 18:04:00 -04:00
|
|
|
// final localConversationKey =
|
|
|
|
// contact.localConversationRecordKey.toVeilid();
|
2023-08-04 01:00:38 -04:00
|
|
|
|
2024-04-12 20:55:05 -04:00
|
|
|
const selected =
|
|
|
|
false; // xxx: eventually when we have selectable invitations:
|
2024-05-27 18:04:00 -04:00
|
|
|
// activeContactCubit.state == localConversationRecordKey;
|
2023-08-04 01:00:38 -04:00
|
|
|
|
2024-04-12 20:55:05 -04:00
|
|
|
final tileDisabled =
|
|
|
|
disabled || context.watch<ContactInvitationListCubit>().isBusy;
|
2023-08-05 01:00:46 -04:00
|
|
|
|
2024-04-12 20:55:05 -04:00
|
|
|
return SliderTile(
|
|
|
|
key: ObjectKey(contactInvitationRecord),
|
|
|
|
disabled: tileDisabled,
|
|
|
|
selected: selected,
|
|
|
|
tileScale: ScaleKind.primary,
|
|
|
|
title: contactInvitationRecord.message.isEmpty
|
|
|
|
? translate('contact_list.invitation')
|
|
|
|
: contactInvitationRecord.message,
|
|
|
|
icon: Icons.person_add,
|
|
|
|
onTap: () async {
|
|
|
|
if (!context.mounted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
await ContactInvitationDisplayDialog.show(
|
|
|
|
context: context,
|
|
|
|
message: contactInvitationRecord.message,
|
|
|
|
create: (context) => InvitationGeneratorCubit.value(
|
|
|
|
Uint8List.fromList(contactInvitationRecord.invitation)));
|
|
|
|
},
|
|
|
|
endActions: [
|
|
|
|
SliderTileAction(
|
|
|
|
icon: Icons.delete,
|
|
|
|
label: translate('button.delete'),
|
|
|
|
actionScale: ScaleKind.tertiary,
|
|
|
|
onPressed: (context) async {
|
|
|
|
final contactInvitationListCubit =
|
|
|
|
context.read<ContactInvitationListCubit>();
|
|
|
|
await contactInvitationListCubit.deleteInvitation(
|
|
|
|
accepted: false,
|
|
|
|
contactRequestInboxRecordKey: contactInvitationRecord
|
|
|
|
.contactRequestInbox.recordKey
|
|
|
|
.toVeilid());
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
);
|
2023-08-04 01:00:38 -04:00
|
|
|
}
|
|
|
|
}
|