You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cloudsolutions-atoms/lib/views/widgets/images/multi_image_picker_item.dart

73 lines
2.5 KiB
Dart

import 'dart:io';
import 'package:flutter/material.dart';
import 'package:test_sa/views/app_style/colors.dart';
import 'package:test_sa/views/app_style/sizing.dart';
import 'package:test_sa/views/widgets/buttons/app_back_button.dart';
class MultiFilesPickerItem extends StatelessWidget {
final File file;
final Function(File) onRemoveTap;
const MultiFilesPickerItem({Key key, this.file, this.onRemoveTap}) : super(key: key);
@override
Widget build(BuildContext context) {
var isImage = file.path.split(".").last.toLowerCase() == "png" || file.path.split(".").last.toLowerCase() == "jpg";
var isPdf = file.path.split(".").last.toLowerCase() == "pdf";
var isExcel = file.path.split(".").last.toLowerCase() == "xlsx";
return Container(
width: 80 * AppStyle.getScaleFactor(context),
height: 80 * AppStyle.getScaleFactor(context),
decoration: BoxDecoration(
boxShadow: [BoxShadow(color: isImage ? Colors.black38 : AColors.cyan.withOpacity(0.5), blurRadius: 2)],
image: DecorationImage(
image: isImage
? FileImage(file)
: AssetImage("assets/images/${isPdf ? "pdf" : isExcel ? "excel" : "doc"}.png"),
fit: BoxFit.cover,
),
borderRadius: BorderRadius.circular(8),
),
child: MaterialButton(
padding: EdgeInsets.zero,
onPressed: () {
if (isImage) {
Navigator.of(context).push(
MaterialPageRoute(
builder: (_) => Scaffold(
body: SafeArea(
child: Stack(
children: [
Center(child: isImage ? InteractiveViewer(child: Image(image: FileImage(file))) : const SizedBox.shrink()),
const ABackButton(),
],
),
),
),
),
);
}
},
child: Align(
alignment: Alignment.topRight,
child: IconButton(
padding: const EdgeInsets.all(2.0),
icon: Container(
padding: const EdgeInsets.all(1),
decoration: BoxDecoration(color: Theme.of(context).scaffoldBackgroundColor.withOpacity(.3), borderRadius: BorderRadius.circular(8)),
child: const Icon(
Icons.remove_circle,
color: AColors.red,
),
),
onPressed: () {
onRemoveTap(file);
},
),
),
),
);
}
}