Skip to content
Merged
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
26 changes: 0 additions & 26 deletions lib/models/latest_info.dart

This file was deleted.

65 changes: 1 addition & 64 deletions lib/pages/player/archive_player_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import '../../cubit/viewer/camera_view_state.dart';
import '../../cubit/viewer/ssh_cubit.dart';
import '../../cubit/viewer/view_state.dart';
import '../../models/camera.dart';
import '../../models/location.dart';
import 'player_base.dart';

abstract class ArchivePlayerBase extends PlayerBase {
Expand Down Expand Up @@ -52,60 +51,7 @@ abstract class ArchivePlayerBase extends PlayerBase {
}

abstract class ArchivePlayerBaseState<T extends ArchivePlayerBase>
extends PlayerBaseState<T> {
@override
void back(BuildContext context) => context.read<ArchiveViewCubit>().back();

@override
void quit(BuildContext context) => context.read<ArchiveViewCubit>().quit();

@override
void getStreamUrl(BuildContext context) => context
.read<ArchiveCameraViewCubit>()
.getStreamUrl(cameraName: widget.cameraName);

@override
void next(BuildContext context) => context.read<ArchiveViewCubit>().next();

@override
void previous(BuildContext context) =>
context.read<ArchiveViewCubit>().previous();

@override
void toggleFullScreen(BuildContext context) =>
context.read<ArchiveViewCubit>().toggleFullScreen();

@override
void updateCamera(BuildContext context, ViewUpdatedState state) =>
context.read<ArchiveCameraViewCubit>().updateCamera(state);

@override
void emitSshUrl(BuildContext bc, int port) {
bc
.read<ArchiveCameraViewCubit>()
.emitUrlState(host: 'localhost', port: port);
}

@override
void updateSelectedCameraAndLocation(BuildContext context, Camera camera,
Location location, bool isFreshState) =>
context
.read<ArchiveViewCubit>()
.updateSelectedCameraAndLocation(camera, location, isFreshState);

@override
BlocListener<ArchiveCameraViewCubit, CameraViewState>
createCameraViewBlocListener(
void Function(BuildContext context, CameraViewState state)
listener) =>
BlocListener<ArchiveCameraViewCubit, CameraViewState>(
listener: listener);

@override
BlocListener<ArchiveViewCubit, ViewState> createViewBlocListener(
void Function(BuildContext context, ViewState state) listener) =>
BlocListener<ArchiveViewCubit, ViewState>(listener: listener);

extends PlayerBaseState<T, ArchiveViewCubit, ArchiveCameraViewCubit> {
@override
BlocProvider<ArchiveCameraViewCubit> createViewBlocProvider(
BuildContext context, CameraPlayerStream playerStream) =>
Expand All @@ -127,13 +73,4 @@ abstract class ArchivePlayerBaseState<T extends ArchivePlayerBase>
),
),
);

@override
BlocBuilder<ArchiveCameraViewCubit, CameraViewState>
createCameraErrorViewBlocBuilder(
Widget Function(BuildContext context, CameraViewState state)
builder) =>
BlocBuilder<ArchiveCameraViewCubit, CameraViewState>(
builder: builder,
);
}
66 changes: 1 addition & 65 deletions lib/pages/player/live_player_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import '../../cubit/viewer/live_view_cubit.dart';
import '../../cubit/viewer/ssh_cubit.dart';
import '../../cubit/viewer/view_state.dart';
import '../../models/camera.dart';
import '../../models/location.dart';
import 'player_base.dart';

abstract class LivePlayerBase extends PlayerBase {
Expand Down Expand Up @@ -50,48 +49,7 @@ abstract class LivePlayerBase extends PlayerBase {
}

abstract class LivePlayerBaseState<T extends LivePlayerBase>
extends PlayerBaseState<T> {
@override
void toggleFullScreen(BuildContext context) =>
context.read<LiveViewCubit>().toggleFullScreen();

@override
void back(BuildContext context) => context.read<LiveViewCubit>().back();

@override
void quit(BuildContext context) => context.read<LiveViewCubit>().quit();

@override
void next(BuildContext context) => context.read<LiveViewCubit>().next();

@override
void previous(BuildContext context) =>
context.read<LiveViewCubit>().previous();

@override
void updateSelectedCameraAndLocation(
BuildContext context,
Camera camera,
Location location,
bool isFreshState,
) =>
context
.read<LiveViewCubit>()
.updateSelectedCameraAndLocation(camera, location, isFreshState);

@override
void getStreamUrl(BuildContext context) =>
context.read<LiveCameraViewCubit>().getStreamUrl();

@override
void updateCamera(BuildContext context, ViewUpdatedState state) =>
context.read<LiveCameraViewCubit>().updateCamera(state);

@override
void emitSshUrl(BuildContext bc, int port) {
bc.read<LiveCameraViewCubit>().emitUrlState(host: 'localhost', port: port);
}

extends PlayerBaseState<T, LiveViewCubit, LiveCameraViewCubit> {
@override
BlocProvider<LiveCameraViewCubit> createViewBlocProvider(
BuildContext context, CameraPlayerStream playerStream) =>
Expand All @@ -111,26 +69,4 @@ abstract class LivePlayerBaseState<T extends LivePlayerBase>
),
),
);

@override
BlocListener<LiveViewCubit, ViewState> createViewBlocListener(
void Function(BuildContext context, ViewState state) listener) =>
BlocListener<LiveViewCubit, ViewState>(listener: listener);

