mirror of
https://github.com/Iconica-Development/flutter_media_picker.git
synced 2025-05-19 00:43:45 +02:00
Merge pull request #1 from Iconica-Development/fix/ontap_custom_header
fix: ontap not working when custom header is set
This commit is contained in:
commit
64fc57a8b9
3 changed files with 57 additions and 43 deletions
|
@ -1,3 +1,11 @@
|
||||||
## 0.0.1
|
## 0.0.1
|
||||||
|
|
||||||
- Initial port
|
- Initial port
|
||||||
|
|
||||||
|
## 0.0.2
|
||||||
|
|
||||||
|
- Updated flutter_form version
|
||||||
|
|
||||||
|
## 0.0.3
|
||||||
|
|
||||||
|
- Fixed bug where onTap was not working when header is set
|
|
@ -1,4 +1,4 @@
|
||||||
export './audio_service.dart';
|
export './audio_service.dart';
|
||||||
export './media_picker_input.dart';
|
export './media_picker_input.dart';
|
||||||
export './media_picker_service.dart';
|
export './media_picker_service.dart';
|
||||||
export './video_player_factory.dart';
|
export './video_player_factory.dart';
|
||||||
|
|
|
@ -134,50 +134,12 @@ class MediaPicker extends ConsumerWidget {
|
||||||
children: [
|
children: [
|
||||||
for (final input in inputs) ...[
|
for (final input in inputs) ...[
|
||||||
const SizedBox(height: 2.5),
|
const SizedBox(height: 2.5),
|
||||||
header?.call(input.label, input.onPressed) ??
|
header?.call(input.label, (BuildContext ct) async {
|
||||||
|
await onPressedMediaType(ct, input);
|
||||||
|
}) ??
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
MediaResult content = await input.onPressed(context);
|
await onPressedMediaType(context, input);
|
||||||
|
|
||||||
if (mediaCheckPage != null &&
|
|
||||||
(input.runtimeType == MediaPickerInputText ||
|
|
||||||
_hasContent(content))) {
|
|
||||||
var checkPage = mediaCheckPage!(
|
|
||||||
await input.displayResult(content),
|
|
||||||
input.checkPageSettings,
|
|
||||||
(Map<String, dynamic> results) {
|
|
||||||
MediaResult result = MediaResult(
|
|
||||||
fileValue: content.fileValue,
|
|
||||||
textValue: content.textValue,
|
|
||||||
checkPageResults: results,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (input.onComplete != null) {
|
|
||||||
input.onComplete!(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onComplete != null) {
|
|
||||||
onComplete!(result);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
// ignore: use_build_context_synchronously
|
|
||||||
Navigator.push(
|
|
||||||
context,
|
|
||||||
MaterialPageRoute(
|
|
||||||
builder: (context) => checkPage,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
if (input.onComplete != null) {
|
|
||||||
input.onComplete!(content);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (onComplete != null) {
|
|
||||||
onComplete!(content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
height: 55,
|
height: 55,
|
||||||
|
@ -208,6 +170,50 @@ class MediaPicker extends ConsumerWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> onPressedMediaType(
|
||||||
|
BuildContext context, MediaPickerInput input) async {
|
||||||
|
MediaResult content = await input.onPressed(context);
|
||||||
|
|
||||||
|
if (mediaCheckPage != null &&
|
||||||
|
(input.runtimeType == MediaPickerInputText || _hasContent(content))) {
|
||||||
|
var checkPage = mediaCheckPage!(
|
||||||
|
await input.displayResult(content),
|
||||||
|
input.checkPageSettings,
|
||||||
|
(Map<String, dynamic> results) {
|
||||||
|
MediaResult result = MediaResult(
|
||||||
|
fileValue: content.fileValue,
|
||||||
|
textValue: content.textValue,
|
||||||
|
checkPageResults: results,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (input.onComplete != null) {
|
||||||
|
input.onComplete!(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onComplete != null) {
|
||||||
|
onComplete!(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
// ignore: use_build_context_synchronously
|
||||||
|
Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => checkPage,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
if (input.onComplete != null) {
|
||||||
|
input.onComplete!(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onComplete != null) {
|
||||||
|
onComplete!(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool _hasContent(MediaResult content) {
|
bool _hasContent(MediaResult content) {
|
||||||
return content.fileValue != null || content.textValue != null;
|
return content.fileValue != null || content.textValue != null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue