Skip to content

Commit

Permalink
Merge pull request #322 from lamarios/fix/tv_broken_new_install
Browse files Browse the repository at this point in the history
Fix/tv broken new install
  • Loading branch information
lamarios authored Sep 25, 2023
2 parents 8495112 + 795f38a commit bdf00ad
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 53 deletions.
6 changes: 0 additions & 6 deletions lib/app/views/tv/screens/tv_home.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions lib/player/states/player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -502,10 +503,9 @@ class PlayerCubit extends Cubit<PlayerState> {
await _playVideos(offlineVids);
}

playVideo(List<BaseVideo> v, {bool? goBack, bool? audio, Duration? startAt}) async {
playVideo(List<BaseVideo> v, {bool? audio, Duration? startAt}) async {
List<BaseVideo> 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);
Expand Down
2 changes: 1 addition & 1 deletion lib/playlists/states/playlist.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PlaylistCubit extends Cubit<PlaylistState> {
}

play(bool? isAudio) {
player.playVideo(state.playlist.videos, goBack: false, audio: isAudio);
player.playVideo(state.playlist.videos, audio: isAudio);
}

scrollToTop() {
Expand Down
5 changes: 2 additions & 3 deletions lib/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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),
Expand Down
3 changes: 1 addition & 2 deletions lib/settings/states/server_list_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ class ServerListSettingsCubit extends Cubit<ServerListSettingsState> {
}
} 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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/videos/states/video.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class VideoCubit extends Cubit<VideoState> {
if (!settings.state.distractionFreeMode && settings.state.playRecommendedNext) {
videos.addAll(state.video?.recommendedVideos ?? []);
}
player.playVideo(videos, goBack: true, audio: audio);
player.playVideo(videos, audio: audio);
}
}

Expand Down
11 changes: 9 additions & 2 deletions lib/videos/views/components/play_button.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';

class PlayButton extends StatelessWidget {
Expand All @@ -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(
Expand All @@ -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(
Expand Down
113 changes: 79 additions & 34 deletions lib/videos/views/components/video_in_list.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<DownloadManagerCubit>();

String title = video?.title ?? offlineVideo?.title ?? '';
Expand All @@ -61,11 +61,16 @@ class VideoListItem extends StatelessWidget {
create: (context) => VideoInListCubit(VideoInListState(video: video, offlineVideo: offlineVideo)),
child: BlocBuilder<VideoInListCubit, VideoInListState>(
builder: (context, _) => BlocListener<PlayerCubit, PlayerState>(
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<VideoInListCubit>().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,
Expand Down Expand Up @@ -127,7 +132,9 @@ class VideoListItem extends StatelessWidget {
children: [
Expanded(
child: NavigationSwitcher(
child: _.progress == 1
child:
/*
_.progress == 1
? Align(
alignment: Alignment.centerRight,
child: Container(
Expand All @@ -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(),
),
),
Expand All @@ -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),
),
),
Expand Down Expand Up @@ -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)
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion submodules/flutter
Submodule flutter updated 31 files
+11 −0 .ci.yaml
+0 −158 .cirrus.yml
+1 −0 TESTOWNERS
+1 −1 bin/internal/engine.version
+21 −0 dev/devicelab/bin/tasks/microbenchmarks_ios_xcode_debug.dart
+6 −0 dev/devicelab/lib/microbenchmarks.dart
+5 −2 dev/devicelab/lib/tasks/microbenchmarks.dart
+2 −2 dev/forbidden_from_release_tests/pubspec.yaml
+2 −4 packages/flutter/lib/src/foundation/_platform_web.dart
+1 −0 packages/flutter/lib/src/rendering/sliver_group.dart
+7 −5 packages/flutter/lib/src/widgets/scroll_delegate.dart
+4 −0 packages/flutter/test/widgets/sliver_main_axis_group_test.dart
+10 −8 packages/flutter/test/widgets/two_dimensional_viewport_test.dart
+42 −21 packages/flutter_tools/lib/src/android/android_studio.dart
+5 −1 packages/flutter_tools/lib/src/commands/upgrade.dart
+29 −1 packages/flutter_tools/lib/src/ios/devices.dart
+0 −2 packages/flutter_tools/lib/src/ios/mac.dart
+7 −6 packages/flutter_tools/lib/src/ios/xcode_build_settings.dart
+2 −1 packages/flutter_tools/lib/src/web/bootstrap.dart
+2 −2 packages/flutter_tools/lib/src/web/file_generators/main_dart.dart
+2 −2 packages/flutter_tools/pubspec.yaml
+12 −0 packages/flutter_tools/test/commands.shard/hermetic/upgrade_test.dart
+45 −0 packages/flutter_tools/test/general.shard/android/android_studio_test.dart
+4 −4 packages/flutter_tools/test/general.shard/build_system/targets/web_test.dart
+82 −0 packages/flutter_tools/test/general.shard/ios/ios_device_start_nonprebuilt_test.dart
+8 −33 packages/flutter_tools/test/general.shard/ios/xcodeproj_test.dart
+2 −2 packages/flutter_tools/test/general.shard/resident_web_runner_test.dart
+28 −10 packages/flutter_tools/test/integration.shard/downgrade_upgrade_integration_test.dart
+5 −6 packages/flutter_web_plugins/lib/src/plugin_registry.dart
+2 −2 packages/flutter_web_plugins/test/plugin_event_channel_test.dart
+2 −2 packages/flutter_web_plugins/test/plugin_registry_test.dart

0 comments on commit bdf00ad

Please sign in to comment.