mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 18:38:48 +01:00
Graduate shared album from experiments
This commit is contained in:
parent
efd5db62ff
commit
05e1aecbf3
5 changed files with 22 additions and 115 deletions
|
@ -182,14 +182,6 @@ class Pref {
|
||||||
Future<bool> setGpsMapProvider(int value) => _set<int>(PrefKey.gpsMapProvider,
|
Future<bool> setGpsMapProvider(int value) => _set<int>(PrefKey.gpsMapProvider,
|
||||||
value, (key, value) => provider.setInt(key, value));
|
value, (key, value) => provider.setInt(key, value));
|
||||||
|
|
||||||
bool? isLabEnableSharedAlbum() =>
|
|
||||||
provider.getBool(PrefKey.labEnableSharedAlbum);
|
|
||||||
bool isLabEnableSharedAlbumOr(bool def) => isLabEnableSharedAlbum() ?? def;
|
|
||||||
Future<bool> setLabEnableSharedAlbum(bool value) => _set<bool>(
|
|
||||||
PrefKey.labEnableSharedAlbum,
|
|
||||||
value,
|
|
||||||
(key, value) => provider.setBool(key, value));
|
|
||||||
|
|
||||||
bool? hasShownSharedAlbumInfo() =>
|
bool? hasShownSharedAlbumInfo() =>
|
||||||
provider.getBool(PrefKey.hasShownSharedAlbumInfo);
|
provider.getBool(PrefKey.hasShownSharedAlbumInfo);
|
||||||
bool hasShownSharedAlbumInfoOr(bool def) => hasShownSharedAlbumInfo() ?? def;
|
bool hasShownSharedAlbumInfoOr(bool def) => hasShownSharedAlbumInfo() ?? def;
|
||||||
|
|
|
@ -60,13 +60,11 @@ class _HomeState extends State<Home> with TickerProviderStateMixin {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (Pref().isLabEnableSharedAlbumOr(false)) {
|
|
||||||
_importPotentialSharedAlbum().then((value) {
|
_importPotentialSharedAlbum().then((value) {
|
||||||
if (value.isNotEmpty) {
|
if (value.isNotEmpty) {
|
||||||
AccountPref.of(widget.account).setNewSharedAlbum(true);
|
AccountPref.of(widget.account).setNewSharedAlbum(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
_animationController.value = 1;
|
_animationController.value = 1;
|
||||||
|
|
||||||
// call once to pre-cache the value
|
// call once to pre-cache the value
|
||||||
|
|
|
@ -181,14 +181,14 @@ class _SettingsState extends State<Settings> {
|
||||||
label: L10n.global().settingsMiscellaneousTitle,
|
label: L10n.global().settingsMiscellaneousTitle,
|
||||||
builder: () => const _MiscSettings(),
|
builder: () => const _MiscSettings(),
|
||||||
),
|
),
|
||||||
if (_enabledExperiments.isNotEmpty)
|
// if (_enabledExperiments.isNotEmpty)
|
||||||
_buildSubSettings(
|
// _buildSubSettings(
|
||||||
context,
|
// context,
|
||||||
leading: const Icon(Icons.science_outlined),
|
// leading: const Icon(Icons.science_outlined),
|
||||||
label: L10n.global().settingsExperimentalTitle,
|
// label: L10n.global().settingsExperimentalTitle,
|
||||||
description: L10n.global().settingsExperimentalDescription,
|
// description: L10n.global().settingsExperimentalDescription,
|
||||||
builder: () => _ExperimentalSettings(),
|
// builder: () => _ExperimentalSettings(),
|
||||||
),
|
// ),
|
||||||
_buildSubSettings(
|
_buildSubSettings(
|
||||||
context,
|
context,
|
||||||
leading: const Icon(Icons.warning_amber),
|
leading: const Icon(Icons.warning_amber),
|
||||||
|
@ -1582,73 +1582,6 @@ class _MiscSettingsState extends State<_MiscSettings> {
|
||||||
late bool _isDoubleTapExit;
|
late bool _isDoubleTapExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ExperimentalSettings extends StatefulWidget {
|
|
||||||
@override
|
|
||||||
createState() => _ExperimentalSettingsState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@npLog
|
|
||||||
class _ExperimentalSettingsState extends State<_ExperimentalSettings> {
|
|
||||||
@override
|
|
||||||
initState() {
|
|
||||||
super.initState();
|
|
||||||
_isEnableSharedAlbum = Pref().isLabEnableSharedAlbumOr(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
body: Builder(
|
|
||||||
builder: (context) => _buildContent(context),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _buildContent(BuildContext context) {
|
|
||||||
return CustomScrollView(
|
|
||||||
slivers: [
|
|
||||||
SliverAppBar(
|
|
||||||
pinned: true,
|
|
||||||
title: Text(L10n.global().settingsExperimentalTitle),
|
|
||||||
),
|
|
||||||
SliverList(
|
|
||||||
delegate: SliverChildListDelegate(
|
|
||||||
[
|
|
||||||
if (_enabledExperiments.contains(_Experiment.sharedAlbum))
|
|
||||||
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().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;
|
|
||||||
}
|
|
||||||
|
|
||||||
class _DevSettings extends StatefulWidget {
|
class _DevSettings extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
createState() => _DevSettingsState();
|
createState() => _DevSettingsState();
|
||||||
|
@ -1718,10 +1651,5 @@ Widget _buildCaption(BuildContext context, String label) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum _Experiment {
|
// final _enabledExperiments = [
|
||||||
sharedAlbum,
|
// ];
|
||||||
}
|
|
||||||
|
|
||||||
final _enabledExperiments = [
|
|
||||||
_Experiment.sharedAlbum,
|
|
||||||
];
|
|
||||||
|
|
|
@ -55,13 +55,6 @@ extension _$_MiscSettingsStateNpLog on _MiscSettingsState {
|
||||||
static final log = Logger("widget.settings._MiscSettingsState");
|
static final log = Logger("widget.settings._MiscSettingsState");
|
||||||
}
|
}
|
||||||
|
|
||||||
extension _$_ExperimentalSettingsStateNpLog on _ExperimentalSettingsState {
|
|
||||||
// ignore: unused_element
|
|
||||||
Logger get _log => log;
|
|
||||||
|
|
||||||
static final log = Logger("widget.settings._ExperimentalSettingsState");
|
|
||||||
}
|
|
||||||
|
|
||||||
extension _$_DevSettingsStateNpLog on _DevSettingsState {
|
extension _$_DevSettingsStateNpLog on _DevSettingsState {
|
||||||
// ignore: unused_element
|
// ignore: unused_element
|
||||||
Logger get _log => log;
|
Logger get _log => log;
|
||||||
|
|
|
@ -66,7 +66,6 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (Pref().isLabEnableSharedAlbumOr(false)) {
|
|
||||||
_importPotentialSharedAlbum().whenComplete(() {
|
_importPotentialSharedAlbum().whenComplete(() {
|
||||||
_initBloc();
|
_initBloc();
|
||||||
});
|
});
|
||||||
|
@ -75,9 +74,6 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
obj.setNewSharedAlbum(false);
|
obj.setNewSharedAlbum(false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
_initBloc();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Reference in a new issue