monorepo/dialer/lib/presentation/common/widgets/obfuscated_avatar.dart
AlexisDanlos 664dd4bb38
All checks were successful
/ mirror (push) Successful in 5s
/ build-stealth (push) Successful in 8m55s
/ build (push) Successful in 8m58s
WIP: app rework
2025-03-26 22:27:02 +01:00

54 lines
1.4 KiB
Dart

import 'dart:typed_data';
import 'dart:ui';
import 'package:flutter/material.dart';
import '../../../core/config/app_config.dart';
import '../../../core/utils/color_utils.dart';
class ObfuscatedAvatar extends StatelessWidget {
final Uint8List? imageBytes;
final double radius;
final Color backgroundColor;
final String? fallbackInitial;
const ObfuscatedAvatar({
Key? key,
required this.imageBytes,
this.radius = 25,
this.backgroundColor = Colors.grey,
this.fallbackInitial,
}) : super(key: key);
@override
Widget build(BuildContext context) {
if (imageBytes != null && imageBytes!.isNotEmpty) {
return ClipOval(
child: ImageFiltered(
imageFilter: AppConfig.isStealthMode
? ImageFilter.blur(sigmaX: 10, sigmaY: 10)
: ImageFilter.blur(sigmaX: 0, sigmaY: 0),
child: Image.memory(
imageBytes!,
fit: BoxFit.cover,
width: radius * 2,
height: radius * 2,
),
),
);
} else {
return CircleAvatar(
radius: radius,
backgroundColor: backgroundColor,
child: Text(
fallbackInitial != null && fallbackInitial!.isNotEmpty
? fallbackInitial![0].toUpperCase()
: '?',
style: TextStyle(
color: darken(backgroundColor),
fontSize: radius,
),
),
);
}
}
}