mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-03-22 06:59:21 +01:00
Simplify Pref access
This commit is contained in:
parent
be220071cd
commit
9ca333403f
24 changed files with 93 additions and 96 deletions
|
@ -47,7 +47,7 @@ enum _AppLanguageEnum {
|
||||||
|
|
||||||
AppLanguage _getSelectedLanguage() {
|
AppLanguage _getSelectedLanguage() {
|
||||||
try {
|
try {
|
||||||
final lang = Pref.inst().getLanguageOr(0);
|
final lang = Pref().getLanguageOr(0);
|
||||||
return supportedLanguages[lang]!;
|
return supportedLanguages[lang]!;
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return supportedLanguages[_AppLanguageEnum.systemDefault.index]!;
|
return supportedLanguages[_AppLanguageEnum.systemDefault.index]!;
|
||||||
|
|
|
@ -75,14 +75,14 @@ void _initLog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _initPref() async {
|
Future<void> _initPref() async {
|
||||||
await Pref.init();
|
await Pref().init();
|
||||||
if (Pref.inst().getLastVersion() == null) {
|
if (Pref().getLastVersion() == null) {
|
||||||
if (Pref.inst().getSetupProgress() == null) {
|
if (Pref().getSetupProgress() == null) {
|
||||||
// new install
|
// new install
|
||||||
await Pref.inst().setLastVersion(k.version);
|
await Pref().setLastVersion(k.version);
|
||||||
} else {
|
} else {
|
||||||
// v6 is the last version without saving the version number in pref
|
// v6 is the last version without saving the version number in pref
|
||||||
await Pref.inst().setLastVersion(6);
|
await Pref().setLastVersion(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ class MetadataTask {
|
||||||
final op = UpdateMissingMetadata(fileRepo);
|
final op = UpdateMissingMetadata(fileRepo);
|
||||||
await for (final _ in op(account,
|
await for (final _ in op(account,
|
||||||
File(path: "${api_util.getWebdavRootUrlRelative(account)}/$r"))) {
|
File(path: "${api_util.getWebdavRootUrlRelative(account)}/$r"))) {
|
||||||
if (!Pref.inst().isEnableExifOr()) {
|
if (!Pref().isEnableExifOr()) {
|
||||||
_log.info("[call] EXIF disabled, task ending immaturely");
|
_log.info("[call] EXIF disabled, task ending immaturely");
|
||||||
op.stop();
|
op.stop();
|
||||||
return;
|
return;
|
||||||
|
@ -76,7 +76,7 @@ class MetadataTaskManager {
|
||||||
|
|
||||||
void _handleStream() async {
|
void _handleStream() async {
|
||||||
await for (final task in _streamController.stream) {
|
await for (final task in _streamController.stream) {
|
||||||
if (Pref.inst().isEnableExifOr()) {
|
if (Pref().isEnableExifOr()) {
|
||||||
_log.info("[_doTask] Executing task: $task");
|
_log.info("[_doTask] Executing task: $task");
|
||||||
await task();
|
await task();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,7 +9,11 @@ import 'package:nc_photos/use_case/compat/v32.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class Pref {
|
class Pref {
|
||||||
static Future<void> init() async {
|
factory Pref() => _inst;
|
||||||
|
|
||||||
|
Pref._();
|
||||||
|
|
||||||
|
Future<void> init() async {
|
||||||
if (await CompatV32.isPrefNeedMigration()) {
|
if (await CompatV32.isPrefNeedMigration()) {
|
||||||
await CompatV32.migratePref();
|
await CompatV32.migratePref();
|
||||||
}
|
}
|
||||||
|
@ -18,8 +22,6 @@ class Pref {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
factory Pref.inst() => _inst;
|
|
||||||
|
|
||||||
List<PrefAccount>? getAccounts2() {
|
List<PrefAccount>? getAccounts2() {
|
||||||
final jsonObjs = _pref.getStringList(_toKey(PrefKey.accounts2));
|
final jsonObjs = _pref.getStringList(_toKey(PrefKey.accounts2));
|
||||||
return jsonObjs?.map((e) => PrefAccount.fromJson(jsonDecode(e))).toList();
|
return jsonObjs?.map((e) => PrefAccount.fromJson(jsonDecode(e))).toList();
|
||||||
|
@ -138,8 +140,6 @@ class Pref {
|
||||||
Future<bool> setLabEnableSharedAlbum(bool value) =>
|
Future<bool> setLabEnableSharedAlbum(bool value) =>
|
||||||
_setBool(PrefKey.labEnableSharedAlbum, value);
|
_setBool(PrefKey.labEnableSharedAlbum, value);
|
||||||
|
|
||||||
Pref._();
|
|
||||||
|
|
||||||
Future<bool> _setBool(PrefKey key, bool value) async {
|
Future<bool> _setBool(PrefKey key, bool value) async {
|
||||||
return _onPostSet(await _pref.setBool(_toKey(key), value), key, value);
|
return _onPostSet(await _pref.setBool(_toKey(key), value), key, value);
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ class Pref {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static final _inst = Pref._();
|
static late final _inst = Pref._();
|
||||||
late SharedPreferences _pref;
|
late SharedPreferences _pref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,16 +277,14 @@ enum PrefKey {
|
||||||
extension PrefExtension on Pref {
|
extension PrefExtension on Pref {
|
||||||
Account? getCurrentAccount() {
|
Account? getCurrentAccount() {
|
||||||
try {
|
try {
|
||||||
return Pref.inst()
|
return Pref().getAccounts2()![Pref().getCurrentAccountIndex()!].account;
|
||||||
.getAccounts2()![Pref.inst().getCurrentAccountIndex()!]
|
|
||||||
.account;
|
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AccountSettings getAccountSettings(Account account) {
|
AccountSettings getAccountSettings(Account account) {
|
||||||
return Pref.inst()
|
return Pref()
|
||||||
.getAccounts2()!
|
.getAccounts2()!
|
||||||
.firstWhere((element) => element.account == account)
|
.firstWhere((element) => element.account == account)
|
||||||
.settings;
|
.settings;
|
||||||
|
|
|
@ -97,7 +97,7 @@ class AppTheme extends StatelessWidget {
|
||||||
static ThemeData _buildDarkThemeData(BuildContext context, ThemeData theme) {
|
static ThemeData _buildDarkThemeData(BuildContext context, ThemeData theme) {
|
||||||
final Color background;
|
final Color background;
|
||||||
final Color popup;
|
final Color popup;
|
||||||
if (Pref.inst().isUseBlackInDarkThemeOr(false)) {
|
if (Pref().isUseBlackInDarkThemeOr(false)) {
|
||||||
background = Colors.black;
|
background = Colors.black;
|
||||||
popup = Colors.grey[900]!;
|
popup = Colors.grey[900]!;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,7 +29,7 @@ class _AccountPickerDialogState extends State<AccountPickerDialog> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_accounts = Pref.inst().getAccounts2Or([]);
|
_accounts = Pref().getAccounts2Or([]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -102,7 +102,7 @@ class _AccountPickerDialogState extends State<AccountPickerDialog> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onItemPressed(PrefAccount account) {
|
void _onItemPressed(PrefAccount account) {
|
||||||
Pref.inst().setCurrentAccountIndex(_accounts.indexOf(account));
|
Pref().setCurrentAccountIndex(_accounts.indexOf(account));
|
||||||
Navigator.of(context).pushNamedAndRemoveUntil(Home.routeName, (_) => false,
|
Navigator.of(context).pushNamedAndRemoveUntil(Home.routeName, (_) => false,
|
||||||
arguments: HomeArguments(account.account));
|
arguments: HomeArguments(account.account));
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ class _AccountPickerDialogState extends State<AccountPickerDialog> {
|
||||||
try {
|
try {
|
||||||
_removeAccount(account);
|
_removeAccount(account);
|
||||||
setState(() {
|
setState(() {
|
||||||
_accounts = Pref.inst().getAccounts2()!;
|
_accounts = Pref().getAccounts2()!;
|
||||||
});
|
});
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(
|
content: Text(
|
||||||
|
@ -135,9 +135,9 @@ class _AccountPickerDialogState extends State<AccountPickerDialog> {
|
||||||
|
|
||||||
void _removeAccount(PrefAccount account) {
|
void _removeAccount(PrefAccount account) {
|
||||||
_log.info("[_removeAccount] Remove account: ${account.account}");
|
_log.info("[_removeAccount] Remove account: ${account.account}");
|
||||||
final currentAccounts = Pref.inst().getAccounts2()!;
|
final currentAccounts = Pref().getAccounts2()!;
|
||||||
final currentAccount =
|
final currentAccount =
|
||||||
currentAccounts[Pref.inst().getCurrentAccountIndex()!];
|
currentAccounts[Pref().getCurrentAccountIndex()!];
|
||||||
final newAccounts = currentAccounts
|
final newAccounts = currentAccounts
|
||||||
.where((element) => element.account != account.account)
|
.where((element) => element.account != account.account)
|
||||||
.toList();
|
.toList();
|
||||||
|
@ -145,7 +145,7 @@ class _AccountPickerDialogState extends State<AccountPickerDialog> {
|
||||||
if (newAccountIndex == -1) {
|
if (newAccountIndex == -1) {
|
||||||
throw StateError("Active account not found in resulting account list");
|
throw StateError("Active account not found in resulting account list");
|
||||||
}
|
}
|
||||||
Pref.inst()
|
Pref()
|
||||||
..setAccounts2(newAccounts)
|
..setAccounts2(newAccounts)
|
||||||
..setCurrentAccountIndex(newAccountIndex);
|
..setCurrentAccountIndex(newAccountIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
||||||
_album!,
|
_album!,
|
||||||
actions: [
|
actions: [
|
||||||
if (_album!.albumFile!.isOwned(widget.account.username) &&
|
if (_album!.albumFile!.isOwned(widget.account.username) &&
|
||||||
Pref.inst().isLabEnableSharedAlbumOr(false))
|
Pref().isLabEnableSharedAlbumOr(false))
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () => _onSharePressed(context),
|
onPressed: () => _onSharePressed(context),
|
||||||
icon: const Icon(Icons.share),
|
icon: const Icon(Icons.share),
|
||||||
|
@ -250,7 +250,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
||||||
],
|
],
|
||||||
menuItemBuilder: (_) => [
|
menuItemBuilder: (_) => [
|
||||||
if (_album!.albumFile!.isOwned(widget.account.username) &&
|
if (_album!.albumFile!.isOwned(widget.account.username) &&
|
||||||
Pref.inst().isLabEnableSharedAlbumOr(false))
|
Pref().isLabEnableSharedAlbumOr(false))
|
||||||
PopupMenuItem(
|
PopupMenuItem(
|
||||||
value: _menuValueFixShares,
|
value: _menuValueFixShares,
|
||||||
child: Text(L10n.global().fixSharesTooltip),
|
child: Text(L10n.global().fixSharesTooltip),
|
||||||
|
@ -642,7 +642,7 @@ class _AlbumBrowserState extends State<AlbumBrowser>
|
||||||
height: k.photoThumbSize,
|
height: k.photoThumbSize,
|
||||||
);
|
);
|
||||||
if ((_editAlbum ?? _album)?.sortProvider is AlbumTimeSortProvider &&
|
if ((_editAlbum ?? _album)?.sortProvider is AlbumTimeSortProvider &&
|
||||||
Pref.inst().isAlbumBrowserShowDateOr()) {
|
Pref().isAlbumBrowserShowDateOr()) {
|
||||||
final date = dateHelper.onFile(item.file);
|
final date = dateHelper.onFile(item.file);
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
yield _DateListItem(date: date);
|
yield _DateListItem(date: date);
|
||||||
|
|
|
@ -26,7 +26,7 @@ mixin AlbumBrowserMixin<T extends StatefulWidget>
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_thumbZoomLevel = Pref.inst().getAlbumBrowserZoomLevelOr(0);
|
_thumbZoomLevel = Pref().getAlbumBrowserZoomLevelOr(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
|
@ -72,7 +72,7 @@ mixin AlbumBrowserMixin<T extends StatefulWidget>
|
||||||
setState(() {
|
setState(() {
|
||||||
_thumbZoomLevel = value.round();
|
_thumbZoomLevel = value.round();
|
||||||
});
|
});
|
||||||
Pref.inst().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
Pref().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
if (album.albumFile?.path.startsWith(
|
if (album.albumFile?.path.startsWith(
|
||||||
|
|
|
@ -62,7 +62,7 @@ class _ArchiveBrowserState extends State<ArchiveBrowser>
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_initBloc();
|
_initBloc();
|
||||||
_thumbZoomLevel = Pref.inst().getAlbumBrowserZoomLevelOr(0);
|
_thumbZoomLevel = Pref().getAlbumBrowserZoomLevelOr(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -187,7 +187,7 @@ class _ArchiveBrowserState extends State<ArchiveBrowser>
|
||||||
setState(() {
|
setState(() {
|
||||||
_thumbZoomLevel = value.round();
|
_thumbZoomLevel = value.round();
|
||||||
});
|
});
|
||||||
Pref.inst().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
Pref().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -549,7 +549,7 @@ class _DynamicAlbumBrowserState extends State<DynamicAlbumBrowser>
|
||||||
height: k.photoThumbSize,
|
height: k.photoThumbSize,
|
||||||
);
|
);
|
||||||
if ((_editAlbum ?? _album)?.sortProvider is AlbumTimeSortProvider &&
|
if ((_editAlbum ?? _album)?.sortProvider is AlbumTimeSortProvider &&
|
||||||
Pref.inst().isAlbumBrowserShowDateOr()) {
|
Pref().isAlbumBrowserShowDateOr()) {
|
||||||
final date = dateHelper.onFile(item.file);
|
final date = dateHelper.onFile(item.file);
|
||||||
if (date != null) {
|
if (date != null) {
|
||||||
yield _DateListItem(date: date);
|
yield _DateListItem(date: date);
|
||||||
|
|
|
@ -47,10 +47,10 @@ class _HomeState extends State<Home> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (Pref.inst().isLabEnableSharedAlbumOr(false)) {
|
if (Pref().isLabEnableSharedAlbumOr(false)) {
|
||||||
_importPotentialSharedAlbum().then((value) {
|
_importPotentialSharedAlbum().then((value) {
|
||||||
if (value.isNotEmpty) {
|
if (value.isNotEmpty) {
|
||||||
Pref.inst().setNewSharedAlbum(true);
|
Pref().setNewSharedAlbum(true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ class _HomeState extends State<Home> {
|
||||||
final albumRepo = AlbumRepo(AlbumRemoteDataSource());
|
final albumRepo = AlbumRepo(AlbumRemoteDataSource());
|
||||||
try {
|
try {
|
||||||
return await ImportPotentialSharedAlbum(fileRepo, albumRepo)(
|
return await ImportPotentialSharedAlbum(fileRepo, albumRepo)(
|
||||||
widget.account, Pref.inst().getAccountSettings(widget.account));
|
widget.account, Pref().getAccountSettings(widget.account));
|
||||||
} catch (e, stacktrace) {
|
} catch (e, stacktrace) {
|
||||||
_log.shout(
|
_log.shout(
|
||||||
"[_importPotentialSharedAlbum] Failed while ImportPotentialSharedAlbum",
|
"[_importPotentialSharedAlbum] Failed while ImportPotentialSharedAlbum",
|
||||||
|
|
|
@ -241,7 +241,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
||||||
return _ButtonListItem(
|
return _ButtonListItem(
|
||||||
icon: Icons.share_outlined,
|
icon: Icons.share_outlined,
|
||||||
label: L10n.global().collectionSharingLabel,
|
label: L10n.global().collectionSharingLabel,
|
||||||
isShowIndicator: Pref.inst().hasNewSharedAlbumOr(false),
|
isShowIndicator: Pref().hasNewSharedAlbumOr(false),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (!isSelectionMode) {
|
if (!isSelectionMode) {
|
||||||
Navigator.of(context).pushNamed(SharingBrowser.routeName,
|
Navigator.of(context).pushNamed(SharingBrowser.routeName,
|
||||||
|
@ -362,7 +362,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onSortSelected(_Sort sort) async {
|
void _onSortSelected(_Sort sort) async {
|
||||||
await Pref.inst().setHomeAlbumsSort(sort.index);
|
await Pref().setHomeAlbumsSort(sort.index);
|
||||||
setState(() {
|
setState(() {
|
||||||
_transformItems(_bloc.state.items);
|
_transformItems(_bloc.state.items);
|
||||||
});
|
});
|
||||||
|
@ -443,7 +443,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
||||||
}
|
}
|
||||||
}).map((e) => e.item2);
|
}).map((e) => e.item2);
|
||||||
itemStreamListItems = [
|
itemStreamListItems = [
|
||||||
if (Pref.inst()
|
if (Pref()
|
||||||
.getAccountSettings(widget.account)
|
.getAccountSettings(widget.account)
|
||||||
.isEnableFaceRecognitionApp ==
|
.isEnableFaceRecognitionApp ==
|
||||||
true)
|
true)
|
||||||
|
@ -616,7 +616,7 @@ enum _Sort {
|
||||||
|
|
||||||
_Sort _getSortFromPref() {
|
_Sort _getSortFromPref() {
|
||||||
try {
|
try {
|
||||||
return _Sort.values[Pref.inst().getHomeAlbumsSort()!];
|
return _Sort.values[Pref().getHomeAlbumsSort()!];
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// default
|
// default
|
||||||
return _Sort.dateDescending;
|
return _Sort.dateDescending;
|
||||||
|
|
|
@ -79,7 +79,7 @@ class HomeSliverAppBar extends StatelessWidget {
|
||||||
automaticallyImplyLeading: false,
|
automaticallyImplyLeading: false,
|
||||||
actions: (actions ?? []) +
|
actions: (actions ?? []) +
|
||||||
[
|
[
|
||||||
if (!Pref.inst().isFollowSystemThemeOr(false))
|
if (!Pref().isFollowSystemThemeOr(false))
|
||||||
Switch(
|
Switch(
|
||||||
value: Theme.of(context).brightness == Brightness.dark,
|
value: Theme.of(context).brightness == Brightness.dark,
|
||||||
onChanged: _onDarkModeChanged,
|
onChanged: _onDarkModeChanged,
|
||||||
|
@ -125,7 +125,7 @@ class HomeSliverAppBar extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onDarkModeChanged(bool value) {
|
void _onDarkModeChanged(bool value) {
|
||||||
Pref.inst().setDarkTheme(value).then((_) {
|
Pref().setDarkTheme(value).then((_) {
|
||||||
KiwiContainer().resolve<EventBus>().fire(ThemeChangedEvent());
|
KiwiContainer().resolve<EventBus>().fire(ThemeChangedEvent());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ class _HomePhotosState extends State<HomePhotos>
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_thumbZoomLevel = Pref.inst().getHomePhotosZoomLevelOr(0);
|
_thumbZoomLevel = Pref().getHomePhotosZoomLevelOr(0);
|
||||||
_initBloc();
|
_initBloc();
|
||||||
_metadataTaskStateChangedListener.begin();
|
_metadataTaskStateChangedListener.begin();
|
||||||
_prefUpdatedListener.begin();
|
_prefUpdatedListener.begin();
|
||||||
|
@ -241,7 +241,7 @@ class _HomePhotosState extends State<HomePhotos>
|
||||||
setState(() {
|
setState(() {
|
||||||
_setThumbZoomLevel(value.round());
|
_setThumbZoomLevel(value.round());
|
||||||
});
|
});
|
||||||
Pref.inst().setHomePhotosZoomLevel(_thumbZoomLevel);
|
Pref().setHomePhotosZoomLevel(_thumbZoomLevel);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -546,7 +546,7 @@ class _HomePhotosState extends State<HomePhotos>
|
||||||
bool ignoreFired = false,
|
bool ignoreFired = false,
|
||||||
}) {
|
}) {
|
||||||
if (_bloc.state is ScanDirBlocSuccess &&
|
if (_bloc.state is ScanDirBlocSuccess &&
|
||||||
Pref.inst().isEnableExifOr() &&
|
Pref().isEnableExifOr() &&
|
||||||
(!_hasFiredMetadataTask.value || ignoreFired)) {
|
(!_hasFiredMetadataTask.value || ignoreFired)) {
|
||||||
MetadataTaskManager().addTask(MetadataTask(widget.account));
|
MetadataTaskManager().addTask(MetadataTask(widget.account));
|
||||||
_metadataTaskProcessTotalCount = _backingFiles
|
_metadataTaskProcessTotalCount = _backingFiles
|
||||||
|
|
|
@ -61,11 +61,11 @@ class _MyAppState extends State<MyApp> implements SnackBarHandler {
|
||||||
@override
|
@override
|
||||||
build(BuildContext context) {
|
build(BuildContext context) {
|
||||||
final ThemeMode themeMode;
|
final ThemeMode themeMode;
|
||||||
if (Pref.inst().isFollowSystemThemeOr(false)) {
|
if (Pref().isFollowSystemThemeOr(false)) {
|
||||||
themeMode = ThemeMode.system;
|
themeMode = ThemeMode.system;
|
||||||
} else {
|
} else {
|
||||||
themeMode =
|
themeMode =
|
||||||
Pref.inst().isDarkThemeOr(false) ? ThemeMode.dark : ThemeMode.light;
|
Pref().isDarkThemeOr(false) ? ThemeMode.dark : ThemeMode.light;
|
||||||
}
|
}
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
onGenerateTitle: (context) => AppLocalizations.of(context)!.appTitle,
|
onGenerateTitle: (context) => AppLocalizations.of(context)!.appTitle,
|
||||||
|
|
|
@ -84,7 +84,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_initBloc();
|
_initBloc();
|
||||||
_thumbZoomLevel = Pref.inst().getAlbumBrowserZoomLevelOr(0);
|
_thumbZoomLevel = Pref().getAlbumBrowserZoomLevelOr(0);
|
||||||
|
|
||||||
_filePropertyUpdatedListener.begin();
|
_filePropertyUpdatedListener.begin();
|
||||||
}
|
}
|
||||||
|
@ -206,7 +206,7 @@ class _PersonBrowserState extends State<PersonBrowser>
|
||||||
setState(() {
|
setState(() {
|
||||||
_thumbZoomLevel = value.round();
|
_thumbZoomLevel = value.round();
|
||||||
});
|
});
|
||||||
Pref.inst().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
Pref().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -57,7 +57,7 @@ class _SettingsState extends State<Settings> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_isEnableExif = Pref.inst().isEnableExifOr();
|
_isEnableExif = Pref().isEnableExifOr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -220,7 +220,7 @@ class _SettingsState extends State<Settings> {
|
||||||
|
|
||||||
void _onLanguageTap(BuildContext context) {
|
void _onLanguageTap(BuildContext context) {
|
||||||
final selected =
|
final selected =
|
||||||
Pref.inst().getLanguageOr(language_util.supportedLanguages[0]!.langId);
|
Pref().getLanguageOr(language_util.supportedLanguages[0]!.langId);
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => FancyOptionPicker(
|
builder: (context) => FancyOptionPicker(
|
||||||
|
@ -240,7 +240,7 @@ class _SettingsState extends State<Settings> {
|
||||||
),
|
),
|
||||||
).then((value) {
|
).then((value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Pref.inst().setLanguage(value).then((_) {
|
Pref().setLanguage(value).then((_) {
|
||||||
KiwiContainer().resolve<EventBus>().fire(LanguageChangedEvent());
|
KiwiContainer().resolve<EventBus>().fire(LanguageChangedEvent());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -345,7 +345,7 @@ class _SettingsState extends State<Settings> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isEnableExif = value;
|
_isEnableExif = value;
|
||||||
});
|
});
|
||||||
if (!await Pref.inst().setEnableExif(value)) {
|
if (!await Pref().setEnableExif(value)) {
|
||||||
_log.severe("[_setExifSupport] Failed writing pref");
|
_log.severe("[_setExifSupport] Failed writing pref");
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(L10n.global().writePreferenceFailureNotification),
|
content: Text(L10n.global().writePreferenceFailureNotification),
|
||||||
|
@ -406,7 +406,7 @@ class _AccountSettingsState extends State<AccountSettingsWidget> {
|
||||||
super.initState();
|
super.initState();
|
||||||
_account = widget.account;
|
_account = widget.account;
|
||||||
|
|
||||||
final settings = Pref.inst().getAccountSettings(_account);
|
final settings = Pref().getAccountSettings(_account);
|
||||||
_isEnableFaceRecognitionApp = settings.isEnableFaceRecognitionApp;
|
_isEnableFaceRecognitionApp = settings.isEnableFaceRecognitionApp;
|
||||||
_shareFolder = settings.shareFolder;
|
_shareFolder = settings.shareFolder;
|
||||||
}
|
}
|
||||||
|
@ -489,7 +489,7 @@ class _AccountSettingsState extends State<AccountSettingsWidget> {
|
||||||
_log.fine("[_onIncludedFoldersPressed] No changes");
|
_log.fine("[_onIncludedFoldersPressed] No changes");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final accounts = Pref.inst().getAccounts2()!;
|
final accounts = Pref().getAccounts2()!;
|
||||||
if (accounts.any((element) => element.account == result)) {
|
if (accounts.any((element) => element.account == result)) {
|
||||||
// conflict with another account. This normally won't happen because
|
// conflict with another account. This normally won't happen because
|
||||||
// the app passwords are unique to each entry, but just in case
|
// the app passwords are unique to each entry, but just in case
|
||||||
|
@ -515,7 +515,7 @@ class _AccountSettingsState extends State<AccountSettingsWidget> {
|
||||||
account: result,
|
account: result,
|
||||||
);
|
);
|
||||||
accounts[index] = newAccount;
|
accounts[index] = newAccount;
|
||||||
if (!await Pref.inst().setAccounts2(accounts)) {
|
if (!await Pref().setAccounts2(accounts)) {
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(L10n.global().writePreferenceFailureNotification),
|
content: Text(L10n.global().writePreferenceFailureNotification),
|
||||||
duration: k.snackBarDurationNormal,
|
duration: k.snackBarDurationNormal,
|
||||||
|
@ -605,7 +605,7 @@ class _AccountSettingsState extends State<AccountSettingsWidget> {
|
||||||
String? shareFolder,
|
String? shareFolder,
|
||||||
}) {
|
}) {
|
||||||
try {
|
try {
|
||||||
final accounts = Pref.inst().getAccounts2()!;
|
final accounts = Pref().getAccounts2()!;
|
||||||
final index = _findAccount(account, accounts);
|
final index = _findAccount(account, accounts);
|
||||||
accounts[index] = accounts[index].copyWith(
|
accounts[index] = accounts[index].copyWith(
|
||||||
settings: accounts[index].settings.copyWith(
|
settings: accounts[index].settings.copyWith(
|
||||||
|
@ -613,7 +613,7 @@ class _AccountSettingsState extends State<AccountSettingsWidget> {
|
||||||
shareFolder: shareFolder,
|
shareFolder: shareFolder,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return Pref.inst().setAccounts2(accounts);
|
return Pref().setAccounts2(accounts);
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
_log.severe(
|
_log.severe(
|
||||||
"[_modifyAccountSettings] Failed while setting account settings",
|
"[_modifyAccountSettings] Failed while setting account settings",
|
||||||
|
@ -625,7 +625,7 @@ class _AccountSettingsState extends State<AccountSettingsWidget> {
|
||||||
|
|
||||||
/// Return the index of [account] in [Pref.getAccounts2]
|
/// Return the index of [account] in [Pref.getAccounts2]
|
||||||
static int _findAccount(Account account, [List<PrefAccount>? accounts]) {
|
static int _findAccount(Account account, [List<PrefAccount>? accounts]) {
|
||||||
final from = accounts ?? Pref.inst().getAccounts2Or([]);
|
final from = accounts ?? Pref().getAccounts2Or([]);
|
||||||
return from.indexWhere((element) => element.account == account);
|
return from.indexWhere((element) => element.account == account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -711,8 +711,8 @@ class _ViewerSettingsState extends State<_ViewerSettings> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_screenBrightness = Pref.inst().getViewerScreenBrightnessOr(-1);
|
_screenBrightness = Pref().getViewerScreenBrightnessOr(-1);
|
||||||
_isForceRotation = Pref.inst().isViewerForceRotationOr(false);
|
_isForceRotation = Pref().isViewerForceRotationOr(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -833,7 +833,7 @@ class _ViewerSettingsState extends State<_ViewerSettings> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_screenBrightness = value;
|
_screenBrightness = value;
|
||||||
});
|
});
|
||||||
if (!await Pref.inst().setViewerScreenBrightness(value)) {
|
if (!await Pref().setViewerScreenBrightness(value)) {
|
||||||
_log.severe("[_setScreenBrightness] Failed writing pref");
|
_log.severe("[_setScreenBrightness] Failed writing pref");
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(L10n.global().writePreferenceFailureNotification),
|
content: Text(L10n.global().writePreferenceFailureNotification),
|
||||||
|
@ -850,7 +850,7 @@ class _ViewerSettingsState extends State<_ViewerSettings> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isForceRotation = value;
|
_isForceRotation = value;
|
||||||
});
|
});
|
||||||
if (!await Pref.inst().setViewerForceRotation(value)) {
|
if (!await Pref().setViewerForceRotation(value)) {
|
||||||
_log.severe("[_setForceRotation] Failed writing pref");
|
_log.severe("[_setForceRotation] Failed writing pref");
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(L10n.global().writePreferenceFailureNotification),
|
content: Text(L10n.global().writePreferenceFailureNotification),
|
||||||
|
@ -877,7 +877,7 @@ class _AlbumSettingsState extends State<_AlbumSettings> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_isBrowserShowDate = Pref.inst().isAlbumBrowserShowDateOr();
|
_isBrowserShowDate = Pref().isAlbumBrowserShowDateOr();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -920,7 +920,7 @@ class _AlbumSettingsState extends State<_AlbumSettings> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isBrowserShowDate = value;
|
_isBrowserShowDate = value;
|
||||||
});
|
});
|
||||||
if (!await Pref.inst().setAlbumBrowserShowDate(value)) {
|
if (!await Pref().setAlbumBrowserShowDate(value)) {
|
||||||
_log.severe("[_onBrowserShowDateChanged] Failed writing pref");
|
_log.severe("[_onBrowserShowDateChanged] Failed writing pref");
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(L10n.global().writePreferenceFailureNotification),
|
content: Text(L10n.global().writePreferenceFailureNotification),
|
||||||
|
@ -946,8 +946,8 @@ class _ThemeSettingsState extends State<_ThemeSettings> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_isFollowSystemTheme = Pref.inst().isFollowSystemThemeOr(false);
|
_isFollowSystemTheme = Pref().isFollowSystemThemeOr(false);
|
||||||
_isUseBlackInDarkTheme = Pref.inst().isUseBlackInDarkThemeOr(false);
|
_isUseBlackInDarkTheme = Pref().isUseBlackInDarkThemeOr(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -999,7 +999,7 @@ class _ThemeSettingsState extends State<_ThemeSettings> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isFollowSystemTheme = value;
|
_isFollowSystemTheme = value;
|
||||||
});
|
});
|
||||||
if (await Pref.inst().setFollowSystemTheme(value)) {
|
if (await Pref().setFollowSystemTheme(value)) {
|
||||||
KiwiContainer().resolve<EventBus>().fire(ThemeChangedEvent());
|
KiwiContainer().resolve<EventBus>().fire(ThemeChangedEvent());
|
||||||
} else {
|
} else {
|
||||||
_log.severe("[_onFollowSystemThemeChanged] Failed writing pref");
|
_log.severe("[_onFollowSystemThemeChanged] Failed writing pref");
|
||||||
|
@ -1018,7 +1018,7 @@ class _ThemeSettingsState extends State<_ThemeSettings> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isUseBlackInDarkTheme = value;
|
_isUseBlackInDarkTheme = value;
|
||||||
});
|
});
|
||||||
if (await Pref.inst().setUseBlackInDarkTheme(value)) {
|
if (await Pref().setUseBlackInDarkTheme(value)) {
|
||||||
if (Theme.of(context).brightness == Brightness.dark) {
|
if (Theme.of(context).brightness == Brightness.dark) {
|
||||||
KiwiContainer().resolve<EventBus>().fire(ThemeChangedEvent());
|
KiwiContainer().resolve<EventBus>().fire(ThemeChangedEvent());
|
||||||
}
|
}
|
||||||
|
@ -1049,7 +1049,7 @@ class _ExperimentalSettingsState extends State<_ExperimentalSettings> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_isEnableSharedAlbum = Pref.inst().isLabEnableSharedAlbumOr(false);
|
_isEnableSharedAlbum = Pref().isLabEnableSharedAlbumOr(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -1092,7 +1092,7 @@ class _ExperimentalSettingsState extends State<_ExperimentalSettings> {
|
||||||
setState(() {
|
setState(() {
|
||||||
_isEnableSharedAlbum = value;
|
_isEnableSharedAlbum = value;
|
||||||
});
|
});
|
||||||
if (!await Pref.inst().setLabEnableSharedAlbum(value)) {
|
if (!await Pref().setLabEnableSharedAlbum(value)) {
|
||||||
_log.severe("[_onEnableSharedAlbumChanged] Failed writing pref");
|
_log.severe("[_onEnableSharedAlbumChanged] Failed writing pref");
|
||||||
SnackBarManager().showSnackBar(SnackBar(
|
SnackBarManager().showSnackBar(SnackBar(
|
||||||
content: Text(L10n.global().writePreferenceFailureNotification),
|
content: Text(L10n.global().writePreferenceFailureNotification),
|
||||||
|
|
|
@ -8,8 +8,7 @@ import 'package:nc_photos/widget/home.dart';
|
||||||
import 'package:nc_photos/widget/sign_in.dart';
|
import 'package:nc_photos/widget/sign_in.dart';
|
||||||
import 'package:page_view_indicators/circle_page_indicator.dart';
|
import 'package:page_view_indicators/circle_page_indicator.dart';
|
||||||
|
|
||||||
bool isNeedSetup() =>
|
bool isNeedSetup() => Pref().getSetupProgressOr() & _PageId.all != _PageId.all;
|
||||||
Pref.inst().getSetupProgressOr() & _PageId.all != _PageId.all;
|
|
||||||
|
|
||||||
class Setup extends StatefulWidget {
|
class Setup extends StatefulWidget {
|
||||||
static const routeName = "/setup";
|
static const routeName = "/setup";
|
||||||
|
@ -102,9 +101,9 @@ class _SetupState extends State<Setup> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onDonePressed() {
|
void _onDonePressed() {
|
||||||
Pref.inst().setSetupProgress(_PageId.all);
|
Pref().setSetupProgress(_PageId.all);
|
||||||
|
|
||||||
final account = Pref.inst().getCurrentAccount();
|
final account = Pref().getCurrentAccount();
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
Navigator.pushReplacementNamed(context, SignIn.routeName);
|
Navigator.pushReplacementNamed(context, SignIn.routeName);
|
||||||
} else {
|
} else {
|
||||||
|
@ -114,12 +113,12 @@ class _SetupState extends State<Setup> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onNextPressed(int pageId) {
|
void _onNextPressed(int pageId) {
|
||||||
Pref.inst().setSetupProgress(Pref.inst().getSetupProgressOr() | pageId);
|
Pref().setSetupProgress(Pref().getSetupProgressOr() | pageId);
|
||||||
_pageController.nextPage(
|
_pageController.nextPage(
|
||||||
duration: k.animationDurationNormal, curve: Curves.easeInOut);
|
duration: k.animationDurationNormal, curve: Curves.easeInOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
final _initialProgress = Pref.inst().getSetupProgressOr();
|
final _initialProgress = Pref().getSetupProgressOr();
|
||||||
final _pageController = PageController();
|
final _pageController = PageController();
|
||||||
final _currentPageNotifier = ValueNotifier<int>(0);
|
final _currentPageNotifier = ValueNotifier<int>(0);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +177,7 @@ class _ExifState extends State<_Exif> {
|
||||||
dispose() {
|
dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
// persist user's choice
|
// persist user's choice
|
||||||
Pref.inst().setEnableExif(_isEnableExif);
|
Pref().setEnableExif(_isEnableExif);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onValueChanged(bool value) {
|
void _onValueChanged(bool value) {
|
||||||
|
@ -187,7 +186,7 @@ class _ExifState extends State<_Exif> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _isEnableExif = Pref.inst().isEnableExifOr();
|
bool _isEnableExif = Pref().isEnableExifOr();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _HiddenPrefDirNotice extends StatefulWidget implements _Page {
|
class _HiddenPrefDirNotice extends StatefulWidget implements _Page {
|
||||||
|
|
|
@ -61,11 +61,11 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
@override
|
@override
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
if (Pref.inst().isLabEnableSharedAlbumOr(false)) {
|
if (Pref().isLabEnableSharedAlbumOr(false)) {
|
||||||
_importPotentialSharedAlbum().whenComplete(() {
|
_importPotentialSharedAlbum().whenComplete(() {
|
||||||
_initBloc();
|
_initBloc();
|
||||||
});
|
});
|
||||||
Pref.inst().setNewSharedAlbum(false);
|
Pref().setNewSharedAlbum(false);
|
||||||
} else {
|
} else {
|
||||||
_initBloc();
|
_initBloc();
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
||||||
final albumRepo = AlbumRepo(AlbumRemoteDataSource());
|
final albumRepo = AlbumRepo(AlbumRemoteDataSource());
|
||||||
try {
|
try {
|
||||||
return await ImportPotentialSharedAlbum(fileRepo, albumRepo)(
|
return await ImportPotentialSharedAlbum(fileRepo, albumRepo)(
|
||||||
widget.account, Pref.inst().getAccountSettings(widget.account));
|
widget.account, Pref().getAccountSettings(widget.account));
|
||||||
} catch (e, stackTrace) {
|
} catch (e, stackTrace) {
|
||||||
_log.shout(
|
_log.shout(
|
||||||
"[_importPotentialSharedAlbum] Failed while ImportPotentialSharedAlbum",
|
"[_importPotentialSharedAlbum] Failed while ImportPotentialSharedAlbum",
|
||||||
|
|
|
@ -228,11 +228,11 @@ class _SignInState extends State<SignIn> {
|
||||||
// we've got a good account
|
// we've got a good account
|
||||||
final pa = PrefAccount(result);
|
final pa = PrefAccount(result);
|
||||||
// only signing in with app password would trigger distinct
|
// only signing in with app password would trigger distinct
|
||||||
final accounts = (Pref.inst().getAccounts2Or([])..add(pa)).distinctIf(
|
final accounts = (Pref().getAccounts2Or([])..add(pa)).distinctIf(
|
||||||
(a, b) => a.account == b.account,
|
(a, b) => a.account == b.account,
|
||||||
(a) => a.account.hashCode,
|
(a) => a.account.hashCode,
|
||||||
);
|
);
|
||||||
Pref.inst()
|
Pref()
|
||||||
..setAccounts2(accounts)
|
..setAccounts2(accounts)
|
||||||
..setCurrentAccountIndex(
|
..setCurrentAccountIndex(
|
||||||
accounts.indexWhere((element) => element.account == result));
|
accounts.indexWhere((element) => element.account == result));
|
||||||
|
|
|
@ -74,7 +74,7 @@ class _SplashState extends State<Splash> {
|
||||||
|
|
||||||
void _initTimedExit() {
|
void _initTimedExit() {
|
||||||
Future.delayed(const Duration(seconds: 1)).then((_) {
|
Future.delayed(const Duration(seconds: 1)).then((_) {
|
||||||
final account = Pref.inst().getCurrentAccount();
|
final account = Pref().getCurrentAccount();
|
||||||
if (isNeedSetup()) {
|
if (isNeedSetup()) {
|
||||||
Navigator.pushReplacementNamed(context, Setup.routeName);
|
Navigator.pushReplacementNamed(context, Setup.routeName);
|
||||||
} else if (account == null) {
|
} else if (account == null) {
|
||||||
|
@ -87,13 +87,13 @@ class _SplashState extends State<Splash> {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _shouldUpgrade() {
|
bool _shouldUpgrade() {
|
||||||
final lastVersion = Pref.inst().getLastVersionOr(k.version);
|
final lastVersion = Pref().getLastVersionOr(k.version);
|
||||||
return lastVersion < k.version;
|
return lastVersion < k.version;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleUpgrade() async {
|
void _handleUpgrade() async {
|
||||||
try {
|
try {
|
||||||
final lastVersion = Pref.inst().getLastVersionOr(k.version);
|
final lastVersion = Pref().getLastVersionOr(k.version);
|
||||||
await _upgrade(lastVersion);
|
await _upgrade(lastVersion);
|
||||||
|
|
||||||
final change = _gatherChangelog(lastVersion);
|
final change = _gatherChangelog(lastVersion);
|
||||||
|
@ -118,7 +118,7 @@ class _SplashState extends State<Splash> {
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
_initTimedExit();
|
_initTimedExit();
|
||||||
Pref.inst().setLastVersion(k.version);
|
Pref().setLastVersion(k.version);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_initBloc();
|
_initBloc();
|
||||||
_thumbZoomLevel = Pref.inst().getAlbumBrowserZoomLevelOr(0);
|
_thumbZoomLevel = Pref().getAlbumBrowserZoomLevelOr(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -209,7 +209,7 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
||||||
setState(() {
|
setState(() {
|
||||||
_thumbZoomLevel = value.round();
|
_thumbZoomLevel = value.round();
|
||||||
});
|
});
|
||||||
Pref.inst().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
Pref().setAlbumBrowserZoomLevel(_thumbZoomLevel);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
PopupMenuButton<_AppBarMenuOption>(
|
PopupMenuButton<_AppBarMenuOption>(
|
||||||
|
|
|
@ -481,15 +481,15 @@ class _ViewerState extends State<Viewer>
|
||||||
final result = await showDialog<SlideshowConfig>(
|
final result = await showDialog<SlideshowConfig>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => SlideshowDialog(
|
builder: (_) => SlideshowDialog(
|
||||||
duration: Duration(seconds: Pref.inst().getSlideshowDurationOr(5)),
|
duration: Duration(seconds: Pref().getSlideshowDurationOr(5)),
|
||||||
isShuffle: Pref.inst().isSlideshowShuffleOr(false),
|
isShuffle: Pref().isSlideshowShuffleOr(false),
|
||||||
isRepeat: Pref.inst().isSlideshowRepeatOr(false),
|
isRepeat: Pref().isSlideshowRepeatOr(false),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pref.inst()
|
Pref()
|
||||||
..setSlideshowDuration(result.duration.inSeconds)
|
..setSlideshowDuration(result.duration.inSeconds)
|
||||||
..setSlideshowShuffle(result.isShuffle)
|
..setSlideshowShuffle(result.isShuffle)
|
||||||
..setSlideshowRepeat(result.isRepeat);
|
..setSlideshowRepeat(result.isRepeat);
|
||||||
|
|
|
@ -17,7 +17,7 @@ mixin ViewerControllersMixin<T extends StatefulWidget>
|
||||||
...super.initDisposables(),
|
...super.initDisposables(),
|
||||||
if (platform_k.isMobile) _ViewerBrightnessController(),
|
if (platform_k.isMobile) _ViewerBrightnessController(),
|
||||||
_ViewerSystemUiResetter(),
|
_ViewerSystemUiResetter(),
|
||||||
if (platform_k.isMobile && Pref.inst().isViewerForceRotationOr(false))
|
if (platform_k.isMobile && Pref().isViewerForceRotationOr(false))
|
||||||
_ViewerOrientationController(
|
_ViewerOrientationController(
|
||||||
onChanged: _onOrientationChanged,
|
onChanged: _onOrientationChanged,
|
||||||
),
|
),
|
||||||
|
@ -57,7 +57,7 @@ mixin ViewerControllersMixin<T extends StatefulWidget>
|
||||||
class _ViewerBrightnessController implements Disposable {
|
class _ViewerBrightnessController implements Disposable {
|
||||||
@override
|
@override
|
||||||
init(State state) {
|
init(State state) {
|
||||||
final brightness = Pref.inst().getViewerScreenBrightness();
|
final brightness = Pref().getViewerScreenBrightness();
|
||||||
if (brightness != null && brightness >= 0) {
|
if (brightness != null && brightness >= 0) {
|
||||||
ScreenBrightness.setScreenBrightness(brightness / 100.0);
|
ScreenBrightness.setScreenBrightness(brightness / 100.0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue