ente/lib/ui/sharing/album_share_info_widget.dart

73 lines
1.9 KiB
Dart
Raw Normal View History

2023-06-24 13:57:57 +00:00
import "dart:math";
import "package:flutter/material.dart";
import "package:photos/models/api/collection/user.dart";
import "package:photos/ui/sharing/more_count_badge.dart";
import "package:photos/ui/sharing/user_avator_widget.dart";
class AlbumSharesIcons extends StatelessWidget {
final List<User> sharees;
final int limitCountTo;
final AvatarType type;
final bool removeBorder;
final EdgeInsets padding;
final Widget? trailingWidget;
2023-06-24 13:57:57 +00:00
const AlbumSharesIcons({
Key? key,
required this.sharees,
this.type = AvatarType.tiny,
this.limitCountTo = 2,
this.removeBorder = true,
this.trailingWidget,
this.padding = const EdgeInsets.only(left: 10.0, top: 10, bottom: 10),
2023-06-24 13:57:57 +00:00
}) : super(key: key);
@override
Widget build(BuildContext context) {
final displayCount = min(sharees.length, limitCountTo);
final hasMore = sharees.length > limitCountTo;
final double overlapPadding = type == AvatarType.tiny ? 14.0 : 20.0;
2023-06-24 13:57:57 +00:00
final widgets = List<Widget>.generate(
displayCount,
(index) => Positioned(
left: overlapPadding * index,
2023-06-24 13:57:57 +00:00
child: UserAvatarWidget(
sharees[index],
thumbnailView: removeBorder,
type: type,
),
),
);
if (hasMore) {
2023-06-24 13:57:57 +00:00
widgets.add(
Positioned(
left: (overlapPadding * displayCount),
2023-06-24 13:57:57 +00:00
child: MoreCountWidget(
sharees.length - displayCount,
type: type == AvatarType.tiny
? MoreCountType.tiny
: MoreCountType.mini,
2023-06-24 13:57:57 +00:00
thumbnailView: removeBorder,
),
),
);
}
if (trailingWidget != null) {
widgets.add(
Positioned(
2023-07-25 08:36:22 +00:00
left: (overlapPadding * (displayCount + (hasMore ? 1 : 0))) +
2023-07-26 05:01:41 +00:00
(displayCount > 0 ? 12 : 0),
child: trailingWidget!,
),
);
}
2023-06-24 13:57:57 +00:00
return Padding(
padding: padding,
2023-06-24 13:57:57 +00:00
child: Stack(children: widgets),
);
}
}