diff --git a/lib/app/views/tv/screens/tv_home.dart b/lib/app/views/tv/screens/tv_home.dart index 30c6d10e..1557b2da 100644 --- a/lib/app/views/tv/screens/tv_home.dart +++ b/lib/app/views/tv/screens/tv_home.dart @@ -1,4 +1,3 @@ -import 'package:auto_route/annotations.dart'; import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -7,16 +6,11 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:invidious/app/states/tv_home.dart'; import 'package:invidious/globals.dart'; -import 'package:invidious/playlists/views/tv/screens/playlist_grid.dart'; -import 'package:invidious/search/views/tv/screens/search.dart'; -import 'package:invidious/settings/views/tv/screens/settings.dart'; import 'package:invidious/utils/models/paginatedList.dart'; import 'package:invidious/utils/views/tv/components/tv_button.dart'; import 'package:invidious/utils/views/tv/components/tv_overscan.dart'; import 'package:invidious/videos/views/components/subscriptions.dart'; import 'package:invidious/videos/views/components/trending.dart'; -import 'package:invidious/videos/views/tv/screens/video_grid_view.dart'; -import 'package:invidious/welcome_wizard/views/tv/components/welcome_wizard.dart'; import '../../../../router.dart'; import '../../../../utils/views/components/app_icon.dart'; diff --git a/lib/player/states/player.dart b/lib/player/states/player.dart index a4f1647e..15325970 100644 --- a/lib/player/states/player.dart +++ b/lib/player/states/player.dart @@ -13,6 +13,7 @@ import 'package:invidious/globals.dart'; import 'package:invidious/player/models/mediaCommand.dart'; import 'package:invidious/player/models/mediaEvent.dart'; import 'package:invidious/player/states/interfaces/media_player.dart'; +import 'package:invidious/router.dart'; import 'package:invidious/utils/models/image_object.dart'; import 'package:logging/logging.dart'; import 'package:simple_pip_mode/simple_pip.dart'; @@ -502,10 +503,9 @@ class PlayerCubit extends Cubit { await _playVideos(offlineVids); } - playVideo(List v, {bool? goBack, bool? audio, Duration? startAt}) async { + playVideo(List v, {bool? audio, Duration? startAt}) async { List videos = v.where((element) => !element.filtered).toList(); // TODO: find how to do this with auto router - // if (goBack ?? false) navigatorKey.currentState?.pop(); log.fine('Playing ${videos.length} videos'); setAudio(audio); diff --git a/lib/playlists/states/playlist.dart b/lib/playlists/states/playlist.dart index 2e25cc28..9e99d743 100644 --- a/lib/playlists/states/playlist.dart +++ b/lib/playlists/states/playlist.dart @@ -37,7 +37,7 @@ class PlaylistCubit extends Cubit { } play(bool? isAudio) { - player.playVideo(state.playlist.videos, goBack: false, audio: isAudio); + player.playVideo(state.playlist.videos, audio: isAudio); } scrollToTop() { diff --git a/lib/router.dart b/lib/router.dart index b967a569..cbec92bf 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -43,7 +43,7 @@ import 'package:invidious/videos/views/screens/video.dart'; import 'package:invidious/videos/views/tv/screens/video.dart'; import 'package:invidious/videos/views/tv/screens/video_grid_view.dart'; import 'package:invidious/welcome_wizard/views/screens/welcome_wizard.dart'; -import 'package:invidious/welcome_wizard/views/tv/components/welcome_wizard.dart'; +import 'package:invidious/welcome_wizard/views/tv/screens/welcome_wizard.dart'; import 'package:logging/logging.dart'; import 'channels/views/screens/channel.dart'; @@ -76,11 +76,10 @@ class AppRouter extends _$AppRouter { return isTv ? [ AutoRoute( - path: '/', page: TvHomeRoute.page, initial: hasServer, ), - AutoRoute(page: TvWelcomeWizardRoute.page), + AutoRoute(page: TvWelcomeWizardRoute.page, initial: !hasServer), AutoRoute(page: TvChannelRoute.page), AutoRoute(page: TvGridRoute.page), AutoRoute(page: TvVideoRoute.page), diff --git a/lib/settings/states/server_list_settings.dart b/lib/settings/states/server_list_settings.dart index 1bfd01c2..9bbb2a01 100644 --- a/lib/settings/states/server_list_settings.dart +++ b/lib/settings/states/server_list_settings.dart @@ -94,9 +94,8 @@ class ServerListSettingsCubit extends Cubit { } } catch (err) { log.severe("couldn't get public playlist", err); - state.publicServersError = PublicServerErrors.couldNotGetList; if (!isClosed) { - emit(state); + emit(this.state.copyWith(publicServersError: PublicServerErrors.couldNotGetList)); } rethrow; } diff --git a/lib/videos/states/video.dart b/lib/videos/states/video.dart index 899ed13e..c9cf67d3 100644 --- a/lib/videos/states/video.dart +++ b/lib/videos/states/video.dart @@ -124,7 +124,7 @@ class VideoCubit extends Cubit { if (!settings.state.distractionFreeMode && settings.state.playRecommendedNext) { videos.addAll(state.video?.recommendedVideos ?? []); } - player.playVideo(videos, goBack: true, audio: audio); + player.playVideo(videos, audio: audio); } } diff --git a/lib/videos/views/components/play_button.dart b/lib/videos/views/components/play_button.dart index 4d7bb1d5..40790ed6 100644 --- a/lib/videos/views/components/play_button.dart +++ b/lib/videos/views/components/play_button.dart @@ -1,3 +1,4 @@ +import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; class PlayButton extends StatelessWidget { @@ -14,7 +15,10 @@ class PlayButton extends StatelessWidget { Padding( padding: const EdgeInsets.only(left: 100.0, top: 60), child: IconButton( - onPressed: () => onPressed(true), + onPressed: () { + onPressed(true); + AutoRouter.of(context).pop(); + }, style: ButtonStyle( backgroundColor: MaterialStateColor.resolveWith((states) => colorScheme.primary.withOpacity(1))), icon: const Icon( @@ -25,7 +29,10 @@ class PlayButton extends StatelessWidget { ), ), IconButton( - onPressed: () => onPressed(false), + onPressed: () { + onPressed(false); + AutoRouter.of(context).pop(); + }, style: ButtonStyle( backgroundColor: MaterialStateColor.resolveWith((states) => colorScheme.primaryContainer.withOpacity(1))), icon: const Icon( diff --git a/lib/videos/views/components/video_in_list.dart b/lib/videos/views/components/video_in_list.dart index c984d38b..f48fbad1 100644 --- a/lib/videos/views/components/video_in_list.dart +++ b/lib/videos/views/components/video_in_list.dart @@ -1,6 +1,5 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_animate/flutter_animate.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:invidious/globals.dart'; @@ -50,7 +49,8 @@ class VideoListItem extends StatelessWidget { var textTheme = Theme.of(context).textTheme; - TextStyle filterStyle = (textTheme.bodySmall ?? const TextStyle()).copyWith(color: colorScheme.secondary.withOpacity(0.7)); + TextStyle filterStyle = + (textTheme.bodySmall ?? const TextStyle()).copyWith(color: colorScheme.secondary.withOpacity(0.7)); var downloadManager = context.read(); String title = video?.title ?? offlineVideo?.title ?? ''; @@ -61,11 +61,16 @@ class VideoListItem extends StatelessWidget { create: (context) => VideoInListCubit(VideoInListState(video: video, offlineVideo: offlineVideo)), child: BlocBuilder( builder: (context, _) => BlocListener( - listenWhen: (previous, current) => _.video != null && current.currentlyPlaying?.videoId == video!.videoId && previous.position != current.position, + listenWhen: (previous, current) => + _.video != null && + current.currentlyPlaying?.videoId == video!.videoId && + previous.position != current.position, listener: (context, state) => context.read().updateProgress(), child: InkWell( onTap: () => openVideo(context), - onLongPress: _.video == null || _.video!.filtered ? null : () => VideoModalSheet.showVideoModalSheet(context, video!), + onLongPress: _.video == null || _.video!.filtered + ? null + : () => VideoModalSheet.showVideoModalSheet(context, video!), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, @@ -127,7 +132,9 @@ class VideoListItem extends StatelessWidget { children: [ Expanded( child: NavigationSwitcher( - child: _.progress == 1 + child: +/* + _.progress == 1 ? Align( alignment: Alignment.centerRight, child: Container( @@ -143,30 +150,59 @@ class VideoListItem extends StatelessWidget { ), ), ) - : _.progress > 0.05 - ? Padding( - padding: const EdgeInsets.symmetric(horizontal: 4.0, vertical: 8), - child: Container( - alignment: Alignment.centerLeft, - width: double.infinity, - height: small ? 1 : 5, - decoration: BoxDecoration( - color: colorScheme.secondaryContainer, - borderRadius: BorderRadius.circular(20), + : +*/ + + _.progress > 0.05 + ? Align( + alignment: Alignment.centerRight, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 4.0, vertical: 8), + child: AnimatedContainer( + curve: Curves.easeOutQuad, + duration: animationDuration, + alignment: Alignment.centerLeft, + constraints: _.progress == 1 + ? const BoxConstraints(maxWidth: 20) + : const BoxConstraints(maxWidth: 1200), + width: double.infinity, + height: _.progress == 1 + ? 20 + : small + ? 1 + : 5, + decoration: BoxDecoration( + color: colorScheme.secondaryContainer, + borderRadius: BorderRadius.circular(20), + ), + child: AnimatedFractionallySizedBox( + widthFactor: _.progress > 0 ? _.progress : 0, + heightFactor: 1, + duration: animationDuration, + curve: Curves.easeInOutQuad, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + color: _.progress == 1 ? colorScheme.primaryContainer: colorScheme.primary, + borderRadius: BorderRadius.circular(20), + ), + child: AnimatedCrossFade( + crossFadeState: _.progress == 1 + ? CrossFadeState.showFirst + : CrossFadeState.showSecond, + duration: animationDuration, + secondChild: const SizedBox.shrink(), + firstChild: Icon( + Icons.check, + size: 15, + color: colorScheme.primary, + ), + ), + )), + ), ), - child: AnimatedFractionallySizedBox( - widthFactor: _.progress > 0 ? _.progress : 0, - heightFactor: 1, - duration: const Duration(milliseconds: 750), - curve: Curves.easeInOutQuad, - child: Container( - decoration: BoxDecoration( - color: colorScheme.primary, - borderRadius: BorderRadius.circular(20), - ), - )), - ), - ) + ) : const SizedBox.shrink(), ), ), @@ -178,11 +214,15 @@ class VideoListItem extends StatelessWidget { child: Container( alignment: Alignment.center, height: 25, - decoration: BoxDecoration(color: Colors.black.withOpacity(0.75), borderRadius: BorderRadius.circular(5)), + decoration: BoxDecoration( + color: Colors.black.withOpacity(0.75), + borderRadius: BorderRadius.circular(5)), child: Padding( padding: const EdgeInsets.all(4.0), child: Text( - prettyDuration(Duration(seconds: video?.lengthSeconds ?? offlineVideo?.lengthSeconds ?? 0)), + prettyDuration(Duration( + seconds: + video?.lengthSeconds ?? offlineVideo?.lengthSeconds ?? 0)), style: textTheme.bodySmall?.copyWith(color: Colors.white), ), ), @@ -213,18 +253,21 @@ class VideoListItem extends StatelessWidget { textAlign: TextAlign.left, overflow: TextOverflow.ellipsis, maxLines: small ? 1 : 2, - style: (small ? textTheme.labelSmall : textTheme.bodyMedium)?.copyWith(color: colorScheme.primary, fontWeight: FontWeight.normal), + style: (small ? textTheme.labelSmall : textTheme.bodyMedium) + ?.copyWith(color: colorScheme.primary, fontWeight: FontWeight.normal), ), InkWell( onTap: () { - AutoRouter.of(context).push(ChannelRoute(channelId: video?.authorId ?? offlineVideo?.authorUrl ?? '')); + AutoRouter.of(context) + .push(ChannelRoute(channelId: video?.authorId ?? offlineVideo?.authorUrl ?? '')); }, child: Text( author, maxLines: 1, textAlign: TextAlign.left, overflow: TextOverflow.ellipsis, - style: (small ? textTheme.labelSmall : textTheme.bodyMedium)?.copyWith(color: colorScheme.secondary), + style: (small ? textTheme.labelSmall : textTheme.bodyMedium) + ?.copyWith(color: colorScheme.secondary), ), ), if (!small && video != null) @@ -239,7 +282,9 @@ class VideoListItem extends StatelessWidget { ), if (!small && video != null) InkWell( - onTap: (_.video?.filtered ?? true) ? null : () => VideoModalSheet.showVideoModalSheet(context, video!), + onTap: (_.video?.filtered ?? true) + ? null + : () => VideoModalSheet.showVideoModalSheet(context, video!), child: const Padding( padding: EdgeInsets.all(4), child: Icon(Icons.more_vert), diff --git a/lib/welcome_wizard/views/tv/components/welcome_wizard.dart b/lib/welcome_wizard/views/tv/screens/welcome_wizard.dart similarity index 100% rename from lib/welcome_wizard/views/tv/components/welcome_wizard.dart rename to lib/welcome_wizard/views/tv/screens/welcome_wizard.dart diff --git a/pubspec.yaml b/pubspec.yaml index 8821b040..9bb59ab4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.16.1+4030 +version: 1.16.2+4031 environment: sdk: '>=3.0.0 <4.0.0' diff --git a/submodules/flutter b/submodules/flutter index e1e47221..12fccda5 160000 --- a/submodules/flutter +++ b/submodules/flutter @@ -1 +1 @@ -Subproject commit e1e47221e86272429674bec4f1bd36acc4fc7b77 +Subproject commit 12fccda598477eddd19f93040a1dba24f915b9be