π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mob][locker] Add custom list scrollbar
aman-pilot4b88dd758116
diff --git a/mobile/apps/locker/lib/ui/components/custom_list_scrollbar.dart b/mobile/apps/locker/lib/ui/components/custom_list_scrollbar.dartnew file mode 100644index 0000000000..b22a697de9--- /dev/null+++ b/mobile/apps/locker/lib/ui/components/custom_list_scrollbar.dart@@ -0,0 +1,73 @@+import 'package:ente_ui/theme/colors.dart';+import 'package:flutter/material.dart';++/// A thin scrollbar rendered beside a bounded [ListView], with the thumb sized+/// to [visibleItems] of [itemCount] and positioned from the shared+/// [scrollController]. Shared by the add-email and share-collection sheets.+class CustomListScrollbar extends StatelessWidget {+ const CustomListScrollbar({+ super.key,+ required this.scrollController,+ required this.itemCount,+ required this.visibleItems,+ required this.containerHeight,+ required this.colorScheme,+ });++ final ScrollController scrollController;+ final int itemCount;+ final int visibleItems;+ final double containerHeight;+ final EnteColorScheme colorScheme;++ @override+ Widget build(BuildContext context) {+ final thumbHeightRatio = visibleItems / itemCount;+ final thumbHeight = containerHeight * thumbHeightRatio;++ return AnimatedBuilder(+ animation: scrollController,+ builder: (context, child) {+ double thumbPosition = 0;+ if (scrollController.hasClients &&+ scrollController.positions.length == 1) {+ final maxExtent = scrollController.position.hasContentDimensions+ ? scrollController.position.maxScrollExtent+ : 0.0;+ if (maxExtent > 0) {+ final scrollFraction = scrollController.offset / maxExtent;+ thumbPosition = scrollFraction * (containerHeight - thumbHeight);+ }+ }++ return SizedBox(+ height: containerHeight,+ width: 5,+ child: Stack(+ children: [+ Container(+ width: 5,+ height: containerHeight,+ decoration: BoxDecoration(+ color: colorScheme.strokeFaint,+ borderRadius: BorderRadius.circular(3),+ ),+ ),+ Positioned(+ top: thumbPosition,+ child: Container(+ width: 5,+ height: thumbHeight,+ decoration: BoxDecoration(+ color: colorScheme.strokeMuted,+ borderRadius: BorderRadius.circular(3),+ ),+ ),+ ),+ ],+ ),+ );+ },+ );+ }+}diff --git a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dartindex 2cfc9db56c..3fcd70f49d 100644--- a/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart+++ b/mobile/apps/locker/lib/ui/sharing/add_email_bottom_sheet.dart@@ -18,6 +18,7 @@ import "package:locker/l10n/l10n.dart";import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";import "package:locker/services/configuration.dart";+import "package:locker/ui/components/custom_list_scrollbar.dart";import "package:locker/ui/viewer/date/date_time_picker.dart";import "package:locker/utils/collection_actions.dart";@@ -117,6 +118,7 @@ class _AddEmailSheetState extends State<AddEmailSheet> {keyboardType: TextInputType.emailAddress,autofillHints: const [AutofillHints.email],autocorrect: false,+ shouldUnfocusOnClearOrSubmit: true,onChanged: (value) {_email = value.trim();_emailIsValid = _isValidEmail(_email);@@ -221,10 +223,12 @@ class _AddEmailSheetState extends State<AddEmailSheet> {),if (showScrollbar) ...[const SizedBox(width: 4),- _buildCustomScrollbar(- filteredUsers.length,- maxVisibleHeight,- colorScheme,+ CustomListScrollbar(+ scrollController: _scrollController,+ itemCount: filteredUsers.length,+ visibleItems: 2,+ containerHeight: maxVisibleHeight,+ colorScheme: colorScheme,),],],@@ -233,61 +237,6 @@ class _AddEmailSheetState extends State<AddEmailSheet> {);}- Widget _buildCustomScrollbar(- int itemCount,- double containerHeight,- colorScheme,- ) {- const visibleItems = 2;- final thumbHeightRatio = visibleItems / itemCount;- final thumbHeight = containerHeight * thumbHeightRatio;-- return AnimatedBuilder(- animation: _scrollController,- builder: (context, child) {- double thumbPosition = 0;- if (_scrollController.hasClients &&- _scrollController.positions.length == 1) {- final maxExtent = _scrollController.position.hasContentDimensions- ? _scrollController.position.maxScrollExtent- : 0.0;- if (maxExtent > 0) {- final scrollFraction = _scrollController.offset / maxExtent;- thumbPosition = scrollFraction * (containerHeight - thumbHeight);- }- }-- return SizedBox(- height: containerHeight,- width: 5,- child: Stack(- children: [- Container(- width: 5,- height: containerHeight,- decoration: BoxDecoration(- color: colorScheme.strokeFaint,- borderRadius: BorderRadius.circular(3),- ),- ),- Positioned(- top: thumbPosition,- child: Container(- width: 5,- height: thumbHeight,- decoration: BoxDecoration(- color: colorScheme.strokeMuted,- borderRadius: BorderRadius.circular(3),- ),- ),- ),- ],- ),- );- },- );- }-Widget _buildScheduleDateTimeRow(EnteColorScheme colorScheme,EnteTextTheme textTheme,diff --git a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dartindex 1df45909fb..52d135e78d 100644--- a/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart+++ b/mobile/apps/locker/lib/ui/sharing/share_collection_bottom_sheet.dart@@ -17,6 +17,7 @@ import "package:locker/l10n/l10n.dart";import "package:locker/services/collections/collections_service.dart";import "package:locker/services/collections/models/collection.dart";import "package:locker/services/configuration.dart";+import "package:locker/ui/components/custom_list_scrollbar.dart";import "package:locker/ui/components/popup_menu_item_widget.dart";import "package:locker/ui/sharing/add_email_bottom_sheet.dart";import "package:locker/ui/sharing/manage_links_widget.dart";@@ -174,7 +175,13 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {),if (showScrollbar) ...[const SizedBox(width: 4),- _buildCustomScrollbar(allUsers.length, maxVisibleHeight, colorScheme),+ CustomListScrollbar(+ scrollController: _scrollController,+ itemCount: allUsers.length,+ visibleItems: 4,+ containerHeight: maxVisibleHeight,+ colorScheme: colorScheme,+ ),],],);@@ -240,61 +247,6 @@ class _ShareCollectionSheetState extends State<ShareCollectionSheet> {}}- Widget _buildCustomScrollbar(- int itemCount,- double containerHeight,- colorScheme,- ) {- const visibleItems = 4;- final thumbHeightRatio = visibleItems / itemCount;- final thumbHeight = containerHeight * thumbHeightRatio;-- return AnimatedBuilder(- animation: _scrollController,- builder: (context, child) {- double thumbPosition = 0;- if (_scrollController.hasClients &&- _scrollController.positions.length == 1) {- final maxExtent = _scrollController.position.hasContentDimensions- ? _scrollController.position.maxScrollExtent- : 0.0;- if (maxExtent > 0) {- final scrollFraction = _scrollController.offset / maxExtent;- thumbPosition = scrollFraction * (containerHeight - thumbHeight);- }- }-- return SizedBox(- height: containerHeight,- width: 5,- child: Stack(- children: [- Container(- width: 5,- height: containerHeight,- decoration: BoxDecoration(- color: colorScheme.strokeFaint,- borderRadius: BorderRadius.circular(3),- ),- ),- Positioned(- top: thumbPosition,- child: Container(- width: 5,- height: thumbHeight,- decoration: BoxDecoration(- color: colorScheme.strokeMuted,- borderRadius: BorderRadius.circular(3),- ),- ),- ),- ],- ),- );- },- );- }-Widget _buildRoleIcon(CollectionParticipantRole role, colorScheme) {final icon = switch (role) {CollectionParticipantRole.owner => HugeIcons.strokeRoundedCrown03,