feat: file info
This commit is contained in:
@@ -0,0 +1,179 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../models/plex_file_info.dart';
|
||||
|
||||
class FileInfoBottomSheet extends StatelessWidget {
|
||||
final PlexFileInfo fileInfo;
|
||||
final String title;
|
||||
|
||||
const FileInfoBottomSheet({
|
||||
super.key,
|
||||
required this.fileInfo,
|
||||
required this.title,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[900],
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: Radius.circular(16),
|
||||
topRight: Radius.circular(16),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SizedBox(
|
||||
height: MediaQuery.of(context).size.height * 0.75,
|
||||
child: Column(
|
||||
children: [
|
||||
// Header
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: Row(
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.info_outline,
|
||||
color: Colors.white,
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'File Info',
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.close, color: Colors.white),
|
||||
onPressed: () => Navigator.pop(context),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(color: Colors.grey, height: 1),
|
||||
// Content
|
||||
Expanded(
|
||||
child: ListView(
|
||||
padding: const EdgeInsets.all(16),
|
||||
children: [
|
||||
// Title
|
||||
if (title.isNotEmpty) ...[
|
||||
Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
],
|
||||
|
||||
// Video Section
|
||||
_buildSectionHeader('Video'),
|
||||
const SizedBox(height: 8),
|
||||
_buildInfoRow('Codec', fileInfo.videoCodec ?? 'Unknown'),
|
||||
_buildInfoRow('Resolution', fileInfo.resolutionFormatted),
|
||||
_buildInfoRow('Bitrate', fileInfo.bitrateFormatted),
|
||||
_buildInfoRow('Frame Rate', fileInfo.frameRateFormatted),
|
||||
_buildInfoRow('Aspect Ratio', fileInfo.aspectRatioFormatted),
|
||||
if (fileInfo.videoProfile != null)
|
||||
_buildInfoRow('Profile', fileInfo.videoProfile!),
|
||||
if (fileInfo.bitDepth != null)
|
||||
_buildInfoRow('Bit Depth', '${fileInfo.bitDepth} bit'),
|
||||
if (fileInfo.colorSpace != null)
|
||||
_buildInfoRow('Color Space', fileInfo.colorSpace!),
|
||||
if (fileInfo.colorRange != null)
|
||||
_buildInfoRow('Color Range', fileInfo.colorRange!),
|
||||
if (fileInfo.colorPrimaries != null)
|
||||
_buildInfoRow('Color Primaries', fileInfo.colorPrimaries!),
|
||||
if (fileInfo.chromaSubsampling != null)
|
||||
_buildInfoRow('Chroma Subsampling', fileInfo.chromaSubsampling!),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Audio Section
|
||||
_buildSectionHeader('Audio'),
|
||||
const SizedBox(height: 8),
|
||||
_buildInfoRow('Codec', fileInfo.audioCodec ?? 'Unknown'),
|
||||
_buildInfoRow('Channels', fileInfo.audioChannelsFormatted),
|
||||
if (fileInfo.audioProfile != null)
|
||||
_buildInfoRow('Profile', fileInfo.audioProfile!),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// File Section
|
||||
_buildSectionHeader('File'),
|
||||
const SizedBox(height: 8),
|
||||
if (fileInfo.filePath != null)
|
||||
_buildInfoRow('Path', fileInfo.filePath!, isMonospace: true),
|
||||
_buildInfoRow('Size', fileInfo.fileSizeFormatted),
|
||||
_buildInfoRow('Container', fileInfo.container ?? 'Unknown'),
|
||||
_buildInfoRow('Duration', fileInfo.durationFormatted),
|
||||
const SizedBox(height: 20),
|
||||
|
||||
// Advanced Section
|
||||
_buildSectionHeader('Advanced'),
|
||||
const SizedBox(height: 8),
|
||||
_buildInfoRow(
|
||||
'Optimized for Streaming',
|
||||
fileInfo.optimizedForStreaming == true ? 'Yes' : 'No',
|
||||
),
|
||||
_buildInfoRow(
|
||||
'64-bit Offsets',
|
||||
fileInfo.has64bitOffsets == true ? 'Yes' : 'No',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSectionHeader(String title) {
|
||||
return Text(
|
||||
title,
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildInfoRow(String label, String value, {bool isMonospace = false}) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 6),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 140,
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: Colors.grey[400],
|
||||
fontSize: 14,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontFamily: isMonospace ? 'monospace' : null,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import '../models/plex_metadata.dart';
|
||||
import '../utils/provider_extensions.dart';
|
||||
import '../screens/media_detail_screen.dart';
|
||||
import '../screens/season_detail_screen.dart';
|
||||
import '../widgets/file_info_bottom_sheet.dart';
|
||||
|
||||
/// Helper class to store menu action data
|
||||
class _MenuAction {
|
||||
@@ -99,6 +100,17 @@ class _MediaContextMenuState extends State<MediaContextMenu> {
|
||||
);
|
||||
}
|
||||
|
||||
// File Info (for episodes and movies)
|
||||
if (itemType == 'episode' || itemType == 'movie') {
|
||||
menuActions.add(
|
||||
_MenuAction(
|
||||
value: 'fileinfo',
|
||||
icon: Icons.info_outline,
|
||||
label: 'File Info',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String? selected;
|
||||
|
||||
if (useBottomSheet) {
|
||||
@@ -219,6 +231,10 @@ class _MediaContextMenuState extends State<MediaContextMenu> {
|
||||
'Error loading season',
|
||||
);
|
||||
break;
|
||||
|
||||
case 'fileinfo':
|
||||
await _showFileInfo(context);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -276,6 +292,61 @@ class _MediaContextMenuState extends State<MediaContextMenu> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Show file info bottom sheet
|
||||
Future<void> _showFileInfo(BuildContext context) async {
|
||||
final client = context.client;
|
||||
if (client == null) return;
|
||||
|
||||
try {
|
||||
// Show loading indicator
|
||||
if (context.mounted) {
|
||||
showDialog(
|
||||
context: context,
|
||||
barrierDismissible: false,
|
||||
builder: (context) => const Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Fetch file info
|
||||
final fileInfo = await client.getFileInfo(widget.metadata.ratingKey);
|
||||
|
||||
// Close loading indicator
|
||||
if (context.mounted) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
if (fileInfo != null && context.mounted) {
|
||||
// Show file info bottom sheet
|
||||
await showModalBottomSheet(
|
||||
context: context,
|
||||
isScrollControlled: true,
|
||||
backgroundColor: Colors.transparent,
|
||||
builder: (context) => FileInfoBottomSheet(
|
||||
fileInfo: fileInfo,
|
||||
title: widget.metadata.title,
|
||||
),
|
||||
);
|
||||
} else if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
const SnackBar(content: Text('File information not available')),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
// Close loading indicator if it's still open
|
||||
if (context.mounted && Navigator.canPop(context)) {
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
||||
if (context.mounted) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error loading file info: $e')),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
|
||||
Reference in New Issue
Block a user