added support for multiple accounts, guardian login bugfixes, ui changes
This commit is contained in:
@@ -10,6 +10,7 @@ import 'async_action_button.dart';
|
||||
import 'centered_leading.dart';
|
||||
import 'details_bottom_sheet.dart';
|
||||
import 'placeholder_view.dart';
|
||||
import 'user_avatar.dart';
|
||||
|
||||
/// AppBar action that shows the selected child and lets a guardian switch to
|
||||
/// another one. Invisible unless there is a choice to make.
|
||||
@@ -63,7 +64,7 @@ class ChildTile extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ListTile(
|
||||
leading: const CenteredLeading(Icon(Icons.face_outlined)),
|
||||
leading: CenteredLeading(ChildAvatar(child: child)),
|
||||
title: Text(child.displayName),
|
||||
subtitle: child.className.isEmpty
|
||||
? null
|
||||
@@ -73,6 +74,38 @@ class ChildTile extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// Profile picture of a linked child, or its initials while the server does
|
||||
/// not name the child's account.
|
||||
class ChildAvatar extends StatelessWidget {
|
||||
final GuardianChild child;
|
||||
final int size;
|
||||
|
||||
const ChildAvatar({required this.child, this.size = 20, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final username = child.username;
|
||||
if (username != null && username.isNotEmpty) {
|
||||
return UserAvatar(
|
||||
id: username,
|
||||
size: size,
|
||||
semanticLabel: child.displayName,
|
||||
);
|
||||
}
|
||||
final colors = Theme.of(context).colorScheme;
|
||||
final initials = [child.firstName, child.lastName]
|
||||
.where((part) => part.isNotEmpty)
|
||||
.map((part) => part.characters.first.toUpperCase())
|
||||
.join();
|
||||
return CircleAvatar(
|
||||
radius: size.toDouble(),
|
||||
backgroundColor: colors.secondaryContainer,
|
||||
foregroundColor: colors.onSecondaryContainer,
|
||||
child: Text(initials, style: TextStyle(fontSize: size * 0.7)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Shown by per-child modules while a guardian has no linked child. The
|
||||
/// children come from `me/capabilities`, so a failed or pending load must not
|
||||
/// be presented as "no child assigned" — that sends parents to the secretariat
|
||||
|
||||
Reference in New Issue
Block a user