From 8532cb5cdf2b14459baebc3747026f4b1bab0e97 Mon Sep 17 00:00:00 2001 From: Thiago Carvalho Date: Tue, 30 Jan 2024 00:57:44 -0300 Subject: [PATCH] Update folder_selector.dart add scroll to folder selector --- .../folder_selector/folder_selector.dart | 202 +++++++++--------- 1 file changed, 103 insertions(+), 99 deletions(-) diff --git a/lib/sharing/folder_selector/folder_selector.dart b/lib/sharing/folder_selector/folder_selector.dart index fe952c82da..d03e8a3f27 100644 --- a/lib/sharing/folder_selector/folder_selector.dart +++ b/lib/sharing/folder_selector/folder_selector.dart @@ -177,114 +177,118 @@ class _FolderSelectorState extends State { description = 'Select the folder you want to upload to'; content = SizedBox( height: 400, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - if (state.selectedFolder != null) ...[ - SizedBox( - width: 200, - height: 48, - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - if (state.isRootFolder) - Flexible( - child: ListTile( - leading: - getIconForContentType('folder', size: 24), - title: Text( - 'Root folder', - style: ArDriveTypography.body - .buttonLargeBold( - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgDefault) - .copyWith(fontWeight: FontWeight.w700), + child: SingleChildScrollView( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + if (state.selectedFolder != null) ...[ + SizedBox( + width: 200, + height: 48, + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + if (state.isRootFolder) + Flexible( + child: ListTile( + leading: + getIconForContentType('folder', size: 24), + title: Text( + 'Root folder', + style: ArDriveTypography.body + .buttonLargeBold( + color: ArDriveTheme.of(context) + .themeData + .colors + .themeFgDefault) + .copyWith(fontWeight: FontWeight.w700), + ), ), ), - ), - if (state.parentFolder != null && !state.isRootFolder) - Padding( - padding: const EdgeInsets.only(top: 4.0, right: 4), - child: SizedBox( - width: 24, - child: ArDriveIconButton( - icon: ArDriveIcons.arrowLeft(), - onPressed: () { - context.read().add( - SelectFolderEvent( - folder: state.parentFolder!)); - }, + if (state.parentFolder != null && !state.isRootFolder) + Padding( + padding: + const EdgeInsets.only(top: 4.0, right: 4), + child: SizedBox( + width: 24, + child: ArDriveIconButton( + icon: ArDriveIcons.arrowLeft(), + onPressed: () { + context.read().add( + SelectFolderEvent( + folder: state.parentFolder!)); + }, + ), ), ), - ), - if (!state.isRootFolder) - Flexible( - child: ListTile( - leading: - getIconForContentType('folder', size: 24), - title: Text( - state.selectedFolder!.name, - style: ArDriveTypography.body - .buttonLargeBold( - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgDefault) - .copyWith(fontWeight: FontWeight.w700), + if (!state.isRootFolder) + Flexible( + child: ListTile( + leading: + getIconForContentType('folder', size: 24), + title: Text( + state.selectedFolder!.name, + style: ArDriveTypography.body + .buttonLargeBold( + color: ArDriveTheme.of(context) + .themeData + .colors + .themeFgDefault) + .copyWith(fontWeight: FontWeight.w700), + ), ), ), - ), - ], + ], + ), ), + ], + ListView.builder( + padding: EdgeInsets.only( + left: state.selectedFolder == null + ? 0 + : state.parentFolder != null + ? 48 + : 20), + itemCount: state.folders.length, + shrinkWrap: true, + physics: const ScrollPhysics(), + itemBuilder: (context, index) { + final color = state.selectedFolder == null + ? colors.themeFgSubtle + : state.selectedFolder != null + ? state.folders[index].id == + state.selectedFolder!.id + ? null + : colors.themeAccentDisabled + : null; + return SizedBox( + width: 200, + child: ListTile( + leading: getIconForContentType('folder', + color: color, size: 24), + title: Text( + state.folders[index].name, + style: ArDriveTypography.body + .buttonLargeBold( + color: color, + ) + .copyWith( + fontWeight: state.selectedFolder?.id == + state.folders[index].id + ? FontWeight.w700 + : null), + ), + onTap: () { + context.read().add( + SelectFolderEvent( + folder: state.folders[index])); + }, + ), + ); + }, ), ], - ListView.builder( - padding: EdgeInsets.only( - left: state.selectedFolder == null - ? 0 - : state.parentFolder != null - ? 48 - : 20), - itemCount: state.folders.length, - shrinkWrap: true, - physics: const ScrollPhysics(), - itemBuilder: (context, index) { - final color = state.selectedFolder == null - ? colors.themeFgSubtle - : state.selectedFolder != null - ? state.folders[index].id == - state.selectedFolder!.id - ? null - : colors.themeAccentDisabled - : null; - return SizedBox( - width: 200, - child: ListTile( - leading: getIconForContentType('folder', - color: color, size: 24), - title: Text( - state.folders[index].name, - style: ArDriveTypography.body - .buttonLargeBold( - color: color, - ) - .copyWith( - fontWeight: state.selectedFolder?.id == - state.folders[index].id - ? FontWeight.w700 - : null), - ), - onTap: () { - context.read().add( - SelectFolderEvent(folder: state.folders[index])); - }, - ), - ); - }, - ), - ], + ), ), );