2022-12-26 20:26:30 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2023-03-20 14:06:44 +00:00
|
|
|
import '../../controls/login_aware_cached_network_image.dart';
|
|
|
|
|
2022-12-26 20:26:30 +00:00
|
|
|
class MediaUploadAttachment {
|
|
|
|
final String localFilePath;
|
|
|
|
|
|
|
|
final String remoteUrl;
|
|
|
|
|
|
|
|
final bool isExistingServerItem;
|
|
|
|
|
|
|
|
String description;
|
|
|
|
|
|
|
|
String remoteFilename;
|
|
|
|
|
|
|
|
MediaUploadAttachment({
|
|
|
|
this.localFilePath = '',
|
|
|
|
this.remoteUrl = '',
|
|
|
|
this.isExistingServerItem = false,
|
|
|
|
this.description = '',
|
|
|
|
this.remoteFilename = '',
|
|
|
|
});
|
|
|
|
|
|
|
|
factory MediaUploadAttachment.newItem(String localFilename) =>
|
|
|
|
MediaUploadAttachment(
|
|
|
|
localFilePath: localFilename,
|
|
|
|
isExistingServerItem: false,
|
|
|
|
remoteFilename: '',
|
|
|
|
);
|
|
|
|
|
|
|
|
factory MediaUploadAttachment.existingItem(String remoteUrl) =>
|
|
|
|
MediaUploadAttachment(
|
|
|
|
remoteUrl: remoteUrl,
|
|
|
|
isExistingServerItem: true,
|
|
|
|
);
|
|
|
|
|
|
|
|
Widget getPreviewImage() {
|
|
|
|
if (isExistingServerItem) {
|
2023-03-20 14:06:44 +00:00
|
|
|
return LoginAwareCachedNetworkImage(imageUrl: remoteUrl);
|
2022-12-26 20:26:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Image.file(File(localFilePath));
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
return 'MediaUploadAttachment{localFilename: $localFilePath, remoteUrl: $remoteUrl, isExistingServerItem: $isExistingServerItem, description: $description}';
|
|
|
|
}
|
|
|
|
}
|