2022-11-01 08:23:06 +01:00
|
|
|
// SPDX-FileCopyrightText: 2022 Iconica
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
2022-10-25 14:20:18 +02:00
|
|
|
import 'package:example/media_picker_check.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_media_picker/flutter_media_picker.dart';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
|
2022-12-23 13:20:56 +01:00
|
|
|
class MediaPickerPageIconOptions extends ConsumerStatefulWidget {
|
|
|
|
const MediaPickerPageIconOptions({required this.callback, Key? key})
|
|
|
|
: super(key: key);
|
2022-10-25 14:20:18 +02:00
|
|
|
final Function callback;
|
|
|
|
|
|
|
|
@override
|
2022-12-23 13:20:56 +01:00
|
|
|
ConsumerState<ConsumerStatefulWidget> createState() => _MediaPickerIconOptionsState();
|
2022-10-25 14:20:18 +02:00
|
|
|
}
|
|
|
|
|
2022-12-23 13:20:56 +01:00
|
|
|
class _MediaPickerIconOptionsState extends ConsumerState<MediaPickerPageIconOptions> {
|
2022-10-25 14:20:18 +02:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var mediaService = ref.read<MediaPickerService>(mediaPickerServiceProvider);
|
|
|
|
var audioService = ref.read<AudioService>(audioPlayerServiceProvider);
|
|
|
|
return Wrap(
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: MediaQuery.of(context).size.width,
|
|
|
|
decoration: const BoxDecoration(
|
|
|
|
color: Colors.white,
|
|
|
|
borderRadius: BorderRadius.only(
|
|
|
|
topLeft: Radius.circular(15),
|
|
|
|
topRight: Radius.circular(15),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
|
|
|
const SizedBox(
|
|
|
|
height: 8,
|
|
|
|
),
|
|
|
|
Container(
|
|
|
|
width: 70,
|
|
|
|
height: 5,
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
borderRadius: BorderRadius.circular(100),
|
|
|
|
color: const Color(0xFF000000).withOpacity(0.50),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 14,
|
|
|
|
),
|
|
|
|
const Text(
|
2022-12-22 13:57:57 +01:00
|
|
|
'Create/Pick',
|
2022-10-25 14:20:18 +02:00
|
|
|
style: TextStyle(
|
|
|
|
fontWeight: FontWeight.w900,
|
|
|
|
fontSize: 20,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 15,
|
|
|
|
),
|
|
|
|
MediaPicker(
|
2022-12-22 16:18:33 +01:00
|
|
|
buttonType: ButtonType.icons,
|
2022-12-23 11:57:28 +01:00
|
|
|
horizontalSpacing: 40,
|
|
|
|
verticalSpacing: 20,
|
2022-10-25 14:20:18 +02:00
|
|
|
mediaPickerInputs: [
|
|
|
|
MediaPickerInputPhoto(
|
2022-12-23 15:10:01 +01:00
|
|
|
label: 'Make photo',
|
2022-12-23 13:20:56 +01:00
|
|
|
icon: const IconButtonWithText(
|
|
|
|
icon: Icons.camera_alt,
|
2022-12-23 15:10:01 +01:00
|
|
|
iconText: 'Custom Photo Icon',
|
2022-12-23 13:20:56 +01:00
|
|
|
),
|
2022-10-25 14:20:18 +02:00
|
|
|
pickFile: mediaService.pickImageFile,
|
|
|
|
checkPageSettings: {
|
2022-12-22 13:57:57 +01:00
|
|
|
'title': 'Share photo',
|
2022-10-25 14:20:18 +02:00
|
|
|
'width': 125.0,
|
|
|
|
'height': 200.0,
|
|
|
|
},
|
|
|
|
onComplete: (MediaResult result) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
MediaPickerInputVideo(
|
2022-12-23 15:10:01 +01:00
|
|
|
label: 'Make video',
|
2022-10-25 14:20:18 +02:00
|
|
|
pickFile: mediaService.pickVideoFile,
|
|
|
|
videoPlayerFactory: MediaPickerVideoPlayerFactory(),
|
|
|
|
checkPageSettings: {
|
2022-12-22 13:57:57 +01:00
|
|
|
'title': 'Share video',
|
2022-10-25 14:20:18 +02:00
|
|
|
'width': 122.5,
|
|
|
|
'height': 200.0,
|
|
|
|
},
|
|
|
|
onComplete: (MediaResult result) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
if (!kIsWeb)
|
|
|
|
MediaPickerInputAudio(
|
2022-12-23 15:10:01 +01:00
|
|
|
label: 'Record audio',
|
2022-12-22 13:57:57 +01:00
|
|
|
checkPageSettings: {'title': 'Share audio'},
|
2022-10-25 14:20:18 +02:00
|
|
|
onComplete: (MediaResult result) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
audioService: audioService,
|
|
|
|
),
|
|
|
|
MediaPickerInputText(
|
2022-12-23 15:10:01 +01:00
|
|
|
label: 'Write text',
|
2022-12-22 13:57:57 +01:00
|
|
|
checkPageSettings: {'title': 'Share text'},
|
2022-10-25 14:20:18 +02:00
|
|
|
onComplete: (MediaResult result) {
|
|
|
|
Navigator.pop(context);
|
|
|
|
},
|
|
|
|
),
|
2022-12-22 11:15:08 +01:00
|
|
|
MediaPickerInputFile(
|
2022-12-23 15:10:01 +01:00
|
|
|
label: 'Select file',
|
2022-12-22 11:15:08 +01:00
|
|
|
pickFile: mediaService.pickFile,
|
|
|
|
fileExtensions: [
|
|
|
|
'pdf',
|
|
|
|
'doc',
|
|
|
|
'png',
|
|
|
|
'jpg',
|
|
|
|
'docx',
|
|
|
|
'bmp',
|
|
|
|
'gif',
|
2022-12-22 13:57:57 +01:00
|
|
|
'txt',
|
2022-12-22 11:15:08 +01:00
|
|
|
],
|
|
|
|
checkPageSettings: {
|
2022-12-22 13:57:57 +01:00
|
|
|
'title': 'Share file',
|
|
|
|
},
|
|
|
|
onComplete: (MediaResult result) {
|
|
|
|
Navigator.pop(context);
|
2022-12-22 11:15:08 +01:00
|
|
|
},
|
|
|
|
),
|
2022-10-25 14:20:18 +02:00
|
|
|
],
|
|
|
|
mediaCheckPage: (Widget displayResult,
|
|
|
|
Map<String, dynamic>? inputSettings,
|
|
|
|
Function onComplete) =>
|
|
|
|
MediaCheckPage(
|
|
|
|
cancel: widget.callback,
|
|
|
|
displayResult: displayResult,
|
|
|
|
inputSettings: inputSettings ?? {},
|
|
|
|
onComplete: onComplete,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
const SizedBox(
|
|
|
|
height: 30,
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|