π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Invert selected filter chip colors
ashilkn6422c8f4f9a1
diff --git a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/chip_widgets/only_them_filter_chip.dart b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/chip_widgets/only_them_filter_chip.dartindex c0eea393f1..8233007786 100644--- a/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/chip_widgets/only_them_filter_chip.dart+++ b/mobile/apps/photos/lib/ui/viewer/hierarchicial_search/chip_widgets/only_them_filter_chip.dart@@ -4,6 +4,8 @@ import "package:photos/generated/l10n.dart";import "package:photos/models/search/hierarchical/face_filter.dart";import "package:photos/ui/viewer/people/person_face_widget.dart";+const _innerFaceRadius = Radius.circular(3);+class OnlyThemFilterChip extends StatelessWidget {final List<FaceFilter> faceFilters;final VoidCallback apply;@@ -111,7 +113,7 @@ class _OnlyThemFilterThumbnail extends StatelessWidget {height: size / 2 - 0.5,child: ClipRRect(borderRadius: const BorderRadius.only(- bottomLeft: Radius.circular(1),+ bottomLeft: _innerFaceRadius,),child: PersonFaceWidget(personId: faceFilters[1].personId,@@ -126,7 +128,7 @@ class _OnlyThemFilterThumbnail extends StatelessWidget {height: size / 2 - 0.5,child: ClipRRect(borderRadius: const BorderRadius.only(- topLeft: Radius.circular(1),+ topLeft: _innerFaceRadius,),child: PersonFaceWidget(personId: faceFilters[2].personId,@@ -153,7 +155,7 @@ class _OnlyThemFilterThumbnail extends StatelessWidget {height: size / 2 - 0.5,child: ClipRRect(borderRadius: const BorderRadius.only(- bottomRight: Radius.circular(1),+ bottomRight: _innerFaceRadius,),child: PersonFaceWidget(personId: faceFilters[0].personId,@@ -168,7 +170,7 @@ class _OnlyThemFilterThumbnail extends StatelessWidget {height: size / 2 - 0.5,child: ClipRRect(borderRadius: const BorderRadius.only(- bottomLeft: Radius.circular(1),+ bottomLeft: _innerFaceRadius,),child: PersonFaceWidget(personId: faceFilters[1].personId,@@ -188,7 +190,7 @@ class _OnlyThemFilterThumbnail extends StatelessWidget {height: size / 2 - 0.5,child: ClipRRect(borderRadius: const BorderRadius.only(- topRight: Radius.circular(1),+ topRight: _innerFaceRadius,),child: PersonFaceWidget(personId: faceFilters[2].personId,@@ -203,7 +205,7 @@ class _OnlyThemFilterThumbnail extends StatelessWidget {height: size / 2 - 0.5,child: ClipRRect(borderRadius: const BorderRadius.only(- topLeft: Radius.circular(1),+ topLeft: _innerFaceRadius,),child: PersonFaceWidget(personId: faceFilters[3].personId,diff --git a/mobile/packages/ente_components/lib/components/filter_chip_component.dart b/mobile/packages/ente_components/lib/components/filter_chip_component.dartindex 4e1ec7d7ee..0e208a0f2e 100644--- a/mobile/packages/ente_components/lib/components/filter_chip_component.dart+++ b/mobile/packages/ente_components/lib/components/filter_chip_component.dart@@ -1,6 +1,7 @@import 'dart:math' as math;import 'package:ente_components/components/chip_surface.dart';+import 'package:ente_components/theme/colors.dart';import 'package:ente_components/theme/icon_sizes.dart';import 'package:ente_components/theme/spacing.dart';import 'package:ente_components/theme/text_styles.dart';@@ -69,11 +70,13 @@ class FilterChipComponent extends StatelessWidget {Widget build(BuildContext context) {final colors = context.componentColors;final textColor = switch (state) {- FilterChipComponentState.selected => colors.primary,+ FilterChipComponentState.selected => colors.textReverse,FilterChipComponentState.unselected => colors.textLight,FilterChipComponentState.disabled => colors.textLightest,};- final background = _selected ? colors.primaryLight : colors.fillLight;+ final background = _selected+ ? _inverseBackgroundBase(context)+ : colors.fillLight;final effectiveAvatarSize = _avatarSizeFor(context);final textScaledHeight = heightForTextScale(context);final effectiveChipHeight = avatar == null@@ -103,6 +106,12 @@ class FilterChipComponent extends StatelessWidget {);}+ Color _inverseBackgroundBase(BuildContext context) {+ return Theme.of(context).brightness == Brightness.dark+ ? ColorTokens.light.backgroundBase+ : ColorTokens.dark.backgroundBase;+ }+List<Widget> _children(double effectiveAvatarSize, Color color) {final children = <Widget>[];final gap = avatar != null ? Spacing.xs : Spacing.sm;diff --git a/mobile/packages/ente_components/test/components/selection_controls_test.dart b/mobile/packages/ente_components/test/components/selection_controls_test.dartindex 406bfe413a..0a983bba74 100644--- a/mobile/packages/ente_components/test/components/selection_controls_test.dart+++ b/mobile/packages/ente_components/test/components/selection_controls_test.dart@@ -249,8 +249,32 @@ void main() {final label = tester.widget<Text>(find.text("Faces"));expect(tester.getSize(surfaceFinder).height, 40);- expect(decoration.color, ColorTokens.light.primaryLight);- expect(label.style?.color, ColorTokens.light.primary);+ expect(decoration.color, ColorTokens.dark.backgroundBase);+ expect(label.style?.color, ColorTokens.light.textReverse);+ expect(find.byIcon(Icons.close_rounded), findsOneWidget);+ });++ testWidgets("FilterChipComponent inverts selected colors in dark theme", (+ tester,+ ) async {+ await tester.pumpWidget(+ _wrap(+ const FilterChipComponent(+ label: "Faces",+ state: FilterChipComponentState.selected,+ ),+ theme: ComponentTheme.darkTheme(),+ ),+ );++ final surface = tester.widget<AnimatedContainer>(+ find.byKey(const ValueKey("filter-chip-surface")),+ );+ final decoration = surface.decoration! as BoxDecoration;+ final label = tester.widget<Text>(find.text("Faces"));++ expect(decoration.color, ColorTokens.light.backgroundBase);+ expect(label.style?.color, ColorTokens.dark.textReverse);expect(find.byIcon(Icons.close_rounded), findsOneWidget);});@@ -412,9 +436,10 @@ Widget _wrap(Widget child, {TargetPlatform platform = TargetPlatform.android,TextScaler textScaler = TextScaler.noScaling,+ ThemeData? theme,}) {return MaterialApp(- theme: ComponentTheme.lightTheme().copyWith(platform: platform),+ theme: (theme ?? ComponentTheme.lightTheme()).copyWith(platform: platform),home: MediaQuery(data: MediaQueryData(textScaler: textScaler),child: Scaffold(body: Center(child: child)),