G-EIP-700-TLS-7-1-eip-steph.../lib/pages/contact.dart

42 lines
1.1 KiB
Dart
Raw Normal View History

2024-10-25 11:26:44 +00:00
// contact.dart
2024-09-16 15:07:04 +00:00
import 'package:flutter/material.dart';
import 'package:dialer/classes/contactClass.dart';
import 'package:dialer/classes/displayContact.dart';
class ContactPage extends StatefulWidget {
const ContactPage({super.key});
@override
_ContactPageState createState() => _ContactPageState();
}
2024-10-25 11:26:44 +00:00
2024-09-16 15:07:04 +00:00
class _ContactPageState extends State<ContactPage> {
@override
Widget build(BuildContext context) {
2024-10-25 11:26:44 +00:00
// Optionally sort contacts alphabetically
final sortedContacts = [...contacts]..sort((a, b) => a.name.compareTo(b.name));
2024-09-16 15:07:04 +00:00
return Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
title: const Text('Contacts'),
),
body: ListView.builder(
2024-10-25 11:26:44 +00:00
itemCount: sortedContacts.length,
2024-09-16 15:07:04 +00:00
itemBuilder: (context, index) {
2024-10-25 11:26:44 +00:00
return DisplayContact(contact: sortedContacts[index]);
2024-09-16 15:07:04 +00:00
},
),
);
}
}
2024-10-25 11:26:44 +00:00
2024-09-16 15:07:04 +00:00
List<Contact> contacts = [
2024-10-25 11:26:44 +00:00
Contact('Alice', '1234567890'),
Contact('Bob', '0987654321', isFavorite: true, isLocked: true, publicKey: 'AB...YZ'),
Contact('Charlie', '5555555555', isLocked: true),
2024-09-16 15:07:04 +00:00
];