完善细类
This commit is contained in:
@@ -8,6 +8,41 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../../utils/http/poetry_api.dart';
|
||||
|
||||
class SecondaryButtonsManager {
|
||||
static const String _hideSecondaryButtonsKey = 'hide_secondary_buttons';
|
||||
|
||||
static SecondaryButtonsManager? _instance;
|
||||
bool _isHidden = false;
|
||||
final ValueNotifier<bool> _hiddenNotifier = ValueNotifier<bool>(false);
|
||||
|
||||
SecondaryButtonsManager._internal();
|
||||
|
||||
factory SecondaryButtonsManager() {
|
||||
_instance ??= SecondaryButtonsManager._internal();
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
Future<void> init() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
_isHidden = prefs.getBool(_hideSecondaryButtonsKey) ?? false;
|
||||
_hiddenNotifier.value = _isHidden;
|
||||
}
|
||||
|
||||
bool get isHidden => _isHidden;
|
||||
ValueNotifier<bool> get hiddenNotifier => _hiddenNotifier;
|
||||
|
||||
Future<void> setHidden(bool hidden) async {
|
||||
_isHidden = hidden;
|
||||
_hiddenNotifier.value = hidden;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool(_hideSecondaryButtonsKey, hidden);
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_hiddenNotifier.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
class AutoRefreshManager {
|
||||
static const String _autoRefreshKey = 'auto_refresh_enabled';
|
||||
static const Duration _refreshInterval = Duration(seconds: 5);
|
||||
|
||||
Reference in New Issue
Block a user