修复windows播放器元素溢出

This commit is contained in:
rang 2025-10-20 17:20:08 +08:00
parent 0b71777b41
commit 699b7de311
5 changed files with 55 additions and 57 deletions

View file

@ -93,7 +93,7 @@ class AudiobookPlayer extends HookConsumerWidget {
maxHeight: playerMaxHeight, maxHeight: playerMaxHeight,
controller: audioBookMiniplayerController, controller: audioBookMiniplayerController,
elevation: 4, elevation: 4,
duration: Duration(seconds: 3), // duration: Duration(seconds: 3),
onDismissed: () { onDismissed: () {
// add a delay before closing the player // add a delay before closing the player
// to allow the user to see the player closing // to allow the user to see the player closing

View file

@ -46,13 +46,6 @@ class PlayerWhenExpanded extends HookConsumerWidget {
final currentChapter = ref.watch(currentPlayingChapterProvider); final currentChapter = ref.watch(currentPlayingChapterProvider);
final currentBookMetadata = ref.watch(currentBookMetadataProvider); final currentBookMetadata = ref.watch(currentBookMetadataProvider);
final adjuster = ProportionalAdjuster();
final chapterPercentage = adjuster.adjust(earlyPercentage, 1.1);
final authorPercentage = adjuster.adjust(earlyPercentage, 1.2);
final progressPercentage = adjuster.adjust(earlyPercentage, 1.4);
final playPercentage = adjuster.adjust(earlyPercentage, 1.6);
final settingsPercentage = adjuster.adjust(earlyPercentage, 1.8);
return Column( return Column(
children: [ children: [
// sized box for system status bar; not needed as not full screen // sized box for system status bar; not needed as not full screen
@ -135,12 +128,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
), ),
// the chapter title // the chapter title
if (chapterPercentage >= 1) Expanded(
Opacity( child: Opacity(
opacity: chapterPercentage, opacity: earlyPercentage,
child: Padding( child: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: AppElementSizes.paddingRegular * 4 * earlyPercentage, top: AppElementSizes.paddingLarge * earlyPercentage,
// horizontal: 16.0, // horizontal: 16.0,
), ),
// child: SizedBox( // child: SizedBox(
@ -157,11 +150,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
// ), // ),
), ),
), ),
),
// the book name and author // the book name and author
if (authorPercentage >= 1) Expanded(
Opacity( child: Opacity(
opacity: authorPercentage, opacity: earlyPercentage,
child: Padding( child: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
bottom: AppElementSizes.paddingRegular * earlyPercentage, bottom: AppElementSizes.paddingRegular * earlyPercentage,
@ -184,12 +178,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
// ), // ),
), ),
), ),
if (authorPercentage >= 1) const Spacer(), ),
// the progress bar // the progress bar
if (progressPercentage >= 1) Expanded(
Opacity( child: Opacity(
opacity: progressPercentage, opacity: earlyPercentage,
child: SizedBox( child: SizedBox(
width: imageSize, width: imageSize,
child: Padding( child: Padding(
@ -202,12 +196,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
), ),
), ),
), ),
if (progressPercentage >= 1) const Spacer(), ),
// the chapter skip buttons, seek 30 seconds back and forward, and play/pause button // the chapter skip buttons, seek 30 seconds back and forward, and play/pause button
if (playPercentage >= 1) Expanded(
Opacity( child: Opacity(
opacity: playPercentage, opacity: earlyPercentage,
child: SizedBox( child: SizedBox(
width: imageSize, width: imageSize,
child: Row( child: Row(
@ -228,12 +222,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
), ),
), ),
), ),
if (playPercentage >= 1) const Spacer(), ),
// speed control, sleep timer, chapter list, and settings // speed control, sleep timer, chapter list, and settings
if (settingsPercentage >= 1) Expanded(
Opacity( child: Opacity(
opacity: settingsPercentage, opacity: earlyPercentage,
child: SizedBox( child: SizedBox(
// padding: EdgeInsets.only( // padding: EdgeInsets.only(
// bottom: AppElementSizes.paddingRegular * 4 * earlyPercentage, // bottom: AppElementSizes.paddingRegular * 4 * earlyPercentage,
@ -262,6 +256,7 @@ class PlayerWhenExpanded extends HookConsumerWidget {
), ),
), ),
), ),
),
], ],
); );
} }

View file

