From 25c20f929893cee4f86d984e59a46f144cb31c30 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 23 Dec 2022 11:57:28 +0100 Subject: [PATCH] feat: added icon mode --- .flutter-plugins-dependencies | 2 +- example/lib/media_picker.dart | 85 ++++++++++++++++++++++ example/pubspec.lock | 9 --- lib/src/abstracts/media_picker_input.dart | 3 +- lib/src/inputs/input_audio.dart | 9 ++- lib/src/inputs/input_file.dart | 7 +- lib/src/inputs/input_photo.dart | 7 +- lib/src/inputs/input_text.dart | 7 +- lib/src/inputs/input_video.dart | 4 +- lib/src/media_picker.dart | 33 ++++++--- lib/src/widgets/icon_button_with_text.dart | 37 ++++++++++ pubspec.yaml | 6 +- 12 files changed, 168 insertions(+), 41 deletions(-) create mode 100644 lib/src/widgets/icon_button_with_text.dart diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index cb2faf1..f844d2b 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","native_build":true,"dependencies":[]},{"name":"flutter_sound","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_sound-9.2.13\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_ios-0.8.6+2\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_ios-2.0.11\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_apple-9.0.7\\\\","native_build":true,"dependencies":[]},{"name":"video_player_avfoundation","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_avfoundation-2.3.8\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]},{"name":"flutter_sound","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_sound-9.2.13\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_android-0.8.5+4\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_android-2.0.22\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_android-10.2.0\\\\","native_build":true,"dependencies":[]},{"name":"video_player_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_android-2.3.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.6\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.1.7\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.1.3\\\\","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_windows-0.1.2\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","dependencies":[]},{"name":"flutter_sound_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_sound_web-9.2.13\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.1.10\\\\","dependencies":[]},{"name":"video_player_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_web-2.0.13\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_sound","dependencies":["path_provider","flutter_sound_web"]},{"name":"flutter_sound_web","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"video_player","dependencies":["video_player_android","video_player_avfoundation","video_player_web"]},{"name":"video_player_android","dependencies":[]},{"name":"video_player_avfoundation","dependencies":[]},{"name":"video_player_web","dependencies":[]}],"date_created":"2022-12-21 15:17:49.678650","version":"3.3.10"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","native_build":true,"dependencies":[]},{"name":"flutter_sound","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_sound-9.2.13\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_ios-0.8.6+2\\\\","native_build":true,"dependencies":[]},{"name":"path_provider_ios","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_ios-2.0.11\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler_apple","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_apple-9.0.7\\\\","native_build":true,"dependencies":[]},{"name":"video_player_avfoundation","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_avfoundation-2.3.8\\\\","native_build":true,"dependencies":[]}],"android":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_plugin_android_lifecycle-2.0.7\\\\","native_build":true,"dependencies":[]},{"name":"flutter_sound","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_sound-9.2.13\\\\","native_build":true,"dependencies":[]},{"name":"image_picker_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_android-0.8.5+4\\\\","native_build":true,"dependencies":["flutter_plugin_android_lifecycle"]},{"name":"path_provider_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_android-2.0.22\\\\","native_build":true,"dependencies":[]},{"name":"permission_handler_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_android-10.2.0\\\\","native_build":true,"dependencies":[]},{"name":"video_player_android","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_android-2.3.10\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.6\\\\","native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.1.7\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.1.3\\\\","native_build":false,"dependencies":[]},{"name":"permission_handler_windows","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler_windows-0.1.2\\\\","native_build":true,"dependencies":[]}],"web":[{"name":"file_picker","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\file_picker-5.2.4\\\\","dependencies":[]},{"name":"flutter_sound_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_sound_web-9.2.13\\\\","dependencies":[]},{"name":"image_picker_for_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\image_picker_for_web-2.1.10\\\\","dependencies":[]},{"name":"video_player_web","path":"C:\\\\src\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\video_player_web-2.0.13\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"file_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_sound","dependencies":["path_provider","flutter_sound_web"]},{"name":"flutter_sound_web","dependencies":[]},{"name":"image_picker","dependencies":["image_picker_android","image_picker_for_web","image_picker_ios"]},{"name":"image_picker_android","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"image_picker_for_web","dependencies":[]},{"name":"image_picker_ios","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":["permission_handler_android","permission_handler_apple","permission_handler_windows"]},{"name":"permission_handler_android","dependencies":[]},{"name":"permission_handler_apple","dependencies":[]},{"name":"permission_handler_windows","dependencies":[]},{"name":"video_player","dependencies":["video_player_android","video_player_avfoundation","video_player_web"]},{"name":"video_player_android","dependencies":[]},{"name":"video_player_avfoundation","dependencies":[]},{"name":"video_player_web","dependencies":[]}],"date_created":"2022-12-23 09:33:52.599699","version":"3.3.10"} \ No newline at end of file diff --git a/example/lib/media_picker.dart b/example/lib/media_picker.dart index a8b7076..dcb0f77 100644 --- a/example/lib/media_picker.dart +++ b/example/lib/media_picker.dart @@ -58,10 +58,14 @@ class _MediaPickerState extends ConsumerState { const SizedBox( height: 15, ), + // Icons example of Media Picker MediaPicker( buttonType: ButtonType.icons, + horizontalSpacing: 40, + verticalSpacing: 20, mediaPickerInputs: [ MediaPickerInputPhoto( + label: "Make photo", pickFile: mediaService.pickImageFile, checkPageSettings: { 'title': 'Share photo', @@ -73,6 +77,7 @@ class _MediaPickerState extends ConsumerState { }, ), MediaPickerInputVideo( + label: "Make video", pickFile: mediaService.pickVideoFile, videoPlayerFactory: MediaPickerVideoPlayerFactory(), checkPageSettings: { @@ -86,6 +91,7 @@ class _MediaPickerState extends ConsumerState { ), if (!kIsWeb) MediaPickerInputAudio( + label: "Record audio", checkPageSettings: {'title': 'Share audio'}, onComplete: (MediaResult result) { Navigator.pop(context); @@ -93,12 +99,14 @@ class _MediaPickerState extends ConsumerState { audioService: audioService, ), MediaPickerInputText( + label: "Write text", checkPageSettings: {'title': 'Share text'}, onComplete: (MediaResult result) { Navigator.pop(context); }, ), MediaPickerInputFile( + label: "Select file", pickFile: mediaService.pickFile, fileExtensions: [ 'pdf', @@ -128,6 +136,83 @@ class _MediaPickerState extends ConsumerState { onComplete: onComplete, ), ), + + // Text example of Media Picker + // MediaPicker( + // buttonType: ButtonType.text, + // mediaPickerInputs: [ + // MediaPickerInputPhoto( + // label: "Make photo", + // pickFile: mediaService.pickImageFile, + // checkPageSettings: { + // 'title': 'Share photo', + // 'width': 125.0, + // 'height': 200.0, + // }, + // onComplete: (MediaResult result) { + // Navigator.pop(context); + // }, + // ), + // MediaPickerInputVideo( + // label: "Make video", + // pickFile: mediaService.pickVideoFile, + // videoPlayerFactory: MediaPickerVideoPlayerFactory(), + // checkPageSettings: { + // 'title': 'Share video', + // 'width': 122.5, + // 'height': 200.0, + // }, + // onComplete: (MediaResult result) { + // Navigator.pop(context); + // }, + // ), + // if (!kIsWeb) + // MediaPickerInputAudio( + // label: "Record audio", + // checkPageSettings: {'title': 'Share audio'}, + // onComplete: (MediaResult result) { + // Navigator.pop(context); + // }, + // audioService: audioService, + // ), + // MediaPickerInputText( + // label: "Write text", + // checkPageSettings: {'title': 'Share text'}, + // onComplete: (MediaResult result) { + // Navigator.pop(context); + // }, + // ), + // MediaPickerInputFile( + // label: "Select file", + // pickFile: mediaService.pickFile, + // fileExtensions: [ + // 'pdf', + // 'doc', + // 'png', + // 'jpg', + // 'docx', + // 'bmp', + // 'gif', + // 'txt', + // ], + // checkPageSettings: { + // 'title': 'Share file', + // }, + // onComplete: (MediaResult result) { + // Navigator.pop(context); + // }, + // ), + // ], + // mediaCheckPage: (Widget displayResult, + // Map? inputSettings, + // Function onComplete) => + // MediaCheckPage( + // cancel: widget.callback, + // displayResult: displayResult, + // inputSettings: inputSettings ?? {}, + // onComplete: onComplete, + // ), + // ), const SizedBox( height: 30, ), diff --git a/example/pubspec.lock b/example/pubspec.lock index 31a5c10..a249f75 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -113,15 +113,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.18.5+1" - flutter_image_picker: - dependency: transitive - description: - path: "." - ref: "1.0.3" - resolved-ref: "20814755cca74296600a0ae3e016e46979e66a7e" - url: "https://github.com/Iconica-Development/flutter_image_picker" - source: git - version: "1.0.3" flutter_lints: dependency: "direct dev" description: diff --git a/lib/src/abstracts/media_picker_input.dart b/lib/src/abstracts/media_picker_input.dart index 966231d..7c4b78f 100644 --- a/lib/src/abstracts/media_picker_input.dart +++ b/lib/src/abstracts/media_picker_input.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_media_picker/src/enums/button_type.dart'; import 'package:flutter_media_picker/src/media_result.dart'; +import 'package:flutter_media_picker/src/widgets/icon_button_with_text.dart'; /// Abstract class for inputs used by [MediaPicker]. /// @@ -24,7 +25,7 @@ import 'package:flutter_media_picker/src/media_result.dart'; abstract class MediaPickerInput { String label = "Media Picker input"; - Widget icon = const Icon(Icons.image); + Widget icon = const IconButtonWithText(); Future onPressed(BuildContext context); diff --git a/lib/src/inputs/input_audio.dart b/lib/src/inputs/input_audio.dart index 3a6b227..dd760d8 100644 --- a/lib/src/inputs/input_audio.dart +++ b/lib/src/inputs/input_audio.dart @@ -7,21 +7,24 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_media_picker/flutter_media_picker.dart'; +import 'package:flutter_media_picker/src/widgets/icon_button_with_text.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:intl/intl.dart'; /// Input for audio used by [MediaPicker]. /// -/// This feature is only usable for nativa applications. +/// This feature is only usable for native applications. class MediaPickerInputAudio implements MediaPickerInput { MediaPickerInputAudio({ this.label = "Audio", - this.icon = const Icon(Icons.audio_file), this.checkPageSettings, this.onComplete, required this.audioService, this.inputStyling, - }); + }) : icon = IconButtonWithText( + icon: Icons.record_voice_over, + iconText: label, + ); final AudioService audioService; diff --git a/lib/src/inputs/input_file.dart b/lib/src/inputs/input_file.dart index abfb69e..705b82c 100644 --- a/lib/src/inputs/input_file.dart +++ b/lib/src/inputs/input_file.dart @@ -4,24 +4,21 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_media_picker/src/abstracts/media_picker_input.dart'; +import 'package:flutter_media_picker/src/widgets/icon_button_with_text.dart'; import 'package:path/path.dart' as path; -import 'package:flutter_media_picker/src/media_result.dart'; - import '../../flutter_media_picker.dart'; /// Input for photo used by [MediaPicker]. class MediaPickerInputFile implements MediaPickerInput { MediaPickerInputFile({ this.label = "File", - this.icon = const Icon(Icons.file_copy), this.fileExtensions = const ['pdf', 'jpg', 'png'], this.checkPageSettings, this.onComplete, this.pickFile, - }); + }) : icon = IconButtonWithText(icon: Icons.file_copy, iconText: label,); final Future Function(List)? pickFile; final List fileExtensions; diff --git a/lib/src/inputs/input_photo.dart b/lib/src/inputs/input_photo.dart index 7179fe5..8ae962a 100644 --- a/lib/src/inputs/input_photo.dart +++ b/lib/src/inputs/input_photo.dart @@ -8,16 +8,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_media_picker/src/abstracts/media_picker_input.dart'; import 'package:flutter_media_picker/src/media_result.dart'; +import 'package:flutter_media_picker/src/widgets/icon_button_with_text.dart'; /// Input for photo used by [MediaPicker]. class MediaPickerInputPhoto implements MediaPickerInput { MediaPickerInputPhoto({ this.label = "Photo", - this.icon = const Icon(Icons.image), this.checkPageSettings, this.onComplete, this.pickFile, - }); + }) : icon = IconButtonWithText( + icon: Icons.camera_alt, + iconText: label, + ); final Future Function()? pickFile; diff --git a/lib/src/inputs/input_text.dart b/lib/src/inputs/input_text.dart index 01d86fe..b2bce09 100644 --- a/lib/src/inputs/input_text.dart +++ b/lib/src/inputs/input_text.dart @@ -6,16 +6,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_form/flutter_form.dart'; import 'package:flutter_media_picker/src/abstracts/media_picker_input.dart'; import 'package:flutter_media_picker/src/media_result.dart'; +import 'package:flutter_media_picker/src/widgets/icon_button_with_text.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart'; /// Input for text used by [MediaPicker]. class MediaPickerInputText implements MediaPickerInput { MediaPickerInputText({ this.label = "Text", - this.icon = const Icon(Icons.text_fields), this.checkPageSettings, this.onComplete, - }); + }) : icon = IconButtonWithText( + icon: Icons.text_fields, + iconText: label, + ); @override String label; diff --git a/lib/src/inputs/input_video.dart b/lib/src/inputs/input_video.dart index 1d3d8a5..8b126dc 100644 --- a/lib/src/inputs/input_video.dart +++ b/lib/src/inputs/input_video.dart @@ -6,17 +6,17 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_media_picker/flutter_media_picker.dart'; +import 'package:flutter_media_picker/src/widgets/icon_button_with_text.dart'; /// Input for video used by [MediaPicker]. class MediaPickerInputVideo implements MediaPickerInput { MediaPickerInputVideo({ this.label = "Video", - this.icon = const Icon(Icons.video_camera_front), this.checkPageSettings, this.onComplete, this.pickFile, required this.videoPlayerFactory, - }); + }) : icon = IconButtonWithText(icon: Icons.video_camera_front, iconText: label,); final Future Function()? pickFile; final VideoPlayerFactory videoPlayerFactory; diff --git a/lib/src/media_picker.dart b/lib/src/media_picker.dart index 0430a33..876d7c8 100644 --- a/lib/src/media_picker.dart +++ b/lib/src/media_picker.dart @@ -100,6 +100,7 @@ import '../flutter_media_picker.dart'; /// ], /// ); ///``` + class MediaPicker extends ConsumerWidget { const MediaPicker({ this.mediaPickerInputs, @@ -108,6 +109,8 @@ class MediaPicker extends ConsumerWidget { this.onComplete, this.mediaCheckPage, this.buttonType = ButtonType.text, + this.horizontalSpacing = 0, + this.verticalSpacing = 0, Key? key, }) : super(key: key); @@ -117,6 +120,8 @@ class MediaPicker extends ConsumerWidget { iconButton; final void Function(MediaResult result)? onComplete; final ButtonType buttonType; + final double horizontalSpacing; + final double verticalSpacing; final Widget Function( Widget displayResult, Map? inputSettings, @@ -139,7 +144,11 @@ class MediaPicker extends ConsumerWidget { inputs = mediaPickerInputs!; } - return Column( + return Wrap( + alignment: WrapAlignment.center, + direction: Axis.horizontal, + spacing: horizontalSpacing, + runSpacing: verticalSpacing, children: [ if (buttonType == ButtonType.text) ...[ for (final input in inputs) ...[ @@ -180,17 +189,17 @@ class MediaPicker extends ConsumerWidget { for (final input in inputs) ...[ iconButton?.call(input.label, input.icon, (BuildContext ct) async { await onPressedMediaType(ct, input); - }) ?? GestureDetector( - onTap: () async { - await onPressedMediaType(context, input); - }, - child: Column( - children: [ - input.icon, - Text(input.label), - ], - ), - ) + }) ?? + GestureDetector( + onTap: () async { + await onPressedMediaType(context, input); + }, + child: Wrap( + children: [ + input.icon, + ], + ), + ), ], ] ], diff --git a/lib/src/widgets/icon_button_with_text.dart b/lib/src/widgets/icon_button_with_text.dart new file mode 100644 index 0000000..dc295c0 --- /dev/null +++ b/lib/src/widgets/icon_button_with_text.dart @@ -0,0 +1,37 @@ +import 'package:flutter/material.dart'; + +class IconButtonWithText extends StatelessWidget { + const IconButtonWithText({ + super.key, + this.iconSize = 40, + this.iconText = "Button", + this.iconTextSize = 16, + this.icon = Icons.file_copy, + }); + + final double iconSize; + final String iconText; + final double iconTextSize; + final IconData icon; + + @override + Widget build(BuildContext context) { + + return FittedBox( + fit: BoxFit.fitHeight, + child: Column( + children: [ + Icon( + icon, + size: iconSize, + ), + Text( + iconText, + style: TextStyle(fontSize: iconTextSize), + textAlign: TextAlign.center, + ), + ], + ), + ); + } +} diff --git a/pubspec.yaml b/pubspec.yaml index f88e480..4a0ae74 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,10 +12,8 @@ dependencies: flutter: sdk: flutter - flutter_image_picker: - git: - url: https://github.com/Iconica-Development/flutter_image_picker - ref: 1.0.3 + path: any + image_picker: any file_picker: any video_player: any path_provider: any