💄 Optimize file detail view styling

This commit is contained in:
2025-11-18 00:32:26 +08:00
parent 0303ef4a93
commit 94adecafbb
3 changed files with 89 additions and 98 deletions

View File

@@ -76,7 +76,7 @@ class FileDetailScreen extends HookConsumerWidget {
}, [animationController]); }, [animationController]);
return AppScaffold( return AppScaffold(
isNoBackground: true, isNoBackground: false,
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
leading: IconButton( leading: IconButton(
@@ -86,28 +86,49 @@ class FileDetailScreen extends HookConsumerWidget {
title: Text(item.name.isEmpty ? 'File Details' : item.name), title: Text(item.name.isEmpty ? 'File Details' : item.name),
actions: _buildAppBarActions(context, ref, showInfoSheet), actions: _buildAppBarActions(context, ref, showInfoSheet),
), ),
body: AnimatedBuilder( body: LayoutBuilder(
builder: (context, constraints) {
return AnimatedBuilder(
animation: animation, animation: animation,
builder: (context, child) { builder: (context, child) {
return Row( return Stack(
children: [ children: [
// Main content area // Main content area - resizes with animation
Expanded(child: _buildContent(context, ref, serverUrl)), Positioned(
// Animated drawer panel left: 0,
top: 0,
bottom: 0,
width: constraints.maxWidth - animation.value * 400,
child: _buildContent(context, ref, serverUrl),
),
// Animated drawer panel - overlays
if (isWide) if (isWide)
SizedBox( Positioned(
height: double.infinity, right: 0,
width: animation.value * 400, // Max width of 400px top: 0,
child: Container( bottom: 0,
child: width: 400,
animation.value > 0.1 child: Transform.translate(
? FileInfoSheet(item: item, onClose: showInfoSheet) offset: Offset((1 - animation.value) * 400, 0),
: const SizedBox.shrink(), child: SizedBox(
width: 400,
child: Material(
color:
Theme.of(context).colorScheme.surfaceContainer,
elevation: 8,
child: FileInfoSheet(
item: item,
onClose: showInfoSheet,
),
),
),
), ),
), ),
], ],
); );
}, },
);
},
), ),
); );
} }

View File

@@ -1,7 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:ui';
import 'package:easy_localization/easy_localization.dart';
import 'package:file_saver/file_saver.dart'; import 'package:file_saver/file_saver.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
@@ -266,16 +266,6 @@ class GenericFileContent extends HookConsumerWidget {
} }
return Center( return Center(
child: Container(
margin: const EdgeInsets.all(32),
padding: const EdgeInsets.all(32),
decoration: BoxDecoration(
border: Border.all(
color: Theme.of(context).colorScheme.outline,
width: 1,
),
borderRadius: BorderRadius.circular(16),
),
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
@@ -309,7 +299,7 @@ class GenericFileContent extends HookConsumerWidget {
FilledButton.icon( FilledButton.icon(
onPressed: downloadFile, onPressed: downloadFile,
icon: const Icon(Symbols.download), icon: const Icon(Symbols.download),
label: Text('download'), label: Text('download').tr(),
), ),
const Gap(16), const Gap(16),
OutlinedButton.icon( OutlinedButton.icon(
@@ -322,13 +312,12 @@ class GenericFileContent extends HookConsumerWidget {
); );
}, },
icon: const Icon(Symbols.info), icon: const Icon(Symbols.info),
label: Text('info'), label: Text('info').tr(),
), ),
], ],
), ),
], ],
), ),
),
); );
} }
} }

View File

@@ -1,10 +1,7 @@
import 'dart:io'; import 'dart:io';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:island/pods/network.dart';
import 'package:island/talker.dart';
import 'package:media_kit/media_kit.dart'; import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart'; import 'package:media_kit_video/media_kit_video.dart';
@@ -28,28 +25,12 @@ class _UniversalVideoState extends ConsumerState<UniversalVideo> {
VideoController? _videoController; VideoController? _videoController;
void _openVideo() async { void _openVideo() async {
final url = widget.uri;
MediaKit.ensureInitialized(); MediaKit.ensureInitialized();
_player = Player(); _player = Player();
_videoController = VideoController(_player!); _videoController = VideoController(_player!);
String? uri; _player!.open(Media(widget.uri), play: widget.autoplay);
final inCacheInfo = await DefaultCacheManager().getFileFromCache(url);
if (inCacheInfo == null) {
talker.info('[MediaPlayer] Miss cache: $url');
final token = ref.watch(tokenProvider)?.token;
DefaultCacheManager().downloadFile(
url,
authHeaders: {'Authorization': 'AtField $token'},
);
uri = url;
} else {
uri = inCacheInfo.file.path;
talker.info('[MediaPlayer] Hit cache: $url');
}
_player!.open(Media(uri), play: widget.autoplay);
} }
@override @override