132 lines
3.9 KiB
Dart
132 lines
3.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:onufitness/constants/color_constant.dart';
|
|
import 'package:onufitness/constants/text_constant.dart';
|
|
|
|
class ExclusiveConnectionTile extends StatelessWidget {
|
|
final String name;
|
|
final String type;
|
|
final int? members;
|
|
final String imageUrl;
|
|
final bool isSelected;
|
|
final VoidCallback onTap;
|
|
final bool isLocked;
|
|
const ExclusiveConnectionTile({
|
|
required this.name,
|
|
required this.type,
|
|
this.members,
|
|
required this.imageUrl,
|
|
required this.isSelected,
|
|
required this.onTap,
|
|
this.isLocked = false,
|
|
super.key,
|
|
});
|
|
|
|
Widget _buildProfileImage({
|
|
required double radius,
|
|
required double iconSize,
|
|
}) {
|
|
if (imageUrl.isEmpty) {
|
|
return CircleAvatar(
|
|
radius: radius,
|
|
backgroundColor: Colors.grey[300],
|
|
child: Icon(
|
|
Icons.person,
|
|
size: iconSize,
|
|
color: type == 'group' ? Color(darkGreyColor) : Colors.grey[600],
|
|
),
|
|
);
|
|
}
|
|
|
|
return CircleAvatar(
|
|
radius: radius,
|
|
backgroundColor: Colors.grey[300],
|
|
child: ClipOval(
|
|
child: Image.network(
|
|
imageUrl,
|
|
width: radius * 1.5,
|
|
height: radius * 1.5,
|
|
fit: BoxFit.cover,
|
|
loadingBuilder: (context, child, loadingProgress) {
|
|
if (loadingProgress == null) {
|
|
return child;
|
|
}
|
|
return SizedBox(
|
|
width: radius * 1.5,
|
|
height: radius * 1.5,
|
|
child: Center(
|
|
child: CircularProgressIndicator(
|
|
strokeWidth: 2.0,
|
|
color: Colors.grey[600],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
errorBuilder: (context, error, stackTrace) {
|
|
return Icon(
|
|
Icons.person,
|
|
size: iconSize,
|
|
color: type == 'group' ? Color(darkGreyColor) : Colors.grey[600],
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ListTile(
|
|
onTap: onTap,
|
|
contentPadding: EdgeInsets.symmetric(vertical: 4.h, horizontal: 8.w),
|
|
leading:
|
|
type == 'group'
|
|
? Stack(
|
|
clipBehavior: Clip.none,
|
|
children: [
|
|
// Admin profile picture
|
|
_buildProfileImage(radius: 30.r, iconSize: 25.sp),
|
|
// +N badge
|
|
Positioned(
|
|
right: -2.w,
|
|
bottom: -2.h,
|
|
child: Container(
|
|
padding: EdgeInsets.symmetric(
|
|
horizontal: 4.w,
|
|
vertical: 4.h,
|
|
),
|
|
decoration: BoxDecoration(
|
|
color: Color(primaryColor),
|
|
borderRadius: BorderRadius.circular(20.r),
|
|
border: Border.all(color: Colors.white, width: 2),
|
|
),
|
|
child: Icon(Icons.group, size: 15.sp),
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: _buildProfileImage(radius: 30.r, iconSize: 30.sp),
|
|
title: Text(
|
|
name,
|
|
style: TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500),
|
|
),
|
|
subtitle:
|
|
type == 'group'
|
|
? Text(
|
|
'${members ?? 0} members',
|
|
style: TextStyle(
|
|
fontSize: verySmallSizeText,
|
|
color: Colors.grey,
|
|
),
|
|
)
|
|
: null,
|
|
trailing:
|
|
isLocked
|
|
? const Icon(Icons.check_circle, color: Colors.grey)
|
|
: isSelected
|
|
? const Icon(Icons.check_circle, color: Colors.black)
|
|
: const Icon(Icons.radio_button_unchecked, color: Colors.grey),
|
|
);
|
|
}
|
|
}
|