mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-13 18:58:53 +01:00
Don't handle tap event in album item widget
This commit is contained in:
parent
5bb8795f2f
commit
cb5238d388
4 changed files with 92 additions and 93 deletions
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/widget/selectable.dart';
|
||||
|
||||
class AlbumGridItem extends StatelessWidget {
|
||||
AlbumGridItem({
|
||||
|
@ -11,82 +10,72 @@ class AlbumGridItem extends StatelessWidget {
|
|||
this.subtitle,
|
||||
this.subtitle2,
|
||||
this.icon,
|
||||
this.isSelected = false,
|
||||
this.onTap,
|
||||
this.onLongPress,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
return Selectable(
|
||||
isSelected: isSelected,
|
||||
iconSize: 48,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
onTap: onTap,
|
||||
onLongPress: onLongPress,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
cover,
|
||||
if (icon != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Stack(
|
||||
children: [
|
||||
cover,
|
||||
if (icon != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Align(
|
||||
alignment: AlignmentDirectional.topEnd,
|
||||
child: Icon(
|
||||
icon,
|
||||
size: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.bodyText1!.copyWith(
|
||||
color: AppTheme.getPrimaryTextColor(context),
|
||||
),
|
||||
textAlign: TextAlign.start,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
subtitle ?? "",
|
||||
style: Theme.of(context).textTheme.bodyText2!.copyWith(
|
||||
fontSize: 10,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
),
|
||||
textAlign: TextAlign.start,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (subtitle2?.isNotEmpty == true)
|
||||
Text(
|
||||
subtitle2!,
|
||||
style: Theme.of(context).textTheme.bodyText2!.copyWith(
|
||||
fontSize: 10,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
),
|
||||
textAlign: TextAlign.end,
|
||||
maxLines: 1,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
title,
|
||||
style: Theme.of(context).textTheme.bodyText1!.copyWith(
|
||||
color: AppTheme.getPrimaryTextColor(context),
|
||||
),
|
||||
textAlign: TextAlign.start,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
subtitle ?? "",
|
||||
style: Theme.of(context).textTheme.bodyText2!.copyWith(
|
||||
fontSize: 10,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
),
|
||||
textAlign: TextAlign.start,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
if (subtitle2?.isNotEmpty == true)
|
||||
Text(
|
||||
subtitle2!,
|
||||
style: Theme.of(context).textTheme.bodyText2!.copyWith(
|
||||
fontSize: 10,
|
||||
color: AppTheme.getSecondaryTextColor(context),
|
||||
),
|
||||
textAlign: TextAlign.end,
|
||||
maxLines: 1,
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -98,7 +87,4 @@ class AlbumGridItem extends StatelessWidget {
|
|||
/// Appears after [subtitle], aligned to the end side of parent
|
||||
final String? subtitle2;
|
||||
final IconData? icon;
|
||||
final bool isSelected;
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onLongPress;
|
||||
}
|
||||
|
|
|
@ -94,13 +94,24 @@ class AlbumSearchDelegate extends SearchDelegate {
|
|||
}
|
||||
|
||||
Widget _buildResultItem(BuildContext context, Album album) {
|
||||
return AlbumGridItemBuilder(
|
||||
account: account,
|
||||
album: album,
|
||||
onTap: () {
|
||||
close(context, album);
|
||||
},
|
||||
).build(context);
|
||||
return Stack(
|
||||
children: [
|
||||
AlbumGridItemBuilder(
|
||||
account: account,
|
||||
album: album,
|
||||
).build(context),
|
||||
Positioned.fill(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
close(context, album);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSuggestionContent(
|
||||
|
|
|
@ -15,10 +15,7 @@ class AlbumGridItemBuilder {
|
|||
AlbumGridItemBuilder({
|
||||
required this.account,
|
||||
required this.album,
|
||||
this.isSelected = false,
|
||||
this.isShared = false,
|
||||
this.onTap,
|
||||
this.onLongPress,
|
||||
});
|
||||
|
||||
AlbumGridItem build(BuildContext context) {
|
||||
|
@ -43,9 +40,6 @@ class AlbumGridItemBuilder {
|
|||
subtitle: subtitle,
|
||||
subtitle2: subtitle2,
|
||||
icon: album.provider is AlbumDirProvider ? Icons.folder : null,
|
||||
isSelected: isSelected,
|
||||
onTap: onTap,
|
||||
onLongPress: onLongPress,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -92,8 +86,5 @@ class AlbumGridItemBuilder {
|
|||
|
||||
final Account account;
|
||||
final Album album;
|
||||
final bool isSelected;
|
||||
final bool isShared;
|
||||
final VoidCallback? onTap;
|
||||
final VoidCallback? onLongPress;
|
||||
}
|
||||
|
|
|
@ -134,11 +134,22 @@ class _PendingAlbumsState extends State<PendingAlbums> {
|
|||
|
||||
Widget _buildItem(BuildContext context, int index) {
|
||||
final item = _items[index];
|
||||
return AlbumGridItemBuilder(
|
||||
account: widget.account,
|
||||
album: item.album,
|
||||
onTap: () => _onItemTap(context, item),
|
||||
).build(context);
|
||||
return Stack(
|
||||
children: [
|
||||
AlbumGridItemBuilder(
|
||||
account: widget.account,
|
||||
album: item.album,
|
||||
).build(context),
|
||||
Positioned.fill(
|
||||
child: Material(
|
||||
type: MaterialType.transparency,
|
||||
child: InkWell(
|
||||
onTap: () => _onItemTap(context, item),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _onStateChange(
|
||||
|
|
Loading…
Reference in a new issue