Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Properly zoom in all matrix sizes #227

Merged
merged 9 commits into from
Mar 23, 2024
6 changes: 6 additions & 0 deletions lib/providers/desktop_view_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ class DesktopViewProvider extends UnityProvider {
}
}

if (previousDevice.matrixType != device.matrixType) {
final player = UnityPlayers.players[device.uuid];
player?.zoom.matrixType = device.matrixType ?? MatrixType.t16;
player?.zoom.zoomAxis = (-1, -1);
}

if (reload) {
UnityPlayers.reloadDevice(device);
}
Expand Down
19 changes: 18 additions & 1 deletion lib/providers/downloads_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import 'package:bluecherry_client/providers/settings_provider.dart';
import 'package:bluecherry_client/utils/constants.dart';
import 'package:bluecherry_client/utils/storage.dart';
import 'package:dio/dio.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:path/path.dart' as path;
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -230,7 +231,23 @@ class DownloadsManager extends UnityProvider {
downloading[event] = 0.0;
notifyListeners();

final dir = SettingsProvider.instance.kDownloadsDirectory.value;
final dir = await () async {
final settings = SettingsProvider.instance;

if (settings.kChooseLocationEveryTime.value) {
final selectedDirectory = await FilePicker.platform.getDirectoryPath(
dialogTitle: 'Choose download location',
initialDirectory: settings.kDownloadsDirectory.value,
lockParentWindow: true,
);

if (selectedDirectory != null) {
debugPrint('Selected directory: $selectedDirectory');
settings.kDownloadsDirectory.value = selectedDirectory;
}
}
return settings.kDownloadsDirectory.value;
}();
final fileName =
'event_${event.id}_${event.deviceID}_${event.server.name}.mp4';
final downloadPath = path.join(dir, fileName);
Expand Down
12 changes: 9 additions & 3 deletions lib/providers/settings_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import 'dart:io';

import 'package:bluecherry_client/providers/app_provider_interface.dart';
import 'package:bluecherry_client/providers/downloads_provider.dart';
import 'package:bluecherry_client/providers/update_provider.dart';
import 'package:bluecherry_client/utils/storage.dart';
import 'package:bluecherry_client/utils/video_player.dart';
import 'package:flutter/foundation.dart';
Expand All @@ -43,10 +44,11 @@ class _SettingsOption<T> {
late final String Function(T value) saveAs;
late final T Function(String value) loadFrom;
final ValueChanged<T>? onChanged;
final T Function()? valueOverrider;

late T _value;

T get value => _value;
T get value => valueOverrider?.call() ?? _value;
set value(T newValue) {
SettingsProvider.instance.updateProperty(() {
_value = newValue;
Expand All @@ -66,6 +68,7 @@ class _SettingsOption<T> {
this.min,
this.max,
this.onChanged,
this.valueOverrider,
}) {
Future.microtask(() async {
_value = getDefault != null ? await getDefault!() : def;
Expand Down Expand Up @@ -347,15 +350,18 @@ class SettingsProvider extends UnityProvider {
saveAs: (value) => value.index.toString(),
);
final kSoftwareZooming = _SettingsOption<bool>(
def: Platform.isMacOS ? true : false,
def: Platform.isMacOS || kIsWeb || UpdateManager.isEmbedded ? true : false,
key: 'other.software_zoom',
onChanged: (value) {
for (final player in UnityPlayers.players.values) {
player
..resetCrop()
..softwareZoom = value;
..zoom.softwareZoom = value;
}
},
valueOverrider: Platform.isMacOS || kIsWeb || UpdateManager.isEmbedded
? () => true
: null,
);
final kShowDebugInfo = _SettingsOption(
def: kDebugMode,
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/layouts/desktop/multicast_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class _MulticastViewportState extends State<MulticastViewport> {
next = previousZoom(currentZoom!, size);
}

view.player.crop(next.$1, next.$2, size);
view.player.crop(next.$1, next.$2);
debugPrint('next: $next');
currentZoom = next;
}
Expand Down Expand Up @@ -160,7 +160,7 @@ class _MulticastViewportState extends State<MulticastViewport> {
);
},
onPressed: () {
view.player.crop(row, col, size);
view.player.crop(row, col);
currentZoom = (row, col);
},
builder: (context, states) => SizedBox.expand(
Expand Down
36 changes: 32 additions & 4 deletions lib/screens/settings/advanced_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class AdvancedOptionsSettings extends StatelessWidget {
},
dense: false,
),
if (kDebugMode)
if (settings.kShowDebugInfo.value)
CheckboxListTile.adaptive(
contentPadding: DesktopSettings.horizontalPadding,
secondary: CircleAvatar(
Expand All @@ -187,7 +187,7 @@ class AdvancedOptionsSettings extends StatelessWidget {
contentPadding: DesktopSettings.horizontalPadding,
leading: CircleAvatar(
backgroundColor: Colors.transparent,
foregroundColor: theme.iconTheme.color,
foregroundColor: theme.colorScheme.error,
child: const Icon(Icons.restore),
),
title: const Text('Restore Defaults'),
Expand All @@ -196,8 +196,36 @@ class AdvancedOptionsSettings extends StatelessWidget {
'affect your servers or any other data.',
),
trailing: const Icon(Icons.navigate_next),
// TODO(bdlukaa): Show an "Are you sure?" dialog
onTap: settings.restoreDefaults,
textColor: theme.colorScheme.error,
iconColor: theme.colorScheme.error,
onTap: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Are you sure?'),
content: const Text(
'This will restore all settings to their default values. '
'This will not affect your servers or any other data.',
),
actions: [
FilledButton(
onPressed: () {
settings.restoreDefaults();
Navigator.of(context).pop();
},
child: Text(loc.yes),
),
TextButton(
autofocus: true,
onPressed: Navigator.of(context).pop,
child: Text(loc.no),
),
],
);
},
);
},
),
],
]);
Expand Down
18 changes: 12 additions & 6 deletions lib/screens/settings/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'package:bluecherry_client/screens/settings/settings_desktop.dart';
import 'package:bluecherry_client/screens/settings/shared/options_chooser_tile.dart';
import 'package:bluecherry_client/utils/extensions.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_localized_locales/flutter_localized_locales.dart';
Expand All @@ -39,7 +38,8 @@ class ApplicationSettings extends StatelessWidget {
final settings = context.watch<SettingsProvider>();
return ListView(padding: DesktopSettings.verticalPadding, children: [
OptionsChooserTile<ThemeMode>(
title: 'Theme',
title: loc.theme,
description: loc.themeDescription,
icon: Icons.contrast,
value: settings.kThemeMode.value,
values: ThemeMode.values.map((mode) {
Expand All @@ -51,7 +51,11 @@ class ApplicationSettings extends StatelessWidget {
ThemeMode.dark => Icons.dark_mode,
},
text: switch (mode) {
ThemeMode.system => loc.system,
ThemeMode.system => loc.system +
switch (MediaQuery.platformBrightnessOf(context)) {
Brightness.light => ' (${loc.light})',
Brightness.dark => ' (${loc.dark})',
},
ThemeMode.light => loc.light,
ThemeMode.dark => loc.dark,
},
Expand All @@ -64,7 +68,7 @@ class ApplicationSettings extends StatelessWidget {
const LanguageSection(),
const DateFormatSection(),
const TimeFormatSection(),
if (kDebugMode) ...[
if (settings.kShowDebugInfo.value) ...[
const SubHeader('Window'),
CheckboxListTile.adaptive(
value: settings.kLaunchAppOnStartup.value,
Expand Down Expand Up @@ -228,6 +232,7 @@ class DateFormatSection extends StatelessWidget {

@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
final settings = context.watch<SettingsProvider>();
final locale = Localizations.localeOf(context).toLanguageTag();
final formats = [
Expand All @@ -242,7 +247,7 @@ class DateFormatSection extends StatelessWidget {
].map((e) => DateFormat(e, locale));

return OptionsChooserTile(
title: 'Date Format',
title: loc.dateFormat,
description: 'What format to use for displaying dates',
icon: Icons.calendar_month,
value: '',
Expand All @@ -264,13 +269,14 @@ class TimeFormatSection extends StatelessWidget {

@override
Widget build(BuildContext context) {
final loc = AppLocalizations.of(context);
final settings = context.watch<SettingsProvider>();
final locale = Localizations.localeOf(context).toLanguageTag();

final patterns = ['HH:mm', 'hh:mm a'].map((e) => DateFormat(e, locale));
final date = DateTime.utc(1969, 7, 20, 14, 18, 04);
return OptionsChooserTile(
title: 'Time Format',
title: loc.timeFormat,
description: 'What format to use for displaying time',
icon: Icons.hourglass_empty,
value: '',
Expand Down
42 changes: 22 additions & 20 deletions lib/screens/settings/events_and_downloads.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import 'package:bluecherry_client/screens/settings/settings_desktop.dart';
import 'package:bluecherry_client/screens/settings/shared/options_chooser_tile.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
Expand All @@ -39,22 +38,26 @@ class EventsAndDownloadsSettings extends StatelessWidget {
final settings = context.watch<SettingsProvider>();
return ListView(children: [
SubHeader(loc.downloads),
if (kDebugMode)
CheckboxListTile.adaptive(
value: settings.kChooseLocationEveryTime.value,
onChanged: (v) {
if (v != null) {
settings.kChooseLocationEveryTime.value = v;
}
},
contentPadding: DesktopSettings.horizontalPadding,
secondary: CircleAvatar(
backgroundColor: Colors.transparent,
foregroundColor: theme.iconTheme.color,
child: const Icon(Icons.create_new_folder),
),
title: const Text('Choose location for each download'),
CheckboxListTile.adaptive(
value: settings.kChooseLocationEveryTime.value,
onChanged: (v) {
if (v != null) {
settings.kChooseLocationEveryTime.value = v;
}
},
contentPadding: DesktopSettings.horizontalPadding,
secondary: CircleAvatar(
backgroundColor: Colors.transparent,
foregroundColor: theme.iconTheme.color,
child: const Icon(Icons.create_new_folder),
),
title: const Text('Choose location for each download'),
subtitle: const Text(
'Whether to choose the location for each download or use the default '
'location. When enabled, you will be prompted to choose the download '
'directory for each download.',
),
),
ListTile(
contentPadding: DesktopSettings.horizontalPadding,
leading: CircleAvatar(
Expand All @@ -78,7 +81,7 @@ class EventsAndDownloadsSettings extends StatelessWidget {
}
},
),
if (kDebugMode)
if (settings.kShowDebugInfo.value)
CheckboxListTile.adaptive(
value: false,
onChanged: (v) {},
Expand All @@ -91,9 +94,8 @@ class EventsAndDownloadsSettings extends StatelessWidget {
title: const Text(
'Block the app from closing when there are ongoing downloads'),
),
const SizedBox(height: 20.0),
const SubHeader('Events'),
if (kDebugMode)
if (settings.kShowDebugInfo.value)
CheckboxListTile.adaptive(
value: settings.kPictureInPicture.value,
onChanged: (v) {
Expand Down Expand Up @@ -156,7 +158,7 @@ class EventsAndDownloadsSettings extends StatelessWidget {
),
),
const SizedBox(height: 20.0),
if (kDebugMode) ...[
if (settings.kShowDebugInfo.value) ...[
const SubHeader('Timeline of Events'),
CheckboxListTile.adaptive(
value: settings.kShowDifferentColorsForEvents.value,
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/settings/general.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import 'package:bluecherry_client/screens/settings/settings_desktop.dart';
import 'package:bluecherry_client/screens/settings/shared/options_chooser_tile.dart';
import 'package:bluecherry_client/utils/extensions.dart';
import 'package:bluecherry_client/widgets/misc.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -150,7 +149,7 @@ class GeneralSettings extends StatelessWidget {
settings.kNotificationClickBehavior.value = v;
},
),
if (kDebugMode) ...[
if (settings.kShowDebugInfo.value) ...[
const SubHeader(
'Data Usage',
padding: DesktopSettings.horizontalPadding,
Expand Down
3 changes: 1 addition & 2 deletions lib/screens/settings/privacy_and_security.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:bluecherry_client/providers/settings_provider.dart';
import 'package:bluecherry_client/screens/settings/settings_desktop.dart';
import 'package:bluecherry_client/screens/settings/shared/options_chooser_tile.dart';
import 'package:bluecherry_client/utils/extensions.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

Expand Down Expand Up @@ -70,7 +69,7 @@ class PrivacySecuritySettings extends StatelessWidget {
settings.kAllowCrashReports.value = v;
},
),
if (kDebugMode) ...[
if (settings.kShowDebugInfo.value) ...[
const Divider(),
ListTile(
contentPadding: DesktopSettings.horizontalPadding,
Expand Down
4 changes: 2 additions & 2 deletions lib/screens/settings/server_and_devices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class StreamingSettings extends StatelessWidget {
settings.kVideoFit.value = v;
},
),
if (kDebugMode) ...[
if (settings.kShowDebugInfo.value) ...[
const SizedBox(height: 8.0),
OptionsChooserTile(
title: 'Refresh Period',
Expand Down Expand Up @@ -213,7 +213,7 @@ class StreamingSettings extends StatelessWidget {
},
),
const SizedBox(height: 8.0),
if (kDebugMode) ...[
if (settings.kShowDebugInfo.value) ...[
CheckboxListTile.adaptive(
secondary: CircleAvatar(
backgroundColor: Colors.transparent,
Expand Down
4 changes: 2 additions & 2 deletions macos/Flutter/ephemeral/Flutter-Generated.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ FLUTTER_ROOT=C:\Users\bruno\Documents\flutter\flutter
FLUTTER_APPLICATION_PATH=C:\Users\bruno\Documents\flutter\paid_projects\unity
COCOAPODS_PARALLEL_CODE_SIGN=true
FLUTTER_BUILD_DIR=build
FLUTTER_BUILD_NAME=3.0.014
FLUTTER_BUILD_NUMBER=3.0.014
FLUTTER_BUILD_NAME=3.0.015
FLUTTER_BUILD_NUMBER=3.0.015
DART_OBFUSCATION=false
TRACK_WIDGET_CREATION=true
TREE_SHAKE_ICONS=false
Expand Down
4 changes: 2 additions & 2 deletions macos/Flutter/ephemeral/flutter_export_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ export "FLUTTER_ROOT=C:\Users\bruno\Documents\flutter\flutter"
export "FLUTTER_APPLICATION_PATH=C:\Users\bruno\Documents\flutter\paid_projects\unity"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=3.0.014"
export "FLUTTER_BUILD_NUMBER=3.0.014"
export "FLUTTER_BUILD_NAME=3.0.015"
export "FLUTTER_BUILD_NUMBER=3.0.015"
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
Expand Down
Loading
Loading