修复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,
controller: audioBookMiniplayerController,
elevation: 4,
duration: Duration(seconds: 3),
// duration: Duration(seconds: 3),
onDismissed: () {
// add a delay before closing the player
// 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 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(
children: [
// sized box for system status bar; not needed as not full screen
@ -135,12 +128,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
),
// the chapter title
if (chapterPercentage >= 1)
Opacity(
opacity: chapterPercentage,
Expanded(
child: Opacity(
opacity: earlyPercentage,
child: Padding(
padding: EdgeInsets.only(
top: AppElementSizes.paddingRegular * 4 * earlyPercentage,
top: AppElementSizes.paddingLarge * earlyPercentage,
// horizontal: 16.0,
),
// child: SizedBox(
@ -157,11 +150,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
// ),
),
),
),
// the book name and author
if (authorPercentage >= 1)
Opacity(
opacity: authorPercentage,
Expanded(
child: Opacity(
opacity: earlyPercentage,
child: Padding(
padding: EdgeInsets.only(
bottom: AppElementSizes.paddingRegular * earlyPercentage,
@ -184,12 +178,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
// ),
),
),
if (authorPercentage >= 1) const Spacer(),
),
// the progress bar
if (progressPercentage >= 1)
Opacity(
opacity: progressPercentage,
Expanded(
child: Opacity(
opacity: earlyPercentage,
child: SizedBox(
width: imageSize,
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
if (playPercentage >= 1)
Opacity(
opacity: playPercentage,
Expanded(
child: Opacity(
opacity: earlyPercentage,
child: SizedBox(
width: imageSize,
child: Row(
@ -228,12 +222,12 @@ class PlayerWhenExpanded extends HookConsumerWidget {
),
),
),
if (playPercentage >= 1) const Spacer(),
),
// speed control, sleep timer, chapter list, and settings
if (settingsPercentage >= 1)
Opacity(
opacity: settingsPercentage,
Expanded(
child: Opacity(
opacity: earlyPercentage,
child: SizedBox(
// padding: EdgeInsets.only(
// 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;
final adjuster = ProportionalAdjuster();
final rewindPercentage = adjuster.adjust(vanishingPercentage, 1.5);
final playPercentage = adjuster.adjust(vanishingPercentage, 1.8);
return Stack(
alignment: Alignment.topCenter,
children: [
@ -48,8 +45,8 @@ class PlayerWhenMinimized extends HookConsumerWidget {
children: [
// image
Padding(
padding: EdgeInsets.symmetric(
horizontal: ((availWidth - maxImgSize) / 2) * percentageMiniplayer,
padding: EdgeInsets.only(
left: ((availWidth - maxImgSize) / 2) * percentageMiniplayer,
),
child: InkWell(
onTap: () {
@ -104,32 +101,32 @@ class PlayerWhenMinimized extends HookConsumerWidget {
// controller.animateToHeight(state: PanelState.MAX);
// },
// ),
// rewind button
if (rewindPercentage >= 1)
Opacity(
opacity: rewindPercentage,
child: Padding(
padding: const EdgeInsets.only(left: 8),
child: IconButton(
icon: const Icon(
Icons.replay_30,
size: AppElementSizes.iconSizeSmall,
),
onPressed: () {},
Opacity(
opacity: vanishingPercentage,
child: Padding(
padding: const EdgeInsets.only(left: 8),
child: IconButton(
icon: const Icon(
Icons.replay_30,
size: AppElementSizes.iconSizeSmall,
),
onPressed: () {},
),
),
),
// play/pause button
if (playPercentage >= 1)
Opacity(
opacity: playPercentage,
child: Padding(
padding: const EdgeInsets.only(right: 8),
child: AudiobookPlayerPlayPauseButton(
playPauseController: playPauseController,
),
Opacity(
opacity: vanishingPercentage,
child: Padding(
padding: const EdgeInsets.only(right: 8),
child: AudiobookPlayerPlayPauseButton(
playPauseController: playPauseController,
),
),
),
],
),
const Spacer(),

View file

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