feat(proj): init
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
import 'package:please_pay_me/theme/tokens.dart';
|
||||
|
||||
/// Circular avatar — image, initials, or the iOS person placeholder.
|
||||
class AppAvatar extends StatelessWidget {
|
||||
const AppAvatar({
|
||||
super.key,
|
||||
this.imageUrl,
|
||||
this.initials,
|
||||
this.radius = 22,
|
||||
this.backgroundColor = AppColors.systemGray5,
|
||||
});
|
||||
|
||||
final String? imageUrl;
|
||||
final String? initials;
|
||||
final double radius;
|
||||
final Color backgroundColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final size = radius * 2;
|
||||
final hasImage = imageUrl != null && imageUrl!.isNotEmpty;
|
||||
|
||||
return ClipOval(
|
||||
child: Container(
|
||||
width: size,
|
||||
height: size,
|
||||
color: AppColors.of(context, backgroundColor),
|
||||
alignment: Alignment.center,
|
||||
child: hasImage
|
||||
? Image.network(imageUrl!, width: size, height: size, fit: BoxFit.cover)
|
||||
: initials != null && initials!.isNotEmpty
|
||||
? Text(
|
||||
initials!.toUpperCase(),
|
||||
style: GoogleFonts.inter(
|
||||
textStyle: AppTypography.headline.copyWith(fontSize: radius * 0.8),
|
||||
color: AppColors.of(context, AppColors.secondaryLabel),
|
||||
),
|
||||
)
|
||||
: Icon(
|
||||
CupertinoIcons.person_fill,
|
||||
size: radius,
|
||||
color: AppColors.of(context, AppColors.systemGray),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user