mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-02-24 10:28:50 +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,
|
||||
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() =>
|
||||
provider.getBool(PrefKey.hasShownSharedAlbumInfo);
|
||||
bool hasShownSharedAlbumInfoOr(bool def) => hasShownSharedAlbumInfo() ?? def;
|
||||
|
|
|
@ -60,13 +60,11 @@ class _HomeState extends State<Home> with TickerProviderStateMixin {
|
|||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
if (Pref().isLabEnableSharedAlbumOr(false)) {
|
||||
_importPotentialSharedAlbum().then((value) {
|
||||
if (value.isNotEmpty) {
|
||||
AccountPref.of(widget.account).setNewSharedAlbum(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
_animationController.value = 1;
|
||||
|
||||
// call once to pre-cache the value
|
||||
|
|
|
@ -181,14 +181,14 @@ class _SettingsState extends State<Settings> {
|
|||
label: L10n.global().settingsMiscellaneousTitle,
|
||||
builder: () => const _MiscSettings(),
|
||||
),
|
||||
if (_enabledExperiments.isNotEmpty)
|
||||
_buildSubSettings(
|
||||
context,
|
||||
leading: const Icon(Icons.science_outlined),
|
||||
label: L10n.global().settingsExperimentalTitle,
|
||||
description: L10n.global().settingsExperimentalDescription,
|
||||
builder: () => _ExperimentalSettings(),
|
||||
),
|
||||
// if (_enabledExperiments.isNotEmpty)
|
||||
// _buildSubSettings(
|
||||
// context,
|
||||
// leading: const Icon(Icons.science_outlined),
|
||||
// label: L10n.global().settingsExperimentalTitle,
|
||||
// description: L10n.global().settingsExperimentalDescription,
|
||||
// builder: () => _ExperimentalSettings(),
|
||||
// ),
|
||||
_buildSubSettings(
|
||||
context,
|
||||
leading: const Icon(Icons.warning_amber),
|
||||
|
@ -1582,73 +1582,6 @@ class _MiscSettingsState extends State<_MiscSettings> {
|
|||
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 {
|
||||
@override
|
||||
createState() => _DevSettingsState();
|
||||
|
@ -1718,10 +1651,5 @@ Widget _buildCaption(BuildContext context, String label) {
|
|||
);
|
||||
}
|
||||
|
||||
enum _Experiment {
|
||||
sharedAlbum,
|
||||
}
|
||||
|
||||
final _enabledExperiments = [
|
||||
_Experiment.sharedAlbum,
|
||||
];
|
||||
// final _enabledExperiments = [
|
||||
// ];
|
||||
|
|
|
@ -55,13 +55,6 @@ extension _$_MiscSettingsStateNpLog on _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 {
|
||||
// ignore: unused_element
|
||||
Logger get _log => log;
|
||||
|
|
|
@ -66,7 +66,6 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
|||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
if (Pref().isLabEnableSharedAlbumOr(false)) {
|
||||
_importPotentialSharedAlbum().whenComplete(() {
|
||||
_initBloc();
|
||||
});
|
||||
|
@ -75,9 +74,6 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
|||
obj.setNewSharedAlbum(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_initBloc();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
Loading…
Reference in a new issue