veilidchat/lib/components/contact_invitation_list_widget.dart

78 lines
2.8 KiB
Dart
Raw Normal View History

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';
import '../../entities/proto.dart' as proto;
import '../tools/tools.dart';
import 'contact_invitation_item_widget.dart';
2023-08-05 01:00:46 -04:00
class ContactInvitationListWidget extends ConsumerStatefulWidget {
ContactInvitationListWidget({
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,
constraints: const BoxConstraints(minHeight: 64, maxHeight: 200),
2023-08-04 01:00:38 -04:00
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
2023-08-05 01:00:46 -04:00
Container(
width: double.infinity,
decoration: ShapeDecoration(
color: scale.grayScale.appBackground,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
)),
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,
)).paddingLTRB(8, 0, 8, 8).flexible()
2023-08-04 01:00:38 -04:00
],
),
);
}
}