|
|
|
|
@ -22,8 +22,9 @@ class FilesList extends StatelessWidget {
|
|
|
|
|
final bool showAsListView;
|
|
|
|
|
final bool showDownloadButton;
|
|
|
|
|
final double? itemGap;
|
|
|
|
|
final Widget? separator;
|
|
|
|
|
|
|
|
|
|
const FilesList({Key? key, this.images = const <String>[], this.types = const <String>[], this.padding, this.showAsListView = false, this.showDownloadButton = false, this.itemGap})
|
|
|
|
|
const FilesList({Key? key, this.separator, this.images = const <String>[], this.types = const <String>[], this.padding, this.showAsListView = false, this.showDownloadButton = false, this.itemGap})
|
|
|
|
|
: super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
@ -31,7 +32,7 @@ class FilesList extends StatelessWidget {
|
|
|
|
|
return showAsListView
|
|
|
|
|
? ListView.separated(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
padding: padding ?? const EdgeInsets.only(top: 8),
|
|
|
|
|
padding: padding ?? const EdgeInsets.only(top: 0),
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
itemBuilder: (cxt, itemIndex) {
|
|
|
|
|
if (!images[itemIndex].contains(".")) {
|
|
|
|
|
@ -74,14 +75,14 @@ class FilesList extends StatelessWidget {
|
|
|
|
|
children: [
|
|
|
|
|
EllipsizedText(
|
|
|
|
|
images[itemIndex].split("/").last,
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(color: AppColor.black10),
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.textStyleColor(context)),
|
|
|
|
|
type: EllipsisType.start, // or EllipsisType.middle
|
|
|
|
|
),
|
|
|
|
|
4.height,
|
|
|
|
|
2.height,
|
|
|
|
|
RichText(
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
text: '${types.isEmpty ? "Asset Guide" : types[itemIndex]} | ',
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral120),
|
|
|
|
|
style: AppTextStyles.tinyFont.copyWith(color: AppColor.labelTextStyleColor(context)),
|
|
|
|
|
children: <TextSpan>[
|
|
|
|
|
TextSpan(
|
|
|
|
|
text: 'View',
|
|
|
|
|
@ -109,21 +110,24 @@ class FilesList extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
showDownloadButton
|
|
|
|
|
? 'download'.toSvgAsset().onPress(() async {
|
|
|
|
|
if (Utils.isLocalFile(images[itemIndex])) {
|
|
|
|
|
await OpenFile.open(images[itemIndex]);
|
|
|
|
|
} else {
|
|
|
|
|
await Utils.downloadFile(images[itemIndex], autoOpen: true, showToast: true);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
: const SizedBox.shrink()
|
|
|
|
|
if (showDownloadButton)
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: "download".toSvgAsset(height: 24, width: 24, color: AppColor.icon2Color(context)),
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
tooltip: "Download",
|
|
|
|
|
onPressed: () async {
|
|
|
|
|
if (Utils.isLocalFile(images[itemIndex])) {
|
|
|
|
|
await OpenFile.open(images[itemIndex]);
|
|
|
|
|
} else {
|
|
|
|
|
await Utils.downloadFile(images[itemIndex], autoOpen: true, showToast: true);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
separatorBuilder: (cxt, index) => SizedBox(
|
|
|
|
|
height: itemGap ?? 8.toScreenHeight,
|
|
|
|
|
),
|
|
|
|
|
separatorBuilder: (cxt, index) => separator ?? SizedBox(height: itemGap ?? 8.toScreenHeight),
|
|
|
|
|
itemCount: images.length)
|
|
|
|
|
: GridView.builder(
|
|
|
|
|
padding: padding ?? const EdgeInsets.only(top: 8, bottom: 8),
|
|
|
|
|
|