mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-11 08:08:00 -06:00
feat: rework account management page, add tooltip to settings
This commit is contained in:
28
lib/features/settings/view/widgets/user_avatar.dart
Normal file
28
lib/features/settings/view/widgets/user_avatar.dart
Normal file
@@ -0,0 +1,28 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:paperless_mobile/features/login/model/user_account.dart';
|
||||
|
||||
class UserAvatar extends StatelessWidget {
|
||||
final String userId;
|
||||
final UserAccount account;
|
||||
const UserAvatar({
|
||||
super.key,
|
||||
required this.userId,
|
||||
required this.account,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final backgroundColor = Colors.primaries[userId.hashCode % Colors.primaries.length];
|
||||
final foregroundColor = backgroundColor.computeLuminance() > 0.5 ? Colors.black : Colors.white;
|
||||
return CircleAvatar(
|
||||
child: Text((account.fullName ?? account.username)
|
||||
.split(" ")
|
||||
.take(2)
|
||||
.map((e) => e.substring(0, 1))
|
||||
.map((e) => e.toUpperCase())
|
||||
.join("")),
|
||||
backgroundColor: backgroundColor,
|
||||
foregroundColor: foregroundColor,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user