Skip to content

armgit / ente

Public Imported from GitHub
0

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

Centralize album sharing role helpers

AmanRajSinghMourya14fcc69616a8
diff --git a/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_role_badge.dart b/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_role_badge.dart
index 6527d08be1..a1530675c7 100644
--- a/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_role_badge.dart
+++ b/mobile/apps/photos/lib/ui/sharing/library_sharing/library_sharing_role_badge.dart
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:hugeicons/hugeicons.dart';
import 'package:photos/models/collection/collection.dart';
import 'package:photos/services/library_sharing_service.dart';
+import 'package:photos/ui/sharing/widgets/sharing_role.dart';
List<EntePopupMenuOption<CollectionParticipantRole>> librarySharingRoleOptions(
BuildContext context, {
@@ -15,7 +16,7 @@ List<EntePopupMenuOption<CollectionParticipantRole>> librarySharingRoleOptions(
value: role,
label: librarySharingRoleLabel(context, role),
leadingWidget: HugeIcon(
- icon: librarySharingRoleIcon(role),
+ icon: sharingRoleIcon(role),
size: IconSizes.small,
strokeWidth: 1.6,
),
@@ -49,7 +50,7 @@ class LibrarySharingRoleBadge extends StatelessWidget {
),
child: Center(
child: HugeIcon(
- icon: librarySharingRoleIcon(role),
+ icon: sharingRoleIcon(role),
size: IconSizes.micro,
color: colors.textBase,
strokeWidth: 1.8,
@@ -88,7 +89,7 @@ class LibrarySharingRoleSelector extends StatelessWidget {
children: [
if (role != null) ...[
HugeIcon(
- icon: librarySharingRoleIcon(role!),
+ icon: sharingRoleIcon(role!),
size: IconSizes.small,
color: colors.textBase,
strokeWidth: 1.8,
@@ -114,14 +115,6 @@ class LibrarySharingRoleSelector extends StatelessWidget {
}
}
-List<List<dynamic>> librarySharingRoleIcon(CollectionParticipantRole role) {
- return switch (role) {
- CollectionParticipantRole.admin => HugeIcons.strokeRoundedCrown02,
- CollectionParticipantRole.collaborator => HugeIcons.strokeRoundedUserGroup,
- _ => HugeIcons.strokeRoundedView,
- };
-}
-
String librarySharingRoleLabel(
BuildContext context,
CollectionParticipantRole role,
diff --git a/mobile/apps/photos/lib/ui/sharing/widgets/sharing_role.dart b/mobile/apps/photos/lib/ui/sharing/widgets/sharing_role.dart
new file mode 100644
index 0000000000..5c5ba0f698
--- /dev/null
+++ b/mobile/apps/photos/lib/ui/sharing/widgets/sharing_role.dart
@@ -0,0 +1,21 @@
+import "package:hugeicons/hugeicons.dart";
+import "package:photos/models/collection/collection.dart";
+
+List<List<dynamic>> sharingRoleIcon(CollectionParticipantRole role) {
+ return switch (role) {
+ CollectionParticipantRole.owner ||
+ CollectionParticipantRole.admin => HugeIcons.strokeRoundedCrown,
+ CollectionParticipantRole.collaborator => HugeIcons.strokeRoundedUserGroup,
+ CollectionParticipantRole.viewer ||
+ CollectionParticipantRole.unknown => HugeIcons.strokeRoundedView,
+ };
+}
+
+int sharingRoleRank(CollectionParticipantRole role) {
+ return switch (role) {
+ CollectionParticipantRole.owner => -1,
+ CollectionParticipantRole.admin => 0,
+ CollectionParticipantRole.collaborator => 1,
+ CollectionParticipantRole.viewer || CollectionParticipantRole.unknown => 2,
+ };
+}