Skip to content

Commit

Permalink
feat(tab view): minor fix PE-4711
Browse files Browse the repository at this point in the history
  • Loading branch information
matibat committed Oct 6, 2023
1 parent daffcf4 commit 387a258
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 194 deletions.
46 changes: 2 additions & 44 deletions lib/components/details_panel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ class _DetailsPanelState extends State<DetailsPanel> {
required FsEntryInfoState infoState,
}) {
final tabs = [
if (previewState is FsEntryPreviewSuccess &&
!(widget.isSharePage && !mobileView)) ...[
if (!(widget.isSharePage && !mobileView)) ...[
ArDriveTab(
Tab(
child: Text(
Expand All @@ -130,47 +129,6 @@ class _DetailsPanelState extends State<DetailsPanel> {
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,
// ),
// ),
// ],
// ),
// )
],
)),
],
Expand Down Expand Up @@ -403,7 +361,7 @@ class _DetailsPanelState extends State<DetailsPanel> {
];
}

Widget _buildPreview(previewState) {
Widget _buildPreview(FsEntryPreviewState previewState) {
return Align(
alignment: Alignment.center,
child: FsEntryPreviewWidget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class FsEntryPreviewWidget extends StatefulWidget {
required this.isSharePage,
}) : super(key: key);

final FsEntryPreviewSuccess state;
final FsEntryPreviewState state;

@override
State<FsEntryPreviewWidget> createState() => _FsEntryPreviewWidgetState();
Expand All @@ -22,6 +22,7 @@ class _FsEntryPreviewWidgetState extends State<FsEntryPreviewWidget> {
Widget build(BuildContext context) {
switch (widget.state.runtimeType) {
case FsEntryPreviewLoading:
case FsEntryPreviewInitial:
return const Center(
child: SizedBox(
height: 24,
Expand Down
285 changes: 136 additions & 149 deletions lib/pages/shared_file/shared_file_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<SharedFileCubit>()
.submit(_fileKeyController.text),
),
const SizedBox(height: 16),
ArDriveButton(
onPressed: () => context
.read<SharedFileCubit>()
.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(
Expand Down Expand Up @@ -210,9 +71,7 @@ class SharedFilePage extends StatelessWidget {
child: activityPanel(state),
)
} else ...{
const CircularProgressIndicator(
strokeWidth: 8,
),
_buildShareCard(context, state)
}
],
),
Expand All @@ -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),
),
),
);
Expand All @@ -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<SharedFileCubit>()
.submit(_fileKeyController.text),
),
const SizedBox(height: 16),
ArDriveButton(
onPressed: () => context
.read<SharedFileCubit>()
.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,
Expand Down

0 comments on commit 387a258

Please sign in to comment.