@override
BlocListener<LiveCameraViewCubit, CameraViewState>
createCameraViewBlocListener(
void Function(BuildContext context, CameraViewState state)
listener) =>
BlocListener<LiveCameraViewCubit, CameraViewState>(
listener: listener);

@override
BlocBuilder<LiveCameraViewCubit, CameraViewState>
createCameraErrorViewBlocBuilder(
Widget Function(BuildContext context, CameraViewState state)
builder) =>
BlocBuilder<LiveCameraViewCubit, CameraViewState>(
builder: builder,
);
}
66 changes: 35 additions & 31 deletions lib/pages/player/player_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
import 'dart:async';
import 'dart:developer';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

import '../../cubit/mixin/camera_view_cubit_mixin.dart';
import '../../cubit/viewer/camera_view_cubit.dart';
import '../../cubit/viewer/camera_view_state.dart';
import '../../cubit/viewer/ssh_cubit.dart';
import '../../cubit/viewer/thumbnail_cubit.dart';
import '../../cubit/viewer/video_player_cubit.dart';
import '../../cubit/viewer/view_cubit.dart';
import '../../cubit/viewer/view_state.dart';
import '../../cubit/viewer/viewer_keyboard_cubit.dart';
import '../../models/camera.dart';
Expand Down Expand Up @@ -52,7 +55,8 @@ abstract class PlayerBase extends StatefulWidget {
});
}

abstract class PlayerBaseState<T extends PlayerBase> extends State<T>
abstract class PlayerBaseState<T extends PlayerBase, VC extends ViewCubit,
CVC extends CameraViewCubit> extends State<T>
with WidgetsBindingObserver
implements LibHelper {
final TransformationController _controller = TransformationController();
Expand Down Expand Up @@ -208,8 +212,8 @@ abstract class PlayerBaseState<T extends PlayerBase> extends State<T>
? KeyEventResult.handled
: KeyEventResult.ignored,
child: BlocBuilder<ViewerKeyboardCubit, ViewerKeyboardState>(
builder: (context, state) => createCameraErrorViewBlocBuilder(
(context, errState) => Stack(
builder: (context, state) => BlocBuilder<CVC, CameraViewState>(
builder: (context, errState) => Stack(
alignment: Alignment.center,
children: [
Positioned.fill(
Expand Down Expand Up @@ -518,8 +522,8 @@ abstract class PlayerBaseState<T extends PlayerBase> extends State<T>
],
child: MultiBlocListener(
listeners: [
createCameraViewBlocListener(
(context, state) {
BlocListener<CVC, CameraViewState>(
listener: (context, state) {
if (state is! CameraViewErrorState) {
// If any state comes stop the error countdown timer.
// Not this can happen if any camera gives a temporary
Expand Down Expand Up @@ -569,8 +573,8 @@ abstract class PlayerBaseState<T extends PlayerBase> extends State<T>
}
},
),
createViewBlocListener(
(context, state) {
BlocListener<VC, ViewState>(
listener: (context, state) {
if (state is ViewUpdatedState &&
!state.isFreshState &&
state.selectedCamera != null &&
Expand Down Expand Up @@ -670,59 +674,59 @@ abstract class PlayerBaseState<T extends PlayerBase> extends State<T>
void startThumbnailGeneration(String cameraName, String locationName);

@protected
void toggleFullScreen(BuildContext context);
@nonVirtual
void toggleFullScreen(BuildContext context) =>
context.read<VC>().toggleFullScreen();

@protected
void back(BuildContext context);
@nonVirtual
void back(BuildContext context) => context.read<VC>().back();

@protected
void quit(BuildContext context);
@nonVirtual
void quit(BuildContext context) => context.read<VC>().quit();

@protected
void next(BuildContext context);
@nonVirtual
void next(BuildContext context) => context.read<VC>().next();

@protected
void previous(BuildContext context);
@nonVirtual
void previous(BuildContext context) => context.read<VC>().previous();

@override
@protected
Future<void> stop(BuildContext context);

@protected
void emitSshUrl(BuildContext bc, int port);
@nonVirtual
void emitSshUrl(BuildContext bc, int port) =>
bc.read<CVC>().emitUrlState(host: 'localhost', port: port);

@override
@protected
Widget createVideoWidget(BuildContext context, VideoPlayerState state);

@protected
@nonVirtual
void updateSelectedCameraAndLocation(BuildContext context, Camera camera,
Location location, bool isFreshState);
Location location, bool isFreshState) =>
context
.read<VC>()
.updateSelectedCameraAndLocation(camera, location, isFreshState);

@protected
void getStreamUrl(BuildContext context);
@nonVirtual
void getStreamUrl(BuildContext context) => context.read<CVC>().getStreamUrl();

@protected
void updateCamera(BuildContext context, ViewUpdatedState state);
@nonVirtual
void updateCamera(BuildContext context, ViewUpdatedState state) =>
context.read<CVC>().updateCamera(state);

@protected
BlocProvider createViewBlocProvider(
BuildContext context,
CameraPlayerStream playerStream,
);

@protected
BlocListener createViewBlocListener(
void Function(BuildContext context, ViewState state) listener,
);

@protected
BlocListener createCameraViewBlocListener(
void Function(BuildContext context, CameraViewState state) listener,
);

@protected
BlocBuilder createCameraErrorViewBlocBuilder(
Widget Function(BuildContext context, CameraViewState state) builder,
);
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,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: 2.9.0+1102
version: 2.9.1+1103

homepage: https://github.com/homebackend/netr/
repository: https://github.com/homebackend/netr/
Expand Down
Loading