2023-08-05 01:00:46 -04:00
|
|
|
import 'package:awesome_extensions/awesome_extensions.dart';
|
2023-08-04 01:00:38 -04:00
|
|
|
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
|
|
|
2023-09-26 18:46:02 -04:00
|
|
|
import '../proto/proto.dart' as proto;
|
2023-08-04 01:00:38 -04:00
|
|
|
import '../tools/tools.dart';
|
|
|
|
import 'contact_invitation_item_widget.dart';
|
|
|
|
|
2023-08-05 01:00:46 -04:00
|
|
|
class ContactInvitationListWidget extends ConsumerStatefulWidget {
|
2023-09-26 18:46:02 -04:00
|
|
|
const ContactInvitationListWidget({
|
2023-08-05 01:00:46 -04:00
|
|
|
required this.contactInvitationRecordList,
|
|
|
|
super.key,
|
|
|
|
});
|
|
|
|
|
2023-08-04 01:00:38 -04:00
|
|
|
final IList<proto.ContactInvitationRecord> contactInvitationRecordList;
|
|
|
|
|
2023-08-05 01:00:46 -04:00
|
|
|
@override
|
|
|
|
ContactInvitationListWidgetState createState() =>
|
|
|
|
ContactInvitationListWidgetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class ContactInvitationListWidgetState
|
|
|
|
extends ConsumerState<ContactInvitationListWidget> {
|
|
|
|
final ScrollController _scrollController = ScrollController();
|
|
|
|
|
2023-08-04 01:00:38 -04:00
|
|
|
@override
|
|
|
|
// ignore: prefer_expression_function_bodies
|
2023-08-05 01:00:46 -04:00
|
|
|
Widget build(BuildContext context) {
|
2023-08-04 01:00:38 -04:00
|
|
|
final theme = Theme.of(context);
|
2023-08-05 01:00:46 -04:00
|
|
|
//final textTheme = theme.textTheme;
|
|
|
|
final scale = theme.extension<ScaleScheme>()!;
|
2023-08-04 01:00:38 -04:00
|
|
|
|
|
|
|
return Container(
|
2023-08-05 01:00:46 -04:00
|
|
|
width: double.infinity,
|
2023-09-24 15:30:54 -04:00
|
|
|
margin: const EdgeInsets.fromLTRB(4, 0, 4, 4),
|
2023-09-23 12:56:54 -04:00
|
|
|
decoration: ShapeDecoration(
|
|
|
|
shape: RoundedRectangleBorder(
|
2023-09-24 15:30:54 -04:00
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
)),
|
2023-09-23 12:56:54 -04:00
|
|
|
constraints: const BoxConstraints(maxHeight: 200),
|
2023-08-04 01:00:38 -04:00
|
|
|
child: Column(
|
2023-09-23 12:56:54 -04:00
|
|
|
mainAxisSize: MainAxisSize.min,
|
2023-08-04 01:00:38 -04:00
|
|
|
children: [
|
2023-08-05 01:00:46 -04:00
|
|
|
Container(
|
|
|
|
width: double.infinity,
|
|
|
|
decoration: ShapeDecoration(
|
2023-09-23 12:56:54 -04:00
|
|
|
color: scale.primaryScale.subtleBackground,
|
2023-08-05 01:00:46 -04:00
|
|
|
shape: RoundedRectangleBorder(
|
2023-09-24 15:30:54 -04:00
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
)),
|
2023-08-05 01:00:46 -04:00
|
|
|
child: ListView.builder(
|
|
|
|
controller: _scrollController,
|
|
|
|
itemCount: widget.contactInvitationRecordList.length,
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
if (index < 0 ||
|
|
|
|
index >= widget.contactInvitationRecordList.length) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return ContactInvitationItemWidget(
|
|
|
|
contactInvitationRecord:
|
|
|
|
widget.contactInvitationRecordList[index],
|
|
|
|
key: ObjectKey(
|
|
|
|
widget.contactInvitationRecordList[index]))
|
|
|
|
.paddingAll(2);
|
|
|
|
},
|
|
|
|
findChildIndexCallback: (key) {
|
|
|
|
final index = widget.contactInvitationRecordList.indexOf(
|
|
|
|
(key as ObjectKey).value!
|
|
|
|
as proto.ContactInvitationRecord);
|
|
|
|
if (index == -1) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return index;
|
|
|
|
},
|
|
|
|
shrinkWrap: true,
|
2023-09-24 15:30:54 -04:00
|
|
|
).paddingLTRB(0, 0, 0, 4))
|
2023-08-04 01:00:38 -04:00
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|