From 14c9301d2438abf2ade5b6d7861f22b7e7827842 Mon Sep 17 00:00:00 2001 From: Vick Top Date: Mon, 26 Feb 2024 10:50:11 +0100 Subject: [PATCH] doc: create documentation for files --- lib/src/inputs/input_file.dart | 36 +++++++++++++++++++--------- lib/src/inputs/input_photo.dart | 42 +++++++++++++++++++++------------ lib/src/inputs/input_text.dart | 32 +++++++++++++++---------- 3 files changed, 72 insertions(+), 38 deletions(-) diff --git a/lib/src/inputs/input_file.dart b/lib/src/inputs/input_file.dart index ec4bdf8..6b99905 100644 --- a/lib/src/inputs/input_file.dart +++ b/lib/src/inputs/input_file.dart @@ -10,6 +10,27 @@ import '../../flutter_media_picker.dart'; /// Input for file used by [MediaPicker]. class MediaPickerInputFile implements MediaPickerInput { + /// Label for the file input. + @override + String label; + + /// Widget for the file input. + @override + Widget? widget; + + /// List of file extensions allowed. + final List fileExtensions; + + /// Factory for creating video players. + final VideoPlayerFactory videoPlayerFactory = MediaPickerVideoPlayerFactory(); + + /// Service for handling audio operations. + final AudioService audioService = MediaPickerAudioService(); + + /// Callback to pick a file. + final Future Function(List)? pickFile; + + /// Constructor for [MediaPickerInputFile]. MediaPickerInputFile({ this.label = 'File', this.widget, @@ -19,17 +40,7 @@ class MediaPickerInputFile implements MediaPickerInput { this.pickFile, }); - final Future Function(List)? pickFile; - final List fileExtensions; - final VideoPlayerFactory videoPlayerFactory = MediaPickerVideoPlayerFactory(); - final AudioService audioService = MediaPickerAudioService(); - - @override - String label; - - @override - Widget? widget; - + /// Method to handle button press for picking a file. @override Future onPressed(BuildContext context) async { var filePicked = await pickFile?.call(fileExtensions); @@ -47,6 +58,7 @@ class MediaPickerInputFile implements MediaPickerInput { return MediaResult(); } + /// Method to display the result of picking a file. @override Future displayResult(MediaResult result) async { if (result.fileValue != null) { @@ -92,9 +104,11 @@ class MediaPickerInputFile implements MediaPickerInput { return Text(result.fileName!); } + /// Map for checking page settings. @override Map? checkPageSettings; + /// Callback function when the input is completed. @override void Function(MediaResult value)? onComplete; } diff --git a/lib/src/inputs/input_photo.dart b/lib/src/inputs/input_photo.dart index fe555d1..e353bec 100644 --- a/lib/src/inputs/input_photo.dart +++ b/lib/src/inputs/input_photo.dart @@ -9,22 +9,40 @@ import 'package:mime/mime.dart'; /// Input for photo used by [MediaPicker]. class MediaPickerInputPhoto implements MediaPickerInput { + /// Function to pick a file for photo input. + final Future Function()? pickFile; + + /// Label for the photo input. + @override + String label; + + /// Widget representing the photo input. + @override + Widget? widget; + + /// Map containing settings to check the page. + @override + Map? checkPageSettings; + + /// Callback function called when the photo input is completed. + @override + void Function(MediaResult value)? onComplete; + + /// Constructor for [MediaPickerInputPhoto]. + /// + /// [pickFile]: Function to pick a file for photo input. + /// [label]: Label for the photo input. Defaults to 'Photo'. + /// [widget]: Widget representing the photo input. + /// [checkPageSettings]: Map containing settings to check the page. + /// [onComplete]: Callback function called when the photo input is completed. MediaPickerInputPhoto({ + this.pickFile, this.label = 'Photo', this.widget, this.checkPageSettings, this.onComplete, - this.pickFile, }); - final Future Function()? pickFile; - - @override - String label; - - @override - Widget? widget; - @override Future onPressed(BuildContext context) async { var image = await pickFile?.call(); @@ -52,10 +70,4 @@ class MediaPickerInputPhoto implements MediaPickerInput { return Container(); } - - @override - Map? checkPageSettings; - - @override - void Function(MediaResult value)? onComplete; } diff --git a/lib/src/inputs/input_text.dart b/lib/src/inputs/input_text.dart index 5385d0f..d4935e8 100644 --- a/lib/src/inputs/input_text.dart +++ b/lib/src/inputs/input_text.dart @@ -9,6 +9,23 @@ import 'package:flutter_media_picker/src/media_result.dart'; /// Input for text used by [MediaPicker]. class MediaPickerInputText implements MediaPickerInput { + /// Label for the text input. + @override + String label; + + /// Widget for the text input. + @override + Widget? widget; + + /// Map for checking page settings. + @override + Map? checkPageSettings; + + /// Callback function when the input is completed. + @override + void Function(MediaResult value)? onComplete; + + /// Constructor for [MediaPickerInputText]. MediaPickerInputText({ this.label = 'Text', this.widget, @@ -16,29 +33,20 @@ class MediaPickerInputText implements MediaPickerInput { this.onComplete, }); - @override - String label; - - @override - Widget? widget; - + /// Method to handle button press for picking text. @override Future onPressed(BuildContext context) async { return MediaResult(mimeType: 'plain/text'); } + /// Method to display the result of picking text. @override Future displayResult(MediaResult result) async { return const DisplayText(); } - - @override - Map? checkPageSettings; - - @override - void Function(MediaResult value)? onComplete; } +/// Widget to display text input. class DisplayText extends StatefulWidget { const DisplayText({Key? key}) : super(key: key);