Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Cover fixed avatar color roles

Neeraj Guptab5b2662a2e80
diff --git a/mobile/apps/photos/lib/utils/avatar_util.dart b/mobile/apps/photos/lib/utils/avatar_util.dart
index 134dd97be6..efd88f276b 100644
--- a/mobile/apps/photos/lib/utils/avatar_util.dart
+++ b/mobile/apps/photos/lib/utils/avatar_util.dart
@@ -1,7 +1,15 @@
import "package:ente_components/ente_components.dart";
import "package:flutter/material.dart";
-enum AvatarIdentityRole { standard, currentUser, publicUploader }
+enum AvatarIdentityRole {
+ standard,
+
+ /// Kept black across themes to preserve the established "me" treatment.
+ currentUser,
+
+ /// A non-user uploading through a public Collect link.
+ publicUploader,
+}
class AvatarIdentity {
AvatarIdentity({
diff --git a/mobile/apps/photos/test/utils/avatar_util_test.dart b/mobile/apps/photos/test/utils/avatar_util_test.dart
index 1bdfb2aa6d..55fb8fb253 100644
--- a/mobile/apps/photos/test/utils/avatar_util_test.dart
+++ b/mobile/apps/photos/test/utils/avatar_util_test.dart
@@ -1,3 +1,5 @@
+import "package:ente_components/ente_components.dart";
+import "package:flutter/material.dart";
import "package:flutter_test/flutter_test.dart";
import "package:photos/utils/avatar_util.dart";
@@ -66,4 +68,33 @@ void main() {
expect(identity.role, AvatarIdentityRole.standard);
expect(identity.key, "person:person-1");
});
+
+ testWidgets("semantic avatar roles stay black across themes", (tester) async {
+ for (final theme in [
+ ComponentTheme.lightTheme(),
+ ComponentTheme.darkTheme(),
+ ]) {
+ for (final role in [
+ AvatarIdentityRole.currentUser,
+ AvatarIdentityRole.publicUploader,
+ ]) {
+ late Color backgroundColor;
+ await tester.pumpWidget(
+ MaterialApp(
+ theme: theme,
+ home: Builder(
+ builder: (context) {
+ backgroundColor = avatarBackgroundColor(
+ context,
+ AvatarIdentity(label: "A", role: role),
+ );
+ return const SizedBox.shrink();
+ },
+ ),
+ ),
+ );
+ expect(backgroundColor, Colors.black);
+ }
+ }
+ });
}
diff --git a/mobile/packages/ente_components/test/components/avatar_test.dart b/mobile/packages/ente_components/test/components/avatar_test.dart
index 7a429bbe74..8600616897 100644
--- a/mobile/packages/ente_components/test/components/avatar_test.dart
+++ b/mobile/packages/ente_components/test/components/avatar_test.dart
@@ -85,6 +85,12 @@ void main() {
.first,
);
expect((cyanAvatar.decoration as BoxDecoration).color, avatarCyan);
+ final blackAvatar = tester.widget<DecoratedBox>(
+ find
+ .ancestor(of: find.text('P'), matching: find.byType(DecoratedBox))
+ .first,
+ );
+ expect((blackAvatar.decoration as BoxDecoration).color, Colors.black);
},
);