-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
153 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:popup_menu/popup_menu.dart'; | ||
|
||
import '../../../nocodb_sdk/models.dart'; | ||
|
||
class AttachmentFileCard extends HookConsumerWidget { | ||
final NcAttachedFile _file; | ||
final PopupMenu? popupMenu; | ||
const AttachmentFileCard( | ||
this._file, { | ||
this.popupMenu, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final anchor = popupMenu != null ? GlobalKey() : null; | ||
final child = Padding( | ||
padding: const EdgeInsets.all(8), | ||
child: Column( | ||
children: [ | ||
const SizedBox( | ||
width: 64, | ||
height: 64, | ||
child: Icon(Icons.description_outlined, size: 48), | ||
), | ||
Container( | ||
padding: const EdgeInsets.all(8), | ||
child: Text( | ||
_file.title, | ||
overflow: TextOverflow.ellipsis, | ||
), | ||
), | ||
], | ||
), | ||
); | ||
|
||
return Card( | ||
key: anchor, | ||
elevation: 4, | ||
child: anchor == null | ||
? child | ||
: InkWell( | ||
onTap: () => popupMenu?.show(widgetKey: anchor), | ||
child: child, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:cached_network_image/cached_network_image.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
import 'package:popup_menu/popup_menu.dart'; | ||
|
||
import '../../../nocodb_sdk/client.dart'; | ||
import '../../../nocodb_sdk/models.dart'; | ||
|
||
class AttachmentImageCard extends HookConsumerWidget { | ||
final NcAttachedFile _file; | ||
final PopupMenu? popupMenu; | ||
const AttachmentImageCard( | ||
this._file, { | ||
this.popupMenu, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final anchor = popupMenu != null ? GlobalKey() : null; | ||
final child = SizedBox( | ||
width: 80, | ||
height: 80, | ||
child: CachedNetworkImage( | ||
imageUrl: _file.signedUrl(api.uri), | ||
placeholder: (context, url) => const Padding( | ||
padding: EdgeInsets.all(24), | ||
child: CircularProgressIndicator(), | ||
), | ||
errorWidget: (context, url, error) => const Icon(Icons.error), | ||
), | ||
); | ||
|
||
return Card( | ||
key: anchor, | ||
elevation: 4, | ||
child: anchor == null | ||
? child | ||
: InkWell( | ||
onTap: () => popupMenu?.show(widgetKey: anchor), | ||
child: child, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.