Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file modified flutter/android/app/src/main/jniLibs/x86_64/libfred_tv_lib.so
Binary file not shown.
Binary file added flutter/assets/btc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flutter/assets/fred.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flutter/assets/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added flutter/assets/paypal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions flutter/lib/app_keys.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import 'package:flutter/material.dart';

final navigatorKey = GlobalKey<NavigatorState>();
final scaffoldMessengerKey = GlobalKey<ScaffoldMessengerState>();
14 changes: 4 additions & 10 deletions flutter/lib/bottom_nav.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import 'package:flutter/material.dart';
import 'package:open_tv/models/view_type.dart';
import 'package:open_tv/settings_view.dart';
import 'package:open_tv/task_service.dart';

class BottomNav extends StatefulWidget {
final Function(ViewType) updateViewMode;
final ViewType startingView;
final bool blockSettings;
final bool tvMode;
const BottomNav({
super.key,
required this.updateViewMode,
this.startingView = ViewType.all,
this.blockSettings = false,
this.tvMode = false,
});

Expand All @@ -36,12 +35,8 @@ class _BottomNavState extends State<BottomNav> {
}

void onBarTapped(int index) {
if (widget.blockSettings && index == ViewType.settings.index) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("Settings disabled while refreshing on start"),
),
);
if (TaskService.instance.isDeletingSource) {
TaskService.instance.notifyBusy();
return;
}
setState(() {
Expand All @@ -51,8 +46,7 @@ class _BottomNavState extends State<BottomNav> {
Navigator.pushAndRemoveUntil(
context,
PageRouteBuilder(
pageBuilder: (_, __, ___) =>
SettingsView(tvMode: widget.tvMode),
pageBuilder: (_, __, ___) => SettingsView(tvMode: widget.tvMode),
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
transitionsBuilder: (context, animation, secondaryAnimation, child) =>
Expand Down
27 changes: 12 additions & 15 deletions flutter/lib/channel_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:open_tv/models/node_type.dart';
import 'package:open_tv/native_bridge.dart';
import 'package:open_tv/player.dart';
import 'package:open_tv/exo_player.dart';
import 'package:open_tv/task_service.dart';
import 'dart:io' show Platform;

class ChannelTile extends StatefulWidget {
Expand Down Expand Up @@ -152,38 +153,32 @@ class _ChannelTileState extends State<ChannelTile> {
Future<void> favorite() async {
if (widget.channel.mediaType == MediaType.group) return;
await Error.tryAsyncNoLoading(() async {
await NativeBridge.instance.favorite(
final applied = await TaskService.instance.favorite(
widget.channel.id!,
!widget.channel.favorite,
);
if (!mounted) return;
if (!applied || !mounted) return;
setState(() {
widget.channel.favorite = !widget.channel.favorite;
});
ScaffoldMessenger.of(context).showSnackBar(
Error.showSnackBar(
const SnackBar(
persist: false,
content: Text("Added to favorites"),
duration: Duration(milliseconds: 500),
),
);
}, context);
});
}

Future<int?> _handleSeries() async {
if (widget.channel.url?.isEmpty == true) {
if (context.mounted) {
Error.handleError(context, "Invalid series: series ID is null");
}
Error.handleError("Invalid series: series ID is null");
return null;
}
final seriesId = int.tryParse(widget.channel.url!);
if (seriesId == null) {
if (context.mounted) {
Error.handleError(
context,
"Invalid series: series ID is not a valid number",
);
}
Error.handleError("Invalid series: series ID is not a valid number");
return null;
}
await Error.tryAsync(
Expand Down Expand Up @@ -227,8 +222,9 @@ class _ChannelTileState extends State<ChannelTile> {
);
} else {
var settings = await NativeBridge.instance.getSettings();
NativeBridge.instance.addLastWatched(widget.channel.id!);
TaskService.instance.addLastWatched(widget.channel.id!);
if (!mounted) return;
TaskService.instance.playerVisible.value = true;
await Navigator.push(
context,
MaterialPageRoute(
Expand All @@ -237,6 +233,7 @@ class _ChannelTileState extends State<ChannelTile> {
: Player(channel: widget.channel, settings: settings),
),
);
TaskService.instance.playerVisible.value = false;
if (mounted) _focusNode.requestFocus();
}
}
Expand All @@ -256,7 +253,7 @@ class _ChannelTileState extends State<ChannelTile> {
statesController: _statesController,
borderRadius: BorderRadius.circular(12),
onLongPress: favorite,
onTap: () async => await play(),
onTap: play,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expand Down
Loading