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
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
import 'package:example/media_picker_check.dart';
|
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/material.dart';
|
||||||
import 'package:flutter_media_picker/flutter_media_picker.dart';
|
import 'package:flutter_media_picker/flutter_media_picker.dart';
|
||||||
|
|
||||||
|
@ -20,7 +20,6 @@ class _MediaPickerExampleState extends State<MediaPickerExample> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var mediaService = MediaPickerFileService();
|
var mediaService = MediaPickerFileService();
|
||||||
var audioService = MediaPickerAudioService();
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
|
@ -59,14 +58,17 @@ class _MediaPickerExampleState extends State<MediaPickerExample> {
|
||||||
height: 15,
|
height: 15,
|
||||||
),
|
),
|
||||||
MediaPicker(
|
MediaPicker(
|
||||||
|
// horizontalSpacing: 20,
|
||||||
loadingIconColor: Theme.of(context).colorScheme.secondary,
|
loadingIconColor: Theme.of(context).colorScheme.secondary,
|
||||||
|
indiviualWidgetWidth: MediaQuery.of(context).size.width / 3,
|
||||||
mediaPickerInputs: [
|
mediaPickerInputs: [
|
||||||
MediaPickerInputPhoto(
|
MediaPickerInputPhoto(
|
||||||
label: 'Make photo',
|
label: 'Make photo',
|
||||||
// widget: const IconButtonWithText(
|
widget: const IconButtonWithText(
|
||||||
// icon: Icons.photo,
|
icon: Icons.video_camera_front,
|
||||||
// iconText: "Make photo",
|
iconText: "Make photo Make photo",
|
||||||
// ),
|
iconSize: 48,
|
||||||
|
),
|
||||||
pickFile: mediaService.pickImageFile,
|
pickFile: mediaService.pickImageFile,
|
||||||
checkPageSettings: {
|
checkPageSettings: {
|
||||||
'title': 'Share photo',
|
'title': 'Share photo',
|
||||||
|
@ -79,10 +81,11 @@ class _MediaPickerExampleState extends State<MediaPickerExample> {
|
||||||
),
|
),
|
||||||
MediaPickerInputVideo(
|
MediaPickerInputVideo(
|
||||||
label: 'Make video',
|
label: 'Make video',
|
||||||
// widget: const IconButtonWithText(
|
widget: const IconButtonWithText(
|
||||||
// icon: Icons.video_camera_front,
|
icon: Icons.video_camera_front,
|
||||||
// iconText: "Make video",
|
iconText: "Make video",
|
||||||
// ),
|
iconSize: 48,
|
||||||
|
),
|
||||||
pickFile: mediaService.pickVideoFile,
|
pickFile: mediaService.pickVideoFile,
|
||||||
videoPlayerFactory: MediaPickerVideoPlayerFactory(),
|
videoPlayerFactory: MediaPickerVideoPlayerFactory(),
|
||||||
checkPageSettings: {
|
checkPageSettings: {
|
||||||
|
@ -94,69 +97,18 @@ class _MediaPickerExampleState extends State<MediaPickerExample> {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (!kIsWeb)
|
MediaPickerInputVideo(
|
||||||
MediaPickerInputAudio(
|
label: 'Make video',
|
||||||
label: 'Record audio',
|
widget: const IconButtonWithText(
|
||||||
// widget: const IconButtonWithText(
|
icon: Icons.video_camera_front,
|
||||||
// icon: Icons.record_voice_over,
|
iconText: "Make video",
|
||||||
// iconText: "Record audio",
|
iconSize: 48,
|
||||||
// ),
|
|
||||||
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,
|
|
||||||
),
|
),
|
||||||
MediaPickerInputText(
|
pickFile: mediaService.pickVideoFile,
|
||||||
label: 'Write text',
|
videoPlayerFactory: MediaPickerVideoPlayerFactory(),
|
||||||
// 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',
|
|
||||||
],
|
|
||||||
checkPageSettings: {
|
checkPageSettings: {
|
||||||
'title': 'Share file',
|
'title': 'Share video',
|
||||||
|
'width': 122.5,
|
||||||
'height': 200.0,
|
'height': 200.0,
|
||||||
},
|
},
|
||||||
onComplete: (MediaResult result) {
|
onComplete: (MediaResult result) {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
|
||||||
class IconButtonWithText extends StatelessWidget {
|
class IconButtonWithText extends StatelessWidget {
|
||||||
const IconButtonWithText({
|
const IconButtonWithText({
|
||||||
super.key,
|
super.key,
|
||||||
|
this.width = 150,
|
||||||
this.iconSize = 40,
|
this.iconSize = 40,
|
||||||
this.iconText = 'Button',
|
this.iconText = 'Button',
|
||||||
this.iconTextSize = 16,
|
this.iconTextSize = 16,
|
||||||
|
@ -14,14 +15,15 @@ class IconButtonWithText extends StatelessWidget {
|
||||||
});
|
});
|
||||||
|
|
||||||
final double iconSize;
|
final double iconSize;
|
||||||
|
final double width;
|
||||||
final String iconText;
|
final String iconText;
|
||||||
final double iconTextSize;
|
final double iconTextSize;
|
||||||
final IconData icon;
|
final IconData icon;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return FittedBox(
|
return SizedBox(
|
||||||
fit: BoxFit.fitHeight,
|
width: width,
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Icon(
|
Icon(
|
||||||
|
|
|
@ -104,6 +104,7 @@ class MediaPicker extends StatefulWidget {
|
||||||
const MediaPicker({
|
const MediaPicker({
|
||||||
this.mediaPickerInputs,
|
this.mediaPickerInputs,
|
||||||
this.inputsDirection = Axis.horizontal,
|
this.inputsDirection = Axis.horizontal,
|
||||||
|
this.indiviualWidgetWidth,
|
||||||
this.onComplete,
|
this.onComplete,
|
||||||
this.mediaCheckPage,
|
this.mediaCheckPage,
|
||||||
this.horizontalSpacing = 0,
|
this.horizontalSpacing = 0,
|
||||||
|
@ -115,6 +116,7 @@ class MediaPicker extends StatefulWidget {
|
||||||
|
|
||||||
final List<MediaPickerInput>? mediaPickerInputs;
|
final List<MediaPickerInput>? mediaPickerInputs;
|
||||||
final void Function(MediaResult result)? onComplete;
|
final void Function(MediaResult result)? onComplete;
|
||||||
|
final double? indiviualWidgetWidth;
|
||||||
final Axis inputsDirection;
|
final Axis inputsDirection;
|
||||||
final double horizontalSpacing;
|
final double horizontalSpacing;
|
||||||
final double verticalSpacing;
|
final double verticalSpacing;
|
||||||
|
@ -166,10 +168,18 @@ class _MediaPickerState extends State<MediaPicker> {
|
||||||
for (final input in inputs) ...[
|
for (final input in inputs) ...[
|
||||||
if (isInputDisabled(input)) ...[
|
if (isInputDisabled(input)) ...[
|
||||||
IgnorePointer(
|
IgnorePointer(
|
||||||
child: gestureDetectorWidget(input, theme),
|
child: gestureDetectorWidget(
|
||||||
|
input,
|
||||||
|
theme,
|
||||||
|
widget.indiviualWidgetWidth ??
|
||||||
|
MediaQuery.of(context).size.width / 2),
|
||||||
)
|
)
|
||||||
] else ...[
|
] 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;
|
return content.fileValue != null || content.textValue != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget gestureDetectorWidget(MediaPickerInput input, ThemeData theme) {
|
Widget gestureDetectorWidget(
|
||||||
|
MediaPickerInput input,
|
||||||
|
ThemeData theme,
|
||||||
|
double width,
|
||||||
|
) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
@ -240,29 +254,36 @@ class _MediaPickerState extends State<MediaPicker> {
|
||||||
},
|
},
|
||||||
child: Wrap(
|
child: Wrap(
|
||||||
children: [
|
children: [
|
||||||
input.widget ??
|
input.widget != null
|
||||||
Container(
|
? SizedBox(
|
||||||
height: 55,
|
width: width,
|
||||||
width: MediaQuery.of(context).size.width * 0.9,
|
child: Center(
|
||||||
decoration: const BoxDecoration(
|
child: input.widget,
|
||||||
border: Border(
|
),
|
||||||
bottom: BorderSide(
|
)
|
||||||
color: Color(0xFF979797),
|
: Container(
|
||||||
width: 1,
|
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue