diff --git a/example/lib/media_picker.dart b/example/lib/media_picker.dart index c1dae84..f1c1ff9 100644 --- a/example/lib/media_picker.dart +++ b/example/lib/media_picker.dart @@ -3,7 +3,7 @@ // SPDX-License-Identifier: BSD-3-Clause import 'package:example/media_picker_check.dart'; -import 'package:flutter/foundation.dart'; +import 'package:example/widgets/icon_button_with_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_media_picker/flutter_media_picker.dart'; @@ -20,7 +20,6 @@ class _MediaPickerExampleState extends State { @override Widget build(BuildContext context) { var mediaService = MediaPickerFileService(); - var audioService = MediaPickerAudioService(); return Wrap( children: [ Container( @@ -59,14 +58,17 @@ class _MediaPickerExampleState extends State { height: 15, ), MediaPicker( + // horizontalSpacing: 20, loadingIconColor: Theme.of(context).colorScheme.secondary, + indiviualWidgetWidth: MediaQuery.of(context).size.width / 3, mediaPickerInputs: [ MediaPickerInputPhoto( label: 'Make photo', - // widget: const IconButtonWithText( - // icon: Icons.photo, - // iconText: "Make photo", - // ), + widget: const IconButtonWithText( + icon: Icons.video_camera_front, + iconText: "Make photo Make photo", + iconSize: 48, + ), pickFile: mediaService.pickImageFile, checkPageSettings: { 'title': 'Share photo', @@ -79,10 +81,11 @@ class _MediaPickerExampleState extends State { ), MediaPickerInputVideo( label: 'Make video', - // widget: const IconButtonWithText( - // icon: Icons.video_camera_front, - // iconText: "Make video", - // ), + widget: const IconButtonWithText( + icon: Icons.video_camera_front, + iconText: "Make video", + iconSize: 48, + ), pickFile: mediaService.pickVideoFile, videoPlayerFactory: MediaPickerVideoPlayerFactory(), checkPageSettings: { @@ -94,69 +97,18 @@ class _MediaPickerExampleState extends State { Navigator.pop(context); }, ), - if (!kIsWeb) - MediaPickerInputAudio( - label: 'Record audio', - // widget: const IconButtonWithText( - // icon: Icons.record_voice_over, - // iconText: "Record audio", - // ), - checkPageSettings: {'title': 'Share audio'}, - onComplete: (MediaResult result) => - Navigator.pop(context), - inputStyling: AudioInputStyling( - leftButton: (_, __) => GestureDetector( - onTap: () async => Navigator.pop(context), - child: Container( - width: MediaQuery.of(context).size.width * 0.3, - height: 45, - decoration: BoxDecoration( - color: const Color(0xFFD8D8D8), - borderRadius: BorderRadius.circular(15), - ), - child: Center( - child: Text( - 'Back', - style: Theme.of(context).textTheme.labelLarge, - ), - ), - ), - ), - ), - audioService: audioService, + MediaPickerInputVideo( + label: 'Make video', + widget: const IconButtonWithText( + icon: Icons.video_camera_front, + iconText: "Make video", + iconSize: 48, ), - MediaPickerInputText( - label: 'Write text', - // widget: const IconButtonWithText( - // icon: Icons.text_fields, - // iconText: "Write text", - // ), - checkPageSettings: {'title': 'Share text'}, - onComplete: (MediaResult result) { - Navigator.pop(context); - }, - ), - MediaPickerInputFile( - label: 'Select file', - // widget: const IconButtonWithText( - // icon: Icons.file_copy, - // iconText: "Select file", - // ), - pickFile: mediaService.pickFile, - fileExtensions: [ - 'pdf', - 'doc', - 'png', - 'jpg', - 'docx', - 'bmp', - 'gif', - 'txt', - 'mp4', - 'mp3', - ], + pickFile: mediaService.pickVideoFile, + videoPlayerFactory: MediaPickerVideoPlayerFactory(), checkPageSettings: { - 'title': 'Share file', + 'title': 'Share video', + 'width': 122.5, 'height': 200.0, }, onComplete: (MediaResult result) { diff --git a/example/lib/widgets/icon_button_with_text.dart b/example/lib/widgets/icon_button_with_text.dart index 5fb6097..4ab3c09 100644 --- a/example/lib/widgets/icon_button_with_text.dart +++ b/example/lib/widgets/icon_button_with_text.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; class IconButtonWithText extends StatelessWidget { const IconButtonWithText({ super.key, + this.width = 150, this.iconSize = 40, this.iconText = 'Button', this.iconTextSize = 16, @@ -14,14 +15,15 @@ class IconButtonWithText extends StatelessWidget { }); final double iconSize; + final double width; final String iconText; final double iconTextSize; final IconData icon; @override Widget build(BuildContext context) { - return FittedBox( - fit: BoxFit.fitHeight, + return SizedBox( + width: width, child: Column( children: [ Icon( diff --git a/lib/src/media_picker.dart b/lib/src/media_picker.dart index dfd6a59..c8a6960 100644 --- a/lib/src/media_picker.dart +++ b/lib/src/media_picker.dart @@ -104,6 +104,7 @@ class MediaPicker extends StatefulWidget { const MediaPicker({ this.mediaPickerInputs, this.inputsDirection = Axis.horizontal, + this.indiviualWidgetWidth, this.onComplete, this.mediaCheckPage, this.horizontalSpacing = 0, @@ -115,6 +116,7 @@ class MediaPicker extends StatefulWidget { final List? mediaPickerInputs; final void Function(MediaResult result)? onComplete; + final double? indiviualWidgetWidth; final Axis inputsDirection; final double horizontalSpacing; final double verticalSpacing; @@ -166,10 +168,18 @@ class _MediaPickerState extends State { for (final input in inputs) ...[ if (isInputDisabled(input)) ...[ IgnorePointer( - child: gestureDetectorWidget(input, theme), + child: gestureDetectorWidget( + input, + theme, + widget.indiviualWidgetWidth ?? + MediaQuery.of(context).size.width / 2), ) ] else ...[ - gestureDetectorWidget(input, theme), + gestureDetectorWidget( + input, + theme, + widget.indiviualWidgetWidth ?? + MediaQuery.of(context).size.width / 2), ], ] ] @@ -230,7 +240,11 @@ class _MediaPickerState extends State { return content.fileValue != null || content.textValue != null; } - Widget gestureDetectorWidget(MediaPickerInput input, ThemeData theme) { + Widget gestureDetectorWidget( + MediaPickerInput input, + ThemeData theme, + double width, + ) { return GestureDetector( onTap: () async { setState(() { @@ -240,29 +254,36 @@ class _MediaPickerState extends State { }, child: Wrap( children: [ - input.widget ?? - Container( - height: 55, - width: MediaQuery.of(context).size.width * 0.9, - decoration: const BoxDecoration( - border: Border( - bottom: BorderSide( - color: Color(0xFF979797), - width: 1, + input.widget != null + ? SizedBox( + width: width, + child: Center( + child: input.widget, + ), + ) + : Container( + height: 55, + width: MediaQuery.of(context).size.width * 0.9, + decoration: const BoxDecoration( + border: Border( + bottom: BorderSide( + color: Color(0xFF979797), + width: 1, + ), + ), + ), + child: Align( + alignment: Alignment.centerLeft, + child: Padding( + padding: const EdgeInsets.only(left: 15), + child: Text( + input.label, + overflow: TextOverflow.clip, + style: theme.textTheme.titleLarge, + ), ), ), ), - child: Align( - alignment: Alignment.centerLeft, - child: Padding( - padding: const EdgeInsets.only(left: 15), - child: Text( - input.label, - style: theme.textTheme.titleLarge, - ), - ), - ), - ), ], ), );