diff --git a/lib/components/details_panel.dart b/lib/components/details_panel.dart index c5342fe479..8225af7232 100644 --- a/lib/components/details_panel.dart +++ b/lib/components/details_panel.dart @@ -119,8 +119,7 @@ class _DetailsPanelState extends State { required FsEntryInfoState infoState, }) { final tabs = [ - if (previewState is FsEntryPreviewSuccess && - !(widget.isSharePage && !mobileView)) ...[ + if (!(widget.isSharePage && !mobileView)) ...[ ArDriveTab( Tab( child: Text( @@ -130,47 +129,6 @@ class _DetailsPanelState extends State { Column( children: [ Expanded(child: _buildPreview(previewState)), - // SizedBox( - // height: mobileView ? 158 : 0, - // child: Column( - // children: [ - // Expanded( - // child: SizedBox( - // height: 40, - // child: Row( - // children: [ - // Expanded( - // child: ArDriveButton( - // icon: ArDriveIcons.download( - // color: Colors.white), - // onPressed: () { - // final file = ARFSFactory() - // .getARFSFileFromFileRevision( - // widget.revisions!.last, - // ); - // return promptToDownloadSharedFile( - // revision: file, - // context: context, - // fileKey: widget.fileKey, - // ); - // }, - // text: appLocalizationsOf(context).download, - // ), - // ), - // ], - // ), - // ), - // ), - // Expanded( - // child: ArDriveButton( - // style: ArDriveButtonStyle.tertiary, - // onPressed: () => openUrl(url: 'https://ardrive.io/'), - // text: appLocalizationsOf(context).whatIsArDrive, - // ), - // ), - // ], - // ), - // ) ], )), ], @@ -403,7 +361,7 @@ class _DetailsPanelState extends State { ]; } - Widget _buildPreview(previewState) { + Widget _buildPreview(FsEntryPreviewState previewState) { return Align( alignment: Alignment.center, child: FsEntryPreviewWidget( diff --git a/lib/pages/drive_detail/components/fs_entry_preview_widget.dart b/lib/pages/drive_detail/components/fs_entry_preview_widget.dart index 2ca46f8a48..b32f8a9dac 100644 --- a/lib/pages/drive_detail/components/fs_entry_preview_widget.dart +++ b/lib/pages/drive_detail/components/fs_entry_preview_widget.dart @@ -11,7 +11,7 @@ class FsEntryPreviewWidget extends StatefulWidget { required this.isSharePage, }) : super(key: key); - final FsEntryPreviewSuccess state; + final FsEntryPreviewState state; @override State createState() => _FsEntryPreviewWidgetState(); @@ -22,6 +22,7 @@ class _FsEntryPreviewWidgetState extends State { Widget build(BuildContext context) { switch (widget.state.runtimeType) { case FsEntryPreviewLoading: + case FsEntryPreviewInitial: return const Center( child: SizedBox( height: 24, diff --git a/lib/pages/shared_file/shared_file_page.dart b/lib/pages/shared_file/shared_file_page.dart index 9ac8fb5617..a5b150d848 100644 --- a/lib/pages/shared_file/shared_file_page.dart +++ b/lib/pages/shared_file/shared_file_page.dart @@ -42,145 +42,6 @@ class SharedFilePage extends StatelessWidget { } }, builder: (context, state) { - Widget shareCard() { - return ArDriveCard( - backgroundColor: - ArDriveTheme.of(context).themeData.tableTheme.backgroundColor, - elevation: 2, - content: Padding( - padding: const EdgeInsets.all(24.0), - child: Center( - child: ConstrainedBox( - constraints: const BoxConstraints( - maxWidth: 400, - minWidth: kMediumDialogWidth, - minHeight: 256, - ), - child: Column( - mainAxisSize: MainAxisSize.min, - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - ScreenTypeLayout.builder( - desktop: (context) => Row( - children: [ - ArDriveImage( - image: AssetImage( - ArDriveTheme.of(context).themeData.name == - 'light' - ? Resources.images.brand.blackLogo2 - : Resources.images.brand.whiteLogo2, - ), - height: 80, - fit: BoxFit.contain, - ), - ], - ), - mobile: (context) => Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ArDriveImage( - image: AssetImage( - ArDriveTheme.of(context).themeData.name == - 'light' - ? Resources.images.brand.blackLogo2 - : Resources.images.brand.whiteLogo2, - ), - height: 55, - fit: BoxFit.contain, - ), - ], - ), - ), - const SizedBox(height: 32), - if (state is SharedFileIsPrivate) ...[ - Text(appLocalizationsOf(context) - .sharedFileIsEncrypted), - const SizedBox(height: 16), - ArDriveTextField( - controller: _fileKeyController, - autofocus: true, - obscureText: true, - hintText: appLocalizationsOf(context).enterFileKey, - onFieldSubmitted: (_) => context - .read() - .submit(_fileKeyController.text), - ), - const SizedBox(height: 16), - ArDriveButton( - onPressed: () => context - .read() - .submit(_fileKeyController.text), - text: appLocalizationsOf(context).unlock, - ), - ], - if (state is SharedFileLoadInProgress) - const CircularProgressIndicator() - else if (state is SharedFileLoadSuccess) ...{ - ListTile( - contentPadding: EdgeInsets.zero, - leading: DriveExplorerItemTileLeading( - item: DriveDataTableItemMapper.fromRevision( - state.fileRevisions.first, - false, // in this page we don't have the information about the current drive, so it's impossible to know if the file is from the user logged in - ), - ), - title: Text( - state.fileRevisions.first.name, - style: ArDriveTypography.body.buttonLargeBold( - color: ArDriveTheme.of(context) - .themeData - .colors - .themeFgDefault, - ), - ), - subtitle: Text( - filesize(state.fileRevisions.first.size), - style: ArDriveTypography.body.buttonNormalRegular( - color: ArDriveTheme.of(context) - .themeData - .colors - .themeAccentDisabled, - ), - ), - ), - const SizedBox(height: 24), - ArDriveButton( - icon: ArDriveIcons.download(color: Colors.white), - onPressed: () { - final file = - ARFSFactory().getARFSFileFromFileRevision( - state.fileRevisions.first, - ); - return promptToDownloadSharedFile( - revision: file, - context: context, - fileKey: state.fileKey, - ); - }, - text: appLocalizationsOf(context).download, - ), - const SizedBox(height: 16), - _buildReturnToAppLink(context), - } else if (state is SharedFileNotFound) ...{ - const Icon(Icons.error_outline, size: 36), - const SizedBox(height: 16), - Text( - appLocalizationsOf(context) - .specifiedFileDoesNotExist, - textAlign: TextAlign.center, - ), - const SizedBox(height: 24), - _buildReturnToAppLink(context), - } - ], - ), - ), - ), - ), - ); - } - Widget activityPanel(SharedFileLoadSuccess state) { return DetailsPanel( item: DriveDataTableItemMapper.fromRevision( @@ -210,9 +71,7 @@ class SharedFilePage extends StatelessWidget { child: activityPanel(state), ) } else ...{ - const CircularProgressIndicator( - strokeWidth: 8, - ), + _buildShareCard(context, state) } ], ), @@ -224,13 +83,7 @@ class SharedFilePage extends StatelessWidget { height: MediaQuery.of(context).size.height, child: state is SharedFileLoadSuccess ? Expanded(child: activityPanel(state)) - : const Center( - child: SizedBox( - height: 24, - width: 24, - child: CircularProgressIndicator(), - ), - ), + : _buildShareCard(context, state), ), ), ); @@ -239,6 +92,140 @@ class SharedFilePage extends StatelessWidget { ); } + Widget _buildShareCard(BuildContext context, SharedFileState state) { + return ArDriveCard( + backgroundColor: + ArDriveTheme.of(context).themeData.tableTheme.backgroundColor, + elevation: 2, + content: Padding( + padding: const EdgeInsets.all(24.0), + child: Center( + child: ConstrainedBox( + constraints: const BoxConstraints( + maxWidth: 400, + minWidth: kMediumDialogWidth, + minHeight: 256, + ), + child: Column( + mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + ScreenTypeLayout.builder( + desktop: (context) => Row( + children: [ + ArDriveImage( + image: AssetImage( + ArDriveTheme.of(context).themeData.name == 'light' + ? Resources.images.brand.blackLogo2 + : Resources.images.brand.whiteLogo2, + ), + height: 80, + fit: BoxFit.contain, + ), + ], + ), + mobile: (context) => Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ArDriveImage( + image: AssetImage( + ArDriveTheme.of(context).themeData.name == 'light' + ? Resources.images.brand.blackLogo2 + : Resources.images.brand.whiteLogo2, + ), + height: 55, + fit: BoxFit.contain, + ), + ], + ), + ), + const SizedBox(height: 32), + if (state is SharedFileIsPrivate) ...[ + Text(appLocalizationsOf(context).sharedFileIsEncrypted), + const SizedBox(height: 16), + ArDriveTextField( + controller: _fileKeyController, + autofocus: true, + obscureText: true, + hintText: appLocalizationsOf(context).enterFileKey, + onFieldSubmitted: (_) => context + .read() + .submit(_fileKeyController.text), + ), + const SizedBox(height: 16), + ArDriveButton( + onPressed: () => context + .read() + .submit(_fileKeyController.text), + text: appLocalizationsOf(context).unlock, + ), + ], + if (state is SharedFileLoadInProgress) + const CircularProgressIndicator() + else if (state is SharedFileLoadSuccess) ...{ + ListTile( + contentPadding: EdgeInsets.zero, + leading: DriveExplorerItemTileLeading( + item: DriveDataTableItemMapper.fromRevision( + state.fileRevisions.first, + false, // in this page we don't have the information about the current drive, so it's impossible to know if the file is from the user logged in + ), + ), + title: Text( + state.fileRevisions.first.name, + style: ArDriveTypography.body.buttonLargeBold( + color: ArDriveTheme.of(context) + .themeData + .colors + .themeFgDefault, + ), + ), + subtitle: Text( + filesize(state.fileRevisions.first.size), + style: ArDriveTypography.body.buttonNormalRegular( + color: ArDriveTheme.of(context) + .themeData + .colors + .themeAccentDisabled, + ), + ), + ), + const SizedBox(height: 24), + ArDriveButton( + icon: ArDriveIcons.download(color: Colors.white), + onPressed: () { + final file = ARFSFactory().getARFSFileFromFileRevision( + state.fileRevisions.first, + ); + return promptToDownloadSharedFile( + revision: file, + context: context, + fileKey: state.fileKey, + ); + }, + text: appLocalizationsOf(context).download, + ), + const SizedBox(height: 16), + _buildReturnToAppLink(context), + } else if (state is SharedFileNotFound) ...{ + const Icon(Icons.error_outline, size: 36), + const SizedBox(height: 16), + Text( + appLocalizationsOf(context).specifiedFileDoesNotExist, + textAlign: TextAlign.center, + ), + const SizedBox(height: 24), + _buildReturnToAppLink(context), + } + ], + ), + ), + ), + ), + ); + } + Widget _buildReturnToAppLink(BuildContext context) { return ArDriveButton( style: ArDriveButtonStyle.tertiary,