π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][photos] Enhance AppBarComponent with title tap functionality
AmanRajSinghMouryaa28f4f2210ec
diff --git a/mobile/packages/ente_components/lib/components/app_bar_component.dart b/mobile/packages/ente_components/lib/components/app_bar_component.dartindex e7f9f44521..b53f7fb0f4 100644--- a/mobile/packages/ente_components/lib/components/app_bar_component.dart+++ b/mobile/packages/ente_components/lib/components/app_bar_component.dart@@ -1,6 +1,7 @@import 'dart:math' as math;import 'dart:ui';+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';@@ -19,6 +20,7 @@ class AppBarComponent extends StatefulWidget {super.key,required this.title,required this.slivers,+ this.onTitleTap,this.subtitle,this.leading,this.backButton,@@ -34,6 +36,7 @@ class AppBarComponent extends StatefulWidget {});final String title;+ final VoidCallback? onTitleTap;final String? subtitle;final Widget? leading;final Widget? backButton;@@ -175,6 +178,7 @@ class _AppBarComponentState extends State<AppBarComponent> {@overrideWidget build(BuildContext context) {+ final colors = context.componentColors;final metrics = _resolveHeaderAppBarMetrics(context,subtitle: widget.subtitle,@@ -195,6 +199,7 @@ class _AppBarComponentState extends State<AppBarComponent> {slivers: [SliverAppBarComponent(title: widget.title,+ onTitleTap: widget.onTitleTap,subtitle: widget.subtitle,leading: widget.leading,backButton: widget.backButton,@@ -203,7 +208,7 @@ class _AppBarComponentState extends State<AppBarComponent> {expandedHeight: widget.expandedHeight,collapsedHeight: widget.collapsedHeight,horizontalPadding: widget.horizontalPadding,- backgroundColor: widget.backgroundColor,+ backgroundColor: widget.backgroundColor ?? colors.backgroundBase,showExpandedBackButton: widget.showExpandedBackButton,),...widget.slivers,@@ -244,6 +249,7 @@ class SliverAppBarComponent extends StatelessWidget {const SliverAppBarComponent({super.key,required this.title,+ this.onTitleTap,this.subtitle,this.leading,this.backButton,@@ -257,6 +263,7 @@ class SliverAppBarComponent extends StatelessWidget {});final String title;+ final VoidCallback? onTitleTap;final String? subtitle;final Widget? leading;final Widget? backButton;@@ -270,6 +277,7 @@ class SliverAppBarComponent extends StatelessWidget {@overrideWidget build(BuildContext context) {+ final colors = context.componentColors;final metrics = _resolveHeaderAppBarMetrics(context,subtitle: subtitle,@@ -281,6 +289,7 @@ class SliverAppBarComponent extends StatelessWidget {pinned: true,delegate: _HeaderAppBarDelegate(title: title,+ onTitleTap: onTitleTap,subtitle: subtitle,leading: leading,backButton: backButton,@@ -291,6 +300,7 @@ class SliverAppBarComponent extends StatelessWidget {horizontalPadding: horizontalPadding,topPadding: MediaQuery.paddingOf(context).top,backgroundColor: backgroundColor,+ colors: colors,showExpandedBackButton: showExpandedBackButton,expandedTitleLineHeight: metrics.expandedTitleLineHeight,collapsedTitleLineHeight: metrics.collapsedTitleLineHeight,@@ -303,6 +313,7 @@ class SliverAppBarComponent extends StatelessWidget {class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {const _HeaderAppBarDelegate({required this.title,+ required this.onTitleTap,required this.subtitle,required this.leading,required this.backButton,@@ -313,6 +324,7 @@ class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {required this.horizontalPadding,required this.topPadding,required this.backgroundColor,+ required this.colors,required this.showExpandedBackButton,required this.expandedTitleLineHeight,required this.collapsedTitleLineHeight,@@ -320,6 +332,7 @@ class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {});final String title;+ final VoidCallback? onTitleTap;final String? subtitle;final Widget? leading;final Widget? backButton;@@ -330,6 +343,7 @@ class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {final double horizontalPadding;final double topPadding;final Color? backgroundColor;+ final ColorTokens colors;final bool showExpandedBackButton;final double expandedTitleLineHeight;final double collapsedTitleLineHeight;@@ -347,7 +361,6 @@ class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {double shrinkOffset,bool overlapsContent,) {- final colors = context.componentColors;final scrollRange = maxExtent - minExtent;final progress = scrollRange == 0? 1.0@@ -423,6 +436,7 @@ class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {),_MovingHeaderTitle(title: title,+ onTap: onTitleTap,top: titleTop,left: titleLeft,right: titleRight,@@ -475,6 +489,7 @@ class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {@overridebool shouldRebuild(covariant _HeaderAppBarDelegate oldDelegate) {return oldDelegate.title != title ||+ oldDelegate.onTitleTap != onTitleTap ||oldDelegate.subtitle != subtitle ||oldDelegate.leading != leading ||oldDelegate.backButton != backButton ||@@ -485,6 +500,7 @@ class _HeaderAppBarDelegate extends SliverPersistentHeaderDelegate {oldDelegate.horizontalPadding != horizontalPadding ||oldDelegate.topPadding != topPadding ||oldDelegate.backgroundColor != backgroundColor ||+ oldDelegate.colors != colors ||oldDelegate.showExpandedBackButton != showExpandedBackButton ||oldDelegate.expandedTitleLineHeight != expandedTitleLineHeight ||oldDelegate.collapsedTitleLineHeight != collapsedTitleLineHeight ||@@ -706,6 +722,7 @@ double _actionsWidth(int actionCount) {class _MovingHeaderTitle extends StatelessWidget {const _MovingHeaderTitle({required this.title,+ required this.onTap,required this.top,required this.left,required this.right,@@ -713,6 +730,7 @@ class _MovingHeaderTitle extends StatelessWidget {});final String title;+ final VoidCallback? onTap;final double top;final double left;final double right;@@ -721,23 +739,28 @@ class _MovingHeaderTitle extends StatelessWidget {@overrideWidget build(BuildContext context) {final colors = context.componentColors;+ final titleText = Text(+ title,+ maxLines: 1,+ overflow: TextOverflow.ellipsis,+ style: TextStyle.lerp(+ TextStyles.h1Bold,+ TextStyles.h2,+ progress,+ )!.copyWith(color: colors.textBase),+ );return Positioned(left: left,right: right,top: top,- child: IgnorePointer(- child: Text(- title,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: TextStyle.lerp(- TextStyles.h1Bold,- TextStyles.h2,- progress,- )!.copyWith(color: colors.textBase),- ),- ),+ child: onTap == null+ ? IgnorePointer(child: titleText)+ : GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: onTap,+ child: titleText,+ ),);}}