Skip to content

armgit / ente

Public Imported from GitHub
0

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

Add trailingWidgets support to TitleBarTitleWidget for dynamic action buttons

AmanRajSinghMourya64a9b0312e85
diff --git a/mobile/apps/photos/lib/ui/components/title_bar_title_widget.dart b/mobile/apps/photos/lib/ui/components/title_bar_title_widget.dart
index e838849ef3..c2815780de 100644
--- a/mobile/apps/photos/lib/ui/components/title_bar_title_widget.dart
+++ b/mobile/apps/photos/lib/ui/components/title_bar_title_widget.dart
@@ -7,12 +7,14 @@ class TitleBarTitleWidget extends StatelessWidget {
final IconData? icon;
final VoidCallback? onTap;
final String? heroTag;
+ final List<Widget>? trailingWidgets;
const TitleBarTitleWidget({
this.title,
this.isTitleH2 = false,
this.icon,
this.onTap,
this.heroTag,
+ this.trailingWidgets,
super.key,
});
@@ -53,6 +55,23 @@ class TitleBarTitleWidget extends StatelessWidget {
maxLines: 1,
);
}
+
+ if (trailingWidgets != null && trailingWidgets!.isNotEmpty) {
+ return Row(
+ children: <Widget>[
+ Expanded(
+ child: GestureDetector(
+ onTap: onTap,
+ child: heroTag != null
+ ? Hero(tag: heroTag!, child: widget)
+ : widget,
+ ),
+ ),
+ ...trailingWidgets!,
+ ],
+ );
+ }
+
return GestureDetector(
onTap: onTap,
child: heroTag != null ? Hero(tag: heroTag!, child: widget) : widget,
diff --git a/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dart b/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dart
index ab24a7a544..5cc0e8dbaf 100644
--- a/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dart
+++ b/mobile/apps/photos/lib/ui/tabs/shared/all_links_page.dart
@@ -167,20 +167,6 @@ class _AllLinksPageState extends State<AllLinksPage> {
onTap: () => Navigator.pop(context),
child: const Icon(Icons.arrow_back_outlined),
),
- actions: [
- if (_hasSelection)
- Padding(
- padding: const EdgeInsets.only(right: 16),
- child: SoftIconButton(
- icon: HugeIcon(
- icon: HugeIcons.strokeRoundedDelete01,
- size: 18,
- color: colorScheme.warning500,
- ),
- onTap: _removeSelectedLinks,
- ),
- ),
- ],
),
body: CustomScrollView(
physics: const BouncingScrollPhysics(),
@@ -194,6 +180,26 @@ class _AllLinksPageState extends State<AllLinksPage> {
TitleBarTitleWidget(
title: AppLocalizations.of(context).links,
heroTag: widget.titleHeroTag,
+ trailingWidgets: [
+ AnimatedSwitcher(
+ duration: const Duration(milliseconds: 200),
+ switchInCurve: Curves.easeOut,
+ switchOutCurve: Curves.easeIn,
+ child: _hasSelection
+ ? SoftIconButton(
+ key: const ValueKey("delete_links"),
+ icon: HugeIcon(
+ icon: HugeIcons.strokeRoundedDelete01,
+ size: 18,
+ color: colorScheme.warning500,
+ ),
+ onTap: _removeSelectedLinks,
+ )
+ : const SizedBox.shrink(
+ key: ValueKey("no_selection_action"),
+ ),
+ ),
+ ],
),
Text(
(widget.quickLinks.length + widget.memoryShares.length)