|
|
|
@ -1,5 +1,6 @@
|
|
|
|
import 'dart:io';
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/gestures.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
import 'package:fluttertoast/fluttertoast.dart';
|
|
|
|
import 'package:open_file/open_file.dart';
|
|
|
|
import 'package:open_file/open_file.dart';
|
|
|
|
@ -18,8 +19,16 @@ class MultiFilesPickerItem extends StatelessWidget {
|
|
|
|
final bool enabled;
|
|
|
|
final bool enabled;
|
|
|
|
final Function(File) onRemoveTap;
|
|
|
|
final Function(File) onRemoveTap;
|
|
|
|
final VoidCallback? onRemove;
|
|
|
|
final VoidCallback? onRemove;
|
|
|
|
|
|
|
|
final bool showAsListView;
|
|
|
|
|
|
|
|
|
|
|
|
const MultiFilesPickerItem({Key? key, required this.file, required this.enabled, required this.onRemoveTap, this.onRemove}) : super(key: key);
|
|
|
|
const MultiFilesPickerItem({
|
|
|
|
|
|
|
|
Key? key,
|
|
|
|
|
|
|
|
required this.file,
|
|
|
|
|
|
|
|
required this.enabled,
|
|
|
|
|
|
|
|
required this.onRemoveTap,
|
|
|
|
|
|
|
|
this.onRemove,
|
|
|
|
|
|
|
|
this.showAsListView = false,
|
|
|
|
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
@ -27,6 +36,97 @@ class MultiFilesPickerItem extends StatelessWidget {
|
|
|
|
bool isPdf = file.path.split(".").last.toLowerCase() == "pdf";
|
|
|
|
bool isPdf = file.path.split(".").last.toLowerCase() == "pdf";
|
|
|
|
bool isExcel = file.path.split(".").last.toLowerCase() == "xlsx";
|
|
|
|
bool isExcel = file.path.split(".").last.toLowerCase() == "xlsx";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (showAsListView) {
|
|
|
|
|
|
|
|
return Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
width: 48.toScreenWidth,
|
|
|
|
|
|
|
|
height: 48.toScreenWidth,
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: AppColor.neutral90,
|
|
|
|
|
|
|
|
border: Border.all(width: 1, color: context.isDark ? AppColor.neutral30 : AppColor.neutral30),
|
|
|
|
|
|
|
|
image: DecorationImage(
|
|
|
|
|
|
|
|
image: getImage(isImage, isPdf, isExcel, file),
|
|
|
|
|
|
|
|
fit: BoxFit.cover,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
8.width,
|
|
|
|
|
|
|
|
Column(
|
|
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
Flexible(
|
|
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
|
|
file.path.split("/").last,
|
|
|
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(color: AppColor.black10),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
8.width,
|
|
|
|
|
|
|
|
if (enabled)
|
|
|
|
|
|
|
|
InkWell(
|
|
|
|
|
|
|
|
child: "remove".toSvgAsset(width: 16),
|
|
|
|
|
|
|
|
onTap: () {
|
|
|
|
|
|
|
|
onRemoveTap(file);
|
|
|
|
|
|
|
|
if (onRemove != null) {
|
|
|
|
|
|
|
|
onRemove!();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
4.height,
|
|
|
|
|
|
|
|
RichText(
|
|
|
|
|
|
|
|
text: TextSpan(
|
|
|
|
|
|
|
|
text: 'Asset Guide | ',
|
|
|
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral120),
|
|
|
|
|
|
|
|
children: <TextSpan>[
|
|
|
|
|
|
|
|
TextSpan(
|
|
|
|
|
|
|
|
text: 'View',
|
|
|
|
|
|
|
|
recognizer: TapGestureRecognizer()
|
|
|
|
|
|
|
|
..onTap = () async {
|
|
|
|
|
|
|
|
if (isImage) {
|
|
|
|
|
|
|
|
Navigator.of(context).push(
|
|
|
|
|
|
|
|
MaterialPageRoute(
|
|
|
|
|
|
|
|
builder: (_) => Scaffold(
|
|
|
|
|
|
|
|
appBar: const DefaultAppBar(),
|
|
|
|
|
|
|
|
body: SafeArea(
|
|
|
|
|
|
|
|
child: InteractiveViewer(
|
|
|
|
|
|
|
|
child: _isLocalUrl(file.path)
|
|
|
|
|
|
|
|
? Image.file(file)
|
|
|
|
|
|
|
|
: ImageLoader(
|
|
|
|
|
|
|
|
url: URLs.getFileUrl(file.path),
|
|
|
|
|
|
|
|
boxFit: BoxFit.cover,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
).center,
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
} else if (_isLocalUrl(file.path)) {
|
|
|
|
|
|
|
|
OpenFile.open(file.path);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (!await launchUrl(Uri.parse(URLs.getFileUrl(file.path)!), mode: LaunchMode.externalApplication)) {
|
|
|
|
|
|
|
|
Fluttertoast.showToast(msg: "UnExpected Error with file.");
|
|
|
|
|
|
|
|
throw Exception('Could not launch');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.primary10, decoration: TextDecoration.underline),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
).expanded
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return SizedBox(
|
|
|
|
return SizedBox(
|
|
|
|
width: 60.toScreenWidth,
|
|
|
|
width: 60.toScreenWidth,
|
|
|
|
height: 60.toScreenWidth,
|
|
|
|
height: 60.toScreenWidth,
|
|
|
|
|