Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to match internal repo #12

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions example/lib/pages/components/file_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ class FilePickerDemo extends StatefulWidget {
class _FilePickerDemoState extends State<FilePickerDemo> {
final ZdsFilePickerController controller = ZdsFilePickerController();

static const pickerConfig = FilePickerConfig(
static const pickerConfig = ZdsFilePickerConfig(
maxFilesAllowed: 5,
maxFileSize: 2500000,
maxVideoTimeInSeconds: 10,
options: [
FilePickerOptions.FILE,
FilePickerOptions.GIF,
FilePickerOptions.LINK,
FilePickerOptions.CAMERA,
FilePickerOptions.GALLERY,
FilePickerOptions.VIDEO,
ZdsFilePickerOptions.FILE,
ZdsFilePickerOptions.GIF,
ZdsFilePickerOptions.LINK,
ZdsFilePickerOptions.CAMERA,
ZdsFilePickerOptions.GALLERY,
ZdsFilePickerOptions.VIDEO,
],
);

Expand Down
22 changes: 11 additions & 11 deletions lib/src/components/organisms/chat/message_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -134,28 +134,28 @@ class ZdsMessageInputState extends State<ZdsMessageInput> with SingleTickerProvi
setState(() => __hasText = value);
}

late final _moreConfig = FilePickerConfig(
late final _moreConfig = ZdsFilePickerConfig(
maxFilesAllowed: 1,
maxFileSize: widget.maxAttachSize,
allowedExtensions: widget.allowedFileTypes,
maxPixelSize: widget.maxPixelSize,
options: [
FilePickerOptions.FILE,
FilePickerOptions.GIF,
FilePickerOptions.GALLERY,
FilePickerOptions.VIDEO,
FilePickerOptions.CAMERA,
ZdsFilePickerOptions.FILE,
ZdsFilePickerOptions.GIF,
ZdsFilePickerOptions.GALLERY,
ZdsFilePickerOptions.VIDEO,
ZdsFilePickerOptions.CAMERA,
],
);

FilePickerConfig get _inlineConfig {
return FilePickerConfig(
ZdsFilePickerConfig get _inlineConfig {
return ZdsFilePickerConfig(
maxFilesAllowed: 1,
maxFileSize: widget.maxAttachSize,
allowedExtensions: widget.allowedFileTypes,
maxPixelSize: widget.maxPixelSize,
options: [
FilePickerOptions.CAMERA,
ZdsFilePickerOptions.CAMERA,
],
);
}
Expand Down Expand Up @@ -199,7 +199,7 @@ class ZdsMessageInputState extends State<ZdsMessageInput> with SingleTickerProvi
}
}

void _onFilesChanged(List<FileWrapper> items) {
void _onFilesChanged(List<ZdsFileWrapper> items) {
if (items.isEmpty) {
return;
} else if (items.first.content is XFile) {
Expand Down Expand Up @@ -378,7 +378,7 @@ class ZdsMessageInputState extends State<ZdsMessageInput> with SingleTickerProvi
final modalController = ZdsFilePickerController();
final zetaColors = Zeta.of(context).colors;
unawaited(
showZdsBottomSheet<FileWrapper>(
showZdsBottomSheet<ZdsFileWrapper>(
enforceSheet: true,
backgroundColor: zetaColors.surfacePrimary,
context: context,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class ZdsImageAnnotationPostProcessor implements ZdsFilePostProcessor {
final BuildContextProvider buildContext;

@override
Future<FileWrapper> process(FilePickerConfig config, FileWrapper file) async {
Future<ZdsFileWrapper> process(ZdsFilePickerConfig config, ZdsFileWrapper file) async {
if (kIsWeb) return file;

if (file.isImage() && file.content != null) {
final File originalFile = File(file.xFilePath);
final XFile? result = await _editFile(buildContext.call(), originalFile);
if (result != null) {
return FileWrapper(file.type, result);
return ZdsFileWrapper(file.type, result);
}
}

Expand Down
12 changes: 6 additions & 6 deletions lib/src/components/organisms/file_picker/file_compress.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ class ZdsFileCompressPostProcessor implements ZdsFilePostProcessor {
const ZdsFileCompressPostProcessor();

@override
Future<FileWrapper> process(FilePickerConfig config, FileWrapper file) async {
Future<ZdsFileWrapper> process(ZdsFilePickerConfig config, ZdsFileWrapper file) async {
if (kIsWeb) {
return file;
} else if (file.isImage()) {
return FileWrapper(file.type, await _compressImage(File(file.xFilePath), config));
return ZdsFileWrapper(file.type, await _compressImage(File(file.xFilePath), config));
} else if (file.isVideo()) {
return FileWrapper(
return ZdsFileWrapper(
file.type,
await _compressVideo(File(file.xFilePath), config),
);
Expand All @@ -36,7 +36,7 @@ class ZdsFileCompressPostProcessor implements ZdsFilePostProcessor {
}
}

Future<XFile> _compressVideo(File video, FilePickerConfig config) async {
Future<XFile> _compressVideo(File video, ZdsFilePickerConfig config) async {
try {
final String dir = await zdsTempDirectory();
final String fileExtension = path.extension(video.path).toLowerCase().replaceAll('.', '');
Expand Down Expand Up @@ -79,7 +79,7 @@ class ZdsFileCompressPostProcessor implements ZdsFilePostProcessor {
return qualityMap[config] ?? VideoQuality.Res640x480Quality;
}

Future<XFile> _compressImage(File image, FilePickerConfig config) async {
Future<XFile> _compressImage(File image, ZdsFilePickerConfig config) async {
try {
final int fileSize = config.maxFileSize == 0 ? _maxImageUploadSize : config.maxFileSize;
final int h = config.maxPixelSize <= 0 ? 1080 : config.maxPixelSize;
Expand Down Expand Up @@ -126,7 +126,7 @@ class ZdsFileCompressPostProcessor implements ZdsFilePostProcessor {
}
}

CompressFormat? _getCompressFormat(String extension, FilePickerConfig config) {
CompressFormat? _getCompressFormat(String extension, ZdsFilePickerConfig config) {
final Iterable<String> allowedExt = config.allowedExtensions.map((String e) => e.toLowerCase());

// If allowed file extension list is empty then return jpeg
Expand Down
4 changes: 2 additions & 2 deletions lib/src/components/organisms/file_picker/file_edit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ZdsFileEditPostProcessor implements ZdsFilePostProcessor {
final BuildContextProvider buildContext;

@override
Future<FileWrapper> process(FilePickerConfig config, FileWrapper file) async {
Future<ZdsFileWrapper> process(ZdsFilePickerConfig config, ZdsFileWrapper file) async {
if (kIsWeb) return file;

if (file.isImage() && file.content != null) {
Expand All @@ -42,7 +42,7 @@ class ZdsFileEditPostProcessor implements ZdsFilePostProcessor {
await originalFile.delete(recursive: true);
final File result = File(path.join(dir, path.basename(originalFile.absolute.path)));
await result.writeAsBytes(bytes);
return FileWrapper(file.type, ZdsXFile.fromFile(result));
return ZdsFileWrapper(file.type, ZdsXFile.fromFile(result));
}
}

Expand Down
Loading
Loading