mirror of
https://github.com/Iconica-Development/flutter_media_picker.git
synced 2025-05-19 00:43:45 +02:00
fix: item sizes
This commit is contained in:
parent
8f7d254d35
commit
56bee57053
3 changed files with 71 additions and 96 deletions
|
@ -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<MediaPickerExample> {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var mediaService = MediaPickerFileService();
|
||||
var audioService = MediaPickerAudioService();
|
||||
return Wrap(
|
||||
children: [
|
||||
Container(
|
||||
|
@ -59,14 +58,17 @@ class _MediaPickerExampleState extends State<MediaPickerExample> {
|
|||
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<MediaPickerExample> {
|
|||
),
|
||||
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<MediaPickerExample> {
|
|||
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),
|
||||
MediaPickerInputVideo(
|
||||
label: 'Make video',
|
||||
widget: const IconButtonWithText(
|
||||
icon: Icons.video_camera_front,
|
||||
iconText: "Make video",
|
||||
iconSize: 48,
|
||||
),
|
||||
child: Center(
|
||||
child: Text(
|
||||
'Back',
|
||||
style: Theme.of(context).textTheme.labelLarge,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
audioService: audioService,
|
||||
),
|
||||
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) {
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<MediaPickerInput>? 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<MediaPicker> {
|
|||
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<MediaPicker> {
|
|||
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,8 +254,14 @@ class _MediaPickerState extends State<MediaPicker> {
|
|||
},
|
||||
child: Wrap(
|
||||
children: [
|
||||
input.widget ??
|
||||
Container(
|
||||
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(
|
||||
|
@ -258,6 +278,7 @@ class _MediaPickerState extends State<MediaPicker> {
|
|||
padding: const EdgeInsets.only(left: 15),
|
||||
child: Text(
|
||||
input.label,
|
||||
overflow: TextOverflow.clip,
|
||||
style: theme.textTheme.titleLarge,
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue