OpenContacts/lib/widgets/user_list_tile.dart

36 lines
1.1 KiB
Dart
Raw Normal View History

2023-05-01 13:13:40 -04:00
import 'package:contacts_plus_plus/models/user.dart';
import 'package:contacts_plus_plus/widgets/generic_avatar.dart';
2023-04-30 09:43:59 -04:00
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
class UserListTile extends StatefulWidget {
const UserListTile({required this.user, super.key});
final User user;
@override
State<UserListTile> createState() => _UserListTileState();
}
class _UserListTileState extends State<UserListTile> {
final DateFormat _regDateFormat = DateFormat.yMMMMd('en_US');
late bool _localAdded = widget.user.userProfile != null;
@override
Widget build(BuildContext context) {
return ListTile(
2023-04-30 17:14:29 -04:00
leading: GenericAvatar(imageUri: widget.user.userProfile?.iconUrl ?? "",),
2023-04-30 09:43:59 -04:00
title: Text(widget.user.username),
subtitle: Text(_regDateFormat.format(widget.user.registrationDate)),
trailing: IconButton(
onPressed: () {
setState(() {
_localAdded = !_localAdded;
});
},
2023-04-30 17:14:29 -04:00
splashRadius: 24,
2023-04-30 09:43:59 -04:00
icon: _localAdded ? const Icon(Icons.person_remove_alt_1) : const Icon(Icons.person_add_alt_1),
),
);
}
}