@ -38,9 +38,6 @@ class PlayerWhenMinimized extends HookConsumerWidget {
var barHeight = vanishingPercentage * 3; var barHeight = vanishingPercentage * 3;
final adjuster = ProportionalAdjuster();
final rewindPercentage = adjuster.adjust(vanishingPercentage, 1.5);
final playPercentage = adjuster.adjust(vanishingPercentage, 1.8);
return Stack( return Stack(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
children: [ children: [
@ -48,8 +45,8 @@ class PlayerWhenMinimized extends HookConsumerWidget {
children: [ children: [
// image // image
Padding( Padding(
padding: EdgeInsets.symmetric( padding: EdgeInsets.only(
horizontal: ((availWidth - maxImgSize) / 2) * percentageMiniplayer, left: ((availWidth - maxImgSize) / 2) * percentageMiniplayer,
), ),
child: InkWell( child: InkWell(
onTap: () { onTap: () {
@ -104,32 +101,32 @@ class PlayerWhenMinimized extends HookConsumerWidget {
// controller.animateToHeight(state: PanelState.MAX); // controller.animateToHeight(state: PanelState.MAX);
// }, // },
// ), // ),
// rewind button // rewind button
if (rewindPercentage >= 1) Opacity(
Opacity( opacity: vanishingPercentage,
opacity: rewindPercentage, child: Padding(
child: Padding( padding: const EdgeInsets.only(left: 8),
padding: const EdgeInsets.only(left: 8), child: IconButton(
child: IconButton( icon: const Icon(
icon: const Icon( Icons.replay_30,
Icons.replay_30, size: AppElementSizes.iconSizeSmall,
size: AppElementSizes.iconSizeSmall,
),
onPressed: () {},
), ),
onPressed: () {},
), ),
), ),
),
// play/pause button // play/pause button
if (playPercentage >= 1) Opacity(
Opacity( opacity: vanishingPercentage,
opacity: playPercentage, child: Padding(
child: Padding( padding: const EdgeInsets.only(right: 8),
padding: const EdgeInsets.only(right: 8), child: AudiobookPlayerPlayPauseButton(
child: AudiobookPlayerPlayPauseButton( playPauseController: playPauseController,
playPauseController: playPauseController,
),
), ),
), ),
),
], ],
), ),
const Spacer(), const Spacer(),

View file

@ -23,6 +23,7 @@ final appLogger = Logger('vaani');
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// Configure the root Logger // Configure the root Logger
await initLogging(); await initLogging();
@ -61,8 +62,7 @@ class MyApp extends ConsumerWidget {
ColorScheme lightColorScheme = brandLightColorScheme; ColorScheme lightColorScheme = brandLightColorScheme;
ColorScheme darkColorScheme = brandDarkColorScheme; ColorScheme darkColorScheme = brandDarkColorScheme;
final shouldUseHighContrast = final shouldUseHighContrast = themeSettings.highContrast || MediaQuery.of(context).highContrast;
themeSettings.highContrast || MediaQuery.of(context).highContrast;
if (shouldUseHighContrast) { if (shouldUseHighContrast) {
lightColorScheme = lightColorScheme.copyWith( lightColorScheme = lightColorScheme.copyWith(
@ -74,8 +74,7 @@ class MyApp extends ConsumerWidget {
} }
if (themeSettings.useMaterialThemeFromSystem) { if (themeSettings.useMaterialThemeFromSystem) {
var themes = var themes = ref.watch(systemThemeProvider(highContrast: shouldUseHighContrast));
ref.watch(systemThemeProvider(highContrast: shouldUseHighContrast));
if (themes.valueOrNull != null) { if (themes.valueOrNull != null) {
lightColorScheme = themes.valueOrNull!.$1; lightColorScheme = themes.valueOrNull!.$1;
darkColorScheme = themes.valueOrNull!.$2; darkColorScheme = themes.valueOrNull!.$2;

View file

@ -25,8 +25,15 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); project.set_dart_entrypoint_arguments(std::move(command_line_arguments));
FlutterWindow window(project); FlutterWindow window(project);
Win32Window::Point origin(10, 10); // 居中
Win32Window::Size size(1280, 720); UINT windowWidth = 832, windowHeight = 640;
UINT scrWidth, scrHeight, xShaft, yShaft;
scrWidth = GetSystemMetrics(SM_CXFULLSCREEN);
scrHeight = GetSystemMetrics(SM_CYFULLSCREEN);
xShaft = (scrWidth - windowWidth) / 2;
yShaft = (scrHeight - windowHeight) / 2;
Win32Window::Point origin(xShaft, yShaft);
Win32Window::Size size(windowWidth, windowHeight);
if (!window.Create(L"vaani", origin, size)) { if (!window.Create(L"vaani", origin, size)) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }