diff --git a/lib/features/player/view/audiobook_player.dart b/lib/features/player/view/audiobook_player.dart index a849b83..913ee7d 100644 --- a/lib/features/player/view/audiobook_player.dart +++ b/lib/features/player/view/audiobook_player.dart @@ -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 diff --git a/lib/features/player/view/player_when_expanded.dart b/lib/features/player/view/player_when_expanded.dart index 31570c5..7e9d67c 100644 --- a/lib/features/player/view/player_when_expanded.dart +++ b/lib/features/player/view/player_when_expanded.dart @@ -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 { ), ), ), + ), ], ); } diff --git a/lib/features/player/view/player_when_minimized.dart b/lib/features/player/view/player_when_minimized.dart index 541de63..5a26afb 100644 --- a/lib/features/player/view/player_when_minimized.dart +++ b/lib/features/player/view/player_when_minimized.dart @@ -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(), diff --git a/lib/main.dart b/lib/main.dart index 6020a6a..6c4de6f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -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; diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index ed655bc..855a95b 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -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; }