Skip to content

Commit 9001aba

Browse files
committed
feat: Enable Area Magnification on mobile live player
1 parent 9b15893 commit 9001aba

File tree

3 files changed

+54
-12
lines changed

3 files changed

+54
-12
lines changed

lib/screens/layouts/desktop/multicast_view.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import 'package:bluecherry_client/models/device.dart';
2424
import 'package:bluecherry_client/providers/layouts_provider.dart';
2525
import 'package:bluecherry_client/providers/settings_provider.dart';
2626
import 'package:bluecherry_client/utils/constants.dart';
27+
import 'package:bluecherry_client/utils/methods.dart';
2728
import 'package:bluecherry_client/widgets/hover_button.dart';
2829
import 'package:bluecherry_client/widgets/misc.dart';
2930
import 'package:flutter/gestures.dart';
@@ -33,8 +34,9 @@ import 'package:unity_video_player/unity_video_player.dart';
3334

3435
class MulticastViewport extends StatefulWidget {
3536
final Device? device;
37+
final bool showMobileGrid;
3638

37-
const MulticastViewport({super.key, this.device});
39+
const MulticastViewport({super.key, this.device, this.showMobileGrid = true});
3840

3941
@override
4042
State<MulticastViewport> createState() => _MulticastViewportState();
@@ -187,13 +189,14 @@ class _MulticastViewportState extends State<MulticastViewport> {
187189
(context, states) => SizedBox.expand(
188190
child: IgnorePointer(
189191
child:
190-
states.isHovering
192+
(isMobile && widget.showMobileGrid) ||
193+
states.isHovering
191194
? Container(
192195
decoration: BoxDecoration(
193196
border: Border.all(
194197
color:
195198
theme.colorScheme.secondary,
196-
width: 2.25,
199+
width: isMobile ? 0.5 : 2.25,
197200
),
198201
),
199202
)

lib/screens/players/live_player.dart

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class _LivePlayerState extends State<LivePlayer> {
101101

102102
@override
103103
Widget build(BuildContext context) {
104-
if (isMobilePlatform) {
104+
if (isMobile) {
105105
return _MobileLivePlayer(
106106
player: widget.player,
107107
device: widget.device,
@@ -133,12 +133,14 @@ class _MobileLivePlayer extends StatefulWidget {
133133
}
134134

135135
class __MobileLivePlayerState extends State<_MobileLivePlayer> {
136-
bool overlay = true;
136+
var overlay = true;
137137
late UnityVideoFit fit =
138138
widget.device.server.additionalSettings.videoFit ??
139139
SettingsProvider.instance.kVideoFit.value;
140140

141141
late bool ptzEnabled = widget.ptzEnabled;
142+
var showMagnificationGrid =
143+
SettingsProvider.instance.kMatrixedZoomEnabled.value;
142144

143145
@override
144146
void initState() {
@@ -197,8 +199,26 @@ class __MobileLivePlayerState extends State<_MobileLivePlayer> {
197199
strokeWidth: 3.45,
198200
),
199201
)
200-
else if (commands.isNotEmpty)
201-
PTZData(commands: commands),
202+
else ...[
203+
if (showMagnificationGrid)
204+
Positioned.fill(
205+
child: Center(
206+
child: AspectRatio(
207+
aspectRatio:
208+
controller.aspectRatio == 0 ||
209+
controller.aspectRatio ==
210+
double.infinity
211+
? 16 / 9
212+
: controller.aspectRatio,
213+
child: MulticastViewport(
214+
device: widget.device,
215+
showMobileGrid: showMagnificationGrid,
216+
),
217+
),
218+
),
219+
),
220+
if (commands.isNotEmpty) PTZData(commands: commands),
221+
],
202222
PositionedDirectional(
203223
top: 0.0,
204224
start: 0.0,
@@ -235,12 +255,29 @@ class __MobileLivePlayerState extends State<_MobileLivePlayer> {
235255
trailing: Row(
236256
mainAxisSize: MainAxisSize.min,
237257
children: [
238-
CameraViewFitButton(
239-
fit: fit,
240-
onChanged: (newFit) {
241-
setState(() => fit = newFit);
242-
},
258+
SquaredIconButton(
259+
icon: Icon(
260+
showMagnificationGrid
261+
? Icons.grid_on_rounded
262+
: Icons.grid_off_rounded,
263+
),
264+
tooltip:
265+
showMagnificationGrid
266+
? 'Disable magnification grid'
267+
: 'Enable magnification grid',
268+
onPressed:
269+
() => setState(
270+
() =>
271+
showMagnificationGrid =
272+
!showMagnificationGrid,
273+
),
243274
),
275+
// CameraViewFitButton(
276+
// fit: fit,
277+
// onChanged: (newFit) {
278+
// setState(() => fit = newFit);
279+
// },
280+
// ),
244281
if (widget.device.hasPTZ)
245282
PTZToggleButton(
246283
ptzEnabled: ptzEnabled,

lib/screens/settings/server_and_devices.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ class AreaMagnificationSettings extends StatelessWidget {
504504
),
505505
OptionsChooserTile<MatrixType>(
506506
title: loc.defaultMatrixSize,
507+
description:
508+
'Double tap on the view to change the magnification area size',
507509
icon: Icons.view_quilt,
508510
value: settings.kMatrixSize.value,
509511
values: MatrixType.values.map((size) {

0 commit comments

Comments
 (0)