2024-04-30 19:25:16 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class UserTile extends StatelessWidget {
|
2024-06-04 20:12:12 +02:00
|
|
|
final String text;
|
2024-06-02 18:58:43 +02:00
|
|
|
final String? profileImageUrl;
|
2024-04-30 19:25:16 +02:00
|
|
|
final void Function()? onTap;
|
|
|
|
|
2024-06-02 18:58:43 +02:00
|
|
|
const UserTile({
|
|
|
|
super.key,
|
2024-06-04 20:12:12 +02:00
|
|
|
required this.text,
|
2024-06-02 18:58:43 +02:00
|
|
|
this.profileImageUrl,
|
|
|
|
required this.onTap,
|
|
|
|
});
|
2024-04-30 19:25:16 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return GestureDetector(
|
|
|
|
onTap: onTap,
|
|
|
|
child: Container(
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
),
|
|
|
|
margin: const EdgeInsets.symmetric(vertical: 5, horizontal: 25),
|
2024-06-04 20:12:12 +02:00
|
|
|
padding: const EdgeInsets.all(20),
|
2024-04-30 19:25:16 +02:00
|
|
|
child: Row(
|
|
|
|
children: [
|
2024-06-04 20:12:12 +02:00
|
|
|
// Profile image
|
|
|
|
if (profileImageUrl != null && profileImageUrl!.isNotEmpty)
|
|
|
|
CircleAvatar(
|
|
|
|
backgroundImage: NetworkImage(profileImageUrl!),
|
|
|
|
radius: 24,
|
|
|
|
),
|
|
|
|
// Icon if profile image is not set
|
|
|
|
if (profileImageUrl == null || profileImageUrl!.isEmpty)
|
|
|
|
const Icon(Icons.person),
|
|
|
|
|
|
|
|
const SizedBox(width: 20),
|
|
|
|
|
|
|
|
// user name
|
|
|
|
Text(text),
|
2024-04-30 19:25:16 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|