diff --git a/lib/widget/sharing_browser.dart b/lib/widget/sharing_browser.dart index 47bba604..ee3a46a2 100644 --- a/lib/widget/sharing_browser.dart +++ b/lib/widget/sharing_browser.dart @@ -29,6 +29,7 @@ import 'package:nc_photos/widget/album_browser_util.dart' as album_browser_util; import 'package:nc_photos/widget/empty_list_indicator.dart'; import 'package:nc_photos/widget/processing_dialog.dart'; import 'package:nc_photos/widget/shared_file_viewer.dart'; +import 'package:nc_photos/widget/unbounded_list_tile.dart'; class SharingBrowserArguments { SharingBrowserArguments(this.account); @@ -379,38 +380,16 @@ class _ListTile extends StatelessWidget { @override build(BuildContext context) { - return InkWell( - onTap: onTap, - child: Padding( - padding: const EdgeInsets.all(16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - leading, - const SizedBox(width: 16), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - label, - style: Theme.of(context).textTheme.subtitle1, - maxLines: 1, - overflow: TextOverflow.ellipsis, - ), - Text( - description, - style: TextStyle( - color: AppTheme.getSecondaryTextColor(context), - ), - ), - ], - ), - ), - if (trailing != null) trailing!, - ], - ), + return UnboundedListTile( + leading: leading, + title: Text( + label, + maxLines: 1, + overflow: TextOverflow.ellipsis, ), + subtitle: Text(description), + trailing: trailing, + onTap: onTap, ); } diff --git a/lib/widget/unbounded_list_tile.dart b/lib/widget/unbounded_list_tile.dart new file mode 100644 index 00000000..7be3050f --- /dev/null +++ b/lib/widget/unbounded_list_tile.dart @@ -0,0 +1,64 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; +import 'package:nc_photos/theme.dart'; + +/// A [ListTile]-like widget with unbounded height +class UnboundedListTile extends StatelessWidget { + const UnboundedListTile({ + Key? key, + this.leading, + required this.title, + this.subtitle, + this.trailing, + this.onTap, + }) : super(key: key); + + @override + build(BuildContext context) { + final content = Padding( + padding: const EdgeInsets.all(16), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (leading != null) ...[ + leading!, + const SizedBox(width: 16), + ], + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + DefaultTextStyle( + style: Theme.of(context).textTheme.subtitle1!, + child: title, + ), + if (subtitle != null) + DefaultTextStyle( + style: TextStyle( + color: AppTheme.getSecondaryTextColor(context), + ), + child: subtitle!, + ), + ], + ), + ), + if (trailing != null) trailing!, + ], + ), + ); + if (onTap != null) { + return InkWell( + onTap: onTap, + child: content, + ); + } else { + return content; + } + } + + final Widget? leading; + final Widget title; + final Widget? subtitle; + final Widget? trailing; + final VoidCallback? onTap; +}