mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 05:52:40 +03:00
Persist navigation and sidebar visibility state
This commit is contained in:
parent
0b8bcf8c67
commit
574e63e147
@ -22,6 +22,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:material_symbols_icons/symbols.dart';
|
import 'package:material_symbols_icons/symbols.dart';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
import '../../core/state.dart';
|
import '../../core/state.dart';
|
||||||
import '../../management/models.dart';
|
import '../../management/models.dart';
|
||||||
@ -34,18 +35,23 @@ import 'keys.dart';
|
|||||||
import 'navigation.dart';
|
import 'navigation.dart';
|
||||||
|
|
||||||
final _navigationVisibilityProvider =
|
final _navigationVisibilityProvider =
|
||||||
StateNotifierProvider<_VisibilityNotifier, bool>(
|
StateNotifierProvider<_VisibilityNotifier, bool>((ref) =>
|
||||||
(ref) => _VisibilityNotifier());
|
_VisibilityNotifier('NAVIGATION_VISIBILITY', ref.watch(prefProvider)));
|
||||||
|
|
||||||
final _detailViewVisibilityProvider =
|
final _detailViewVisibilityProvider =
|
||||||
StateNotifierProvider<_VisibilityNotifier, bool>(
|
StateNotifierProvider<_VisibilityNotifier, bool>((ref) =>
|
||||||
(ref) => _VisibilityNotifier());
|
_VisibilityNotifier('DETAIL_VIEW_VISIBILITY', ref.watch(prefProvider)));
|
||||||
|
|
||||||
class _VisibilityNotifier extends StateNotifier<bool> {
|
class _VisibilityNotifier extends StateNotifier<bool> {
|
||||||
_VisibilityNotifier() : super(true);
|
final String _key;
|
||||||
|
final SharedPreferences _prefs;
|
||||||
|
_VisibilityNotifier(this._key, this._prefs)
|
||||||
|
: super(_prefs.getBool(_key) ?? true);
|
||||||
|
|
||||||
void toggleExpanded() {
|
void toggleExpanded() {
|
||||||
state = !state;
|
final newValue = !state;
|
||||||
|
state = newValue;
|
||||||
|
_prefs.setBool(_key, newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -693,8 +699,8 @@ class _AppPageState extends ConsumerState<AppPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
if (widget.actionButtonBuilder == null &&
|
if (widget.actionButtonBuilder == null &&
|
||||||
(widget.keyActionsBuilder != null && !hasManage ||
|
(widget.keyActionsBuilder != null &&
|
||||||
!showDetailView))
|
(!hasManage || !showDetailView)))
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(left: 4),
|
padding: const EdgeInsets.only(left: 4),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
|
Loading…
Reference in New Issue
Block a user