kopia lustrzana https://gitlab.com/mysocialportal/relatica
Breakout status control's media builder to own class
rodzic
30c86175c5
commit
cd41a0c581
|
@ -47,7 +47,7 @@ android {
|
||||||
applicationId "social.myportal.flutter_portal"
|
applicationId "social.myportal.flutter_portal"
|
||||||
// You can update the following values to match your application needs.
|
// You can update the following values to match your application needs.
|
||||||
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
|
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
|
||||||
minSdkVersion 19
|
minSdkVersion 21
|
||||||
targetSdkVersion flutter.targetSdkVersion
|
targetSdkVersion flutter.targetSdkVersion
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
|
import '../models/attachment_media_type_enum.dart';
|
||||||
|
import '../models/media_attachment.dart';
|
||||||
|
import '../screens/image_viewer_screen.dart';
|
||||||
|
import '../utils/snackbar_builder.dart';
|
||||||
|
import 'image_control.dart';
|
||||||
|
|
||||||
|
class MediaAttachmentViewerControl extends StatefulWidget {
|
||||||
|
final MediaAttachment attachment;
|
||||||
|
|
||||||
|
const MediaAttachmentViewerControl({super.key, required this.attachment});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MediaAttachmentViewerControl> createState() =>
|
||||||
|
_MediaAttachmentViewerControlState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MediaAttachmentViewerControlState
|
||||||
|
extends State<MediaAttachmentViewerControl> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final item = widget.attachment;
|
||||||
|
if (item.explicitType == AttachmentMediaType.video) {
|
||||||
|
return ElevatedButton(
|
||||||
|
onPressed: () async {
|
||||||
|
if (await canLaunchUrl(item.uri)) {
|
||||||
|
buildSnackbar(
|
||||||
|
context,
|
||||||
|
'Attempting to launch video: ${item.uri}',
|
||||||
|
);
|
||||||
|
await launchUrl(item.uri);
|
||||||
|
} else {
|
||||||
|
buildSnackbar(context, 'Unable to launch video: ${item.uri}');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child:
|
||||||
|
Text(item.description.isNotEmpty ? item.description : 'Video'));
|
||||||
|
}
|
||||||
|
if (item.explicitType != AttachmentMediaType.image) {
|
||||||
|
return Text('${item.explicitType}: ${item.uri}');
|
||||||
|
}
|
||||||
|
|
||||||
|
return ImageControl(
|
||||||
|
width: 250.0,
|
||||||
|
height: 250.0,
|
||||||
|
imageUrl: item.thumbnailUri.toString(),
|
||||||
|
altText: item.description,
|
||||||
|
onTap: () async {
|
||||||
|
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
||||||
|
return ImageViewerScreen(attachment: item);
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,16 +2,12 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
|
import 'package:flutter_widget_from_html_core/flutter_widget_from_html_core.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
|
||||||
|
|
||||||
import '../../models/attachment_media_type_enum.dart';
|
|
||||||
import '../../models/entry_tree_item.dart';
|
import '../../models/entry_tree_item.dart';
|
||||||
import '../../models/timeline_entry.dart';
|
import '../../models/timeline_entry.dart';
|
||||||
import '../../screens/image_viewer_screen.dart';
|
|
||||||
import '../../services/timeline_manager.dart';
|
import '../../services/timeline_manager.dart';
|
||||||
import '../../utils/snackbar_builder.dart';
|
|
||||||
import '../../utils/url_opening_utils.dart';
|
import '../../utils/url_opening_utils.dart';
|
||||||
import '../image_control.dart';
|
import '../media_attachment_viewer_control.dart';
|
||||||
import '../padding.dart';
|
import '../padding.dart';
|
||||||
import 'interactions_bar_control.dart';
|
import 'interactions_bar_control.dart';
|
||||||
import 'status_header_control.dart';
|
import 'status_header_control.dart';
|
||||||
|
@ -142,42 +138,7 @@ class _StatusControlState extends State<StatusControl> {
|
||||||
child: ListView.separated(
|
child: ListView.separated(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final item = items[index];
|
return MediaAttachmentViewerControl(attachment: items[index]);
|
||||||
|
|
||||||
if (item.explicitType == AttachmentMediaType.video) {
|
|
||||||
return ElevatedButton(
|
|
||||||
onPressed: () async {
|
|
||||||
if (await canLaunchUrl(item.uri)) {
|
|
||||||
buildSnackbar(
|
|
||||||
context,
|
|
||||||
'Attempting to launch video: ${item.uri}',
|
|
||||||
);
|
|
||||||
await launchUrl(item.uri);
|
|
||||||
} else {
|
|
||||||
buildSnackbar(
|
|
||||||
context, 'Unable to launch video: ${item.uri}');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
child: Text(item.description.isNotEmpty
|
|
||||||
? item.description
|
|
||||||
: 'Video'));
|
|
||||||
}
|
|
||||||
if (item.explicitType != AttachmentMediaType.image) {
|
|
||||||
return Text('${item.explicitType}: ${item.uri}');
|
|
||||||
}
|
|
||||||
|
|
||||||
return ImageControl(
|
|
||||||
width: 250.0,
|
|
||||||
height: 250.0,
|
|
||||||
imageUrl: item.thumbnailUri.toString(),
|
|
||||||
altText: item.description,
|
|
||||||
onTap: () async {
|
|
||||||
Navigator.push(context, MaterialPageRoute(builder: (context) {
|
|
||||||
return ImageViewerScreen(attachment: item);
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
);
|
|
||||||
// return Text(item.toString());
|
|
||||||
},
|
},
|
||||||
separatorBuilder: (context, index) {
|
separatorBuilder: (context, index) {
|
||||||
return HorizontalPadding();
|
return HorizontalPadding();
|
||||||
|
|
|
@ -13,6 +13,8 @@ final platformHasCamera = Platform.isIOS || Platform.isAndroid;
|
||||||
|
|
||||||
final useImagePicker = kIsWeb || Platform.isAndroid || Platform.isIOS;
|
final useImagePicker = kIsWeb || Platform.isAndroid || Platform.isIOS;
|
||||||
|
|
||||||
|
final useVideoPlayer = kIsWeb || Platform.isAndroid || Platform.isIOS;
|
||||||
|
|
||||||
Future<bool?> showConfirmDialog(BuildContext context, String caption) {
|
Future<bool?> showConfirmDialog(BuildContext context, String caption) {
|
||||||
return showDialog<bool>(
|
return showDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
|
|
35
pubspec.lock
35
pubspec.lock
|
@ -777,6 +777,41 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.2"
|
version: "2.1.2"
|
||||||
|
video_player:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: video_player
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.10"
|
||||||
|
video_player_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_android
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.10"
|
||||||
|
video_player_avfoundation:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_avfoundation
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.8"
|
||||||
|
video_player_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "6.0.1"
|
||||||
|
video_player_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: video_player_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.13"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -36,6 +36,7 @@ dependencies:
|
||||||
image: ^3.2.2
|
image: ^3.2.2
|
||||||
flutter_file_dialog: ^2.3.2
|
flutter_file_dialog: ^2.3.2
|
||||||
multi_trigger_autocomplete: ^0.1.1
|
multi_trigger_autocomplete: ^0.1.1
|
||||||
|
video_player: ^2.4.10
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
Ładowanie…
Reference in New Issue