mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Lab settings are now more accessible
This commit is contained in:
parent
36611c7f35
commit
6052d82047
9 changed files with 104 additions and 150 deletions
|
@ -382,6 +382,9 @@
|
|||
"@settingsUseBlackInDarkThemeFalseDescription": {
|
||||
"description": "When black in dark theme is set to false"
|
||||
},
|
||||
"settingsExperimentalTitle": "Experimental",
|
||||
"settingsExperimentalDescription": "Features that are not ready for everyday use",
|
||||
"settingsExperimentalPageTitle": "Experimental settings",
|
||||
"settingsAboutSectionTitle": "About",
|
||||
"@settingsAboutSectionTitle": {
|
||||
"description": "Title of the about section in settings widget"
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
"settingsAlbumPageTitle",
|
||||
"settingsShowDateInAlbumTitle",
|
||||
"settingsShowDateInAlbumDescription",
|
||||
"settingsExperimentalTitle",
|
||||
"settingsExperimentalDescription",
|
||||
"settingsExperimentalPageTitle",
|
||||
"sortOptionManualLabel",
|
||||
"collectionSharingLabel",
|
||||
"fileLastSharedDescription",
|
||||
|
@ -61,6 +64,9 @@
|
|||
"settingsAlbumPageTitle",
|
||||
"settingsShowDateInAlbumTitle",
|
||||
"settingsShowDateInAlbumDescription",
|
||||
"settingsExperimentalTitle",
|
||||
"settingsExperimentalDescription",
|
||||
"settingsExperimentalPageTitle",
|
||||
"timeSecondInputHint",
|
||||
"sortOptionManualLabel",
|
||||
"slideshowTooltip",
|
||||
|
@ -138,6 +144,9 @@
|
|||
"settingsUseBlackInDarkThemeTitle",
|
||||
"settingsUseBlackInDarkThemeTrueDescription",
|
||||
"settingsUseBlackInDarkThemeFalseDescription",
|
||||
"settingsExperimentalTitle",
|
||||
"settingsExperimentalDescription",
|
||||
"settingsExperimentalPageTitle",
|
||||
"settingsCaptureLogsTitle",
|
||||
"settingsCaptureLogsDescription",
|
||||
"captureLogDetails",
|
||||
|
@ -240,6 +249,9 @@
|
|||
"settingsAlbumPageTitle",
|
||||
"settingsShowDateInAlbumTitle",
|
||||
"settingsShowDateInAlbumDescription",
|
||||
"settingsExperimentalTitle",
|
||||
"settingsExperimentalDescription",
|
||||
"settingsExperimentalPageTitle",
|
||||
"sortOptionManualLabel",
|
||||
"collectionSharingLabel",
|
||||
"fileLastSharedDescription",
|
||||
|
@ -303,6 +315,9 @@
|
|||
"settingsUseBlackInDarkThemeTitle",
|
||||
"settingsUseBlackInDarkThemeTrueDescription",
|
||||
"settingsUseBlackInDarkThemeFalseDescription",
|
||||
"settingsExperimentalTitle",
|
||||
"settingsExperimentalDescription",
|
||||
"settingsExperimentalPageTitle",
|
||||
"settingsCaptureLogsTitle",
|
||||
"settingsCaptureLogsDescription",
|
||||
"captureLogDetails",
|
||||
|
@ -385,6 +400,9 @@
|
|||
"settingsAlbumPageTitle",
|
||||
"settingsShowDateInAlbumTitle",
|
||||
"settingsShowDateInAlbumDescription",
|
||||
"settingsExperimentalTitle",
|
||||
"settingsExperimentalDescription",
|
||||
"settingsExperimentalPageTitle",
|
||||
"settingsCaptureLogsTitle",
|
||||
"settingsCaptureLogsDescription",
|
||||
"captureLogDetails",
|
||||
|
|
15
lib/lab.dart
15
lib/lab.dart
|
@ -1,15 +0,0 @@
|
|||
import 'package:nc_photos/pref.dart';
|
||||
|
||||
/// Experimental feature flags
|
||||
class Lab {
|
||||
factory Lab() {
|
||||
_inst ??= Lab._();
|
||||
return _inst!;
|
||||
}
|
||||
|
||||
bool get enableSharedAlbum => Pref.inst().isLabEnableSharedAlbumOr(false);
|
||||
|
||||
Lab._();
|
||||
|
||||
static Lab? _inst;
|
||||
}
|
|
@ -19,7 +19,6 @@ import 'package:nc_photos/entity/share/data_source.dart';
|
|||
import 'package:nc_photos/event/event.dart';
|
||||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/lab.dart';
|
||||
import 'package:nc_photos/list_extension.dart';
|
||||
import 'package:nc_photos/or_null.dart';
|
||||
import 'package:nc_photos/pref.dart';
|
||||
|
@ -242,7 +241,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
_album!,
|
||||
actions: [
|
||||
if (_album!.albumFile!.isOwned(widget.account.username) &&
|
||||
Lab().enableSharedAlbum)
|
||||
Pref.inst().isLabEnableSharedAlbumOr(false))
|
||||
IconButton(
|
||||
onPressed: () => _onSharePressed(context),
|
||||
icon: const Icon(Icons.share),
|
||||
|
@ -251,7 +250,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
|||
],
|
||||
menuItemBuilder: (_) => [
|
||||
if (_album!.albumFile!.isOwned(widget.account.username) &&
|
||||
Lab().enableSharedAlbum)
|
||||
Pref.inst().isLabEnableSharedAlbumOr(false))
|
||||
PopupMenuItem(
|
||||
value: _menuValueFixShares,
|
||||
child: Text(L10n.global().fixSharesTooltip),
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'package:nc_photos/entity/album.dart';
|
|||
import 'package:nc_photos/entity/file.dart';
|
||||
import 'package:nc_photos/entity/file/data_source.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/lab.dart';
|
||||
import 'package:nc_photos/pref.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/use_case/import_potential_shared_album.dart';
|
||||
|
@ -48,7 +47,7 @@ class _HomeState extends State<Home> {
|
|||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
if (Lab().enableSharedAlbum) {
|
||||
if (Pref.inst().isLabEnableSharedAlbumOr(false)) {
|
||||
_importPotentialSharedAlbum().then((value) {
|
||||
if (value.isNotEmpty) {
|
||||
Pref.inst().setNewSharedAlbum(true);
|
||||
|
|
|
@ -1,116 +0,0 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:nc_photos/pref.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
|
||||
class LabSettings extends StatefulWidget {
|
||||
static const routeName = "/lab-settings";
|
||||
|
||||
const LabSettings({
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
createState() => _LabSettingsState();
|
||||
}
|
||||
|
||||
class _LabSettingsState extends State<LabSettings> {
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (context) => AlertDialog(
|
||||
title: const Text("Warning"),
|
||||
content: const Text(
|
||||
"Features listed here may be untested, unfinished, or even completely broken. They may break the app and corrupt your data. No help/support will be provided.\n\nDO NOT proceed unless you understand the risk"),
|
||||
actions: [
|
||||
Align(
|
||||
alignment: AlignmentDirectional.centerEnd,
|
||||
child: TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
child: const Text("I UNDERSTAND"),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
).then((value) {
|
||||
if (value != true) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
return AppTheme(
|
||||
child: Scaffold(
|
||||
body: Builder(builder: (context) => _buildContent(context)),
|
||||
appBar: AppBar(
|
||||
title: const Text("Lab Settings"),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
return ListView(
|
||||
children: [
|
||||
_LabBoolItem(
|
||||
title: const Text("enableSharedAlbum"),
|
||||
isSelected: Pref.inst().isLabEnableSharedAlbumOr(false),
|
||||
onChanged: (value) {
|
||||
Pref.inst().setLabEnableSharedAlbum(value);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _LabBoolItem extends StatefulWidget {
|
||||
const _LabBoolItem({
|
||||
Key? key,
|
||||
required this.title,
|
||||
this.subtitle,
|
||||
required this.isSelected,
|
||||
this.onChanged,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
createState() => _LabBoolItemState();
|
||||
|
||||
final Widget title;
|
||||
final Widget? subtitle;
|
||||
final bool isSelected;
|
||||
final ValueChanged<bool>? onChanged;
|
||||
}
|
||||
|
||||
class _LabBoolItemState extends State<_LabBoolItem> {
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
_isSelected = widget.isSelected;
|
||||
}
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
return CheckboxListTile(
|
||||
title: widget.title,
|
||||
subtitle: widget.subtitle,
|
||||
value: _isSelected,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
_isSelected = value!;
|
||||
});
|
||||
widget.onChanged?.call(value!);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
late bool _isSelected;
|
||||
}
|
|
@ -16,7 +16,6 @@ import 'package:nc_photos/widget/archive_browser.dart';
|
|||
import 'package:nc_photos/widget/connect.dart';
|
||||
import 'package:nc_photos/widget/dynamic_album_browser.dart';
|
||||
import 'package:nc_photos/widget/home.dart';
|
||||
import 'package:nc_photos/widget/lab_settings.dart';
|
||||
import 'package:nc_photos/widget/people_browser.dart';
|
||||
import 'package:nc_photos/widget/person_browser.dart';
|
||||
import 'package:nc_photos/widget/root_picker.dart';
|
||||
|
@ -125,7 +124,6 @@ class _MyAppState extends State<MyApp> implements SnackBarHandler {
|
|||
Setup.routeName: (context) => const Setup(),
|
||||
SignIn.routeName: (context) => const SignIn(),
|
||||
Splash.routeName: (context) => const Splash(),
|
||||
LabSettings.routeName: (context) => const LabSettings(),
|
||||
};
|
||||
|
||||
Route<dynamic>? _onGenerateRoute(RouteSettings settings) {
|
||||
|
|
|
@ -17,7 +17,6 @@ import 'package:nc_photos/snack_bar_manager.dart';
|
|||
import 'package:nc_photos/theme.dart';
|
||||
import 'package:nc_photos/widget/fancy_option_picker.dart';
|
||||
import 'package:nc_photos/widget/home.dart';
|
||||
import 'package:nc_photos/widget/lab_settings.dart';
|
||||
import 'package:nc_photos/widget/root_picker.dart';
|
||||
import 'package:nc_photos/widget/share_folder_picker.dart';
|
||||
import 'package:nc_photos/widget/stateful_slider.dart';
|
||||
|
@ -136,11 +135,20 @@ class _SettingsState extends State<Settings> {
|
|||
description: L10n.global().settingsThemeDescription,
|
||||
builder: () => _ThemeSettings(),
|
||||
),
|
||||
_buildSubSettings(
|
||||
context,
|
||||
leading: Icon(
|
||||
Icons.science_outlined,
|
||||
color: AppTheme.getUnfocusedIconColor(context),
|
||||
),
|
||||
label: L10n.global().settingsExperimentalTitle,
|
||||
description: L10n.global().settingsExperimentalDescription,
|
||||
builder: () => _ExperimentalSettings(),
|
||||
),
|
||||
_buildCaption(context, L10n.global().settingsAboutSectionTitle),
|
||||
ListTile(
|
||||
title: Text(L10n.global().settingsVersionTitle),
|
||||
subtitle: const Text(k.versionStr),
|
||||
onTap: () => _onVersionTap(context),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10n.global().settingsSourceCodeTitle),
|
||||
|
@ -274,13 +282,6 @@ class _SettingsState extends State<Settings> {
|
|||
}
|
||||
}
|
||||
|
||||
void _onVersionTap(BuildContext context) {
|
||||
if (++_labUnlockCount >= 10) {
|
||||
Navigator.of(context).pushNamed(LabSettings.routeName);
|
||||
_labUnlockCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void _onCaptureLogChanged(BuildContext context, bool value) async {
|
||||
if (value) {
|
||||
final result = await showDialog<bool>(
|
||||
|
@ -357,7 +358,6 @@ class _SettingsState extends State<Settings> {
|
|||
}
|
||||
|
||||
late bool _isEnableExif;
|
||||
int _labUnlockCount = 0;
|
||||
|
||||
static final _log = Logger("widget.settings._SettingsState");
|
||||
|
||||
|
@ -1037,6 +1037,75 @@ class _ThemeSettingsState extends State<_ThemeSettings> {
|
|||
static final _log = Logger("widget.settings._ThemeSettingsState");
|
||||
}
|
||||
|
||||
class _ExperimentalSettings extends StatefulWidget {
|
||||
@override
|
||||
createState() => _ExperimentalSettingsState();
|
||||
}
|
||||
|
||||
class _ExperimentalSettingsState extends State<_ExperimentalSettings> {
|
||||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
_isEnableSharedAlbum = Pref.inst().isLabEnableSharedAlbumOr(false);
|
||||
}
|
||||
|
||||
@override
|
||||
build(BuildContext context) {
|
||||
return AppTheme(
|
||||
child: Scaffold(
|
||||
body: Builder(
|
||||
builder: (context) => _buildContent(context),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildContent(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
pinned: true,
|
||||
title: Text(L10n.global().settingsExperimentalPageTitle),
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildListDelegate(
|
||||
[
|
||||
SwitchListTile(
|
||||
title: const Text("Shared album"),
|
||||
subtitle:
|
||||
const Text("Share albums with users on the same server"),
|
||||
value: _isEnableSharedAlbum,
|
||||
onChanged: (value) => _onEnableSharedAlbumChanged(value),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _onEnableSharedAlbumChanged(bool value) async {
|
||||
final oldValue = _isEnableSharedAlbum;
|
||||
setState(() {
|
||||
_isEnableSharedAlbum = value;
|
||||
});
|
||||
if (!await Pref.inst().setLabEnableSharedAlbum(value)) {
|
||||
_log.severe("[_onEnableSharedAlbumChanged] Failed writing pref");
|
||||
SnackBarManager().showSnackBar(SnackBar(
|
||||
content: Text(L10n.global().writePreferenceFailureNotification),
|
||||
duration: k.snackBarDurationNormal,
|
||||
));
|
||||
setState(() {
|
||||
_isEnableSharedAlbum = oldValue;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
late bool _isEnableSharedAlbum;
|
||||
|
||||
static final _log = Logger("widget.settings._ExperimentalSettingsState");
|
||||
}
|
||||
|
||||
Widget _buildCaption(BuildContext context, String label) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 16, 16, 8),
|
||||
|
|
|
@ -17,7 +17,6 @@ import 'package:nc_photos/entity/share.dart';
|
|||
import 'package:nc_photos/exception_util.dart' as exception_util;
|
||||
import 'package:nc_photos/iterable_extension.dart';
|
||||
import 'package:nc_photos/k.dart' as k;
|
||||
import 'package:nc_photos/lab.dart';
|
||||
import 'package:nc_photos/pref.dart';
|
||||
import 'package:nc_photos/snack_bar_manager.dart';
|
||||
import 'package:nc_photos/theme.dart';
|
||||
|
@ -62,7 +61,7 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
|||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
if (Lab().enableSharedAlbum) {
|
||||
if (Pref.inst().isLabEnableSharedAlbumOr(false)) {
|
||||
_importPotentialSharedAlbum().whenComplete(() {
|
||||
_initBloc();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue