Fix windows some issues
Optimize overwrite handle Optimize access control page Optimize some details
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:fl_clash/common/common.dart';
|
||||
import 'package:fl_clash/enum/enum.dart';
|
||||
import 'package:fl_clash/models/models.dart';
|
||||
@@ -290,11 +292,41 @@ class BackBlock extends _$BackBlock with AutoDisposeNotifierMixin {
|
||||
|
||||
@riverpod
|
||||
class Loading extends _$Loading with AutoDisposeNotifierMixin {
|
||||
DateTime? _start;
|
||||
Timer? _timer;
|
||||
|
||||
@override
|
||||
bool build() {
|
||||
return globalState.appState.loading;
|
||||
}
|
||||
|
||||
void start() {
|
||||
_timer?.cancel();
|
||||
_timer = null;
|
||||
_start = DateTime.now();
|
||||
value = true;
|
||||
}
|
||||
|
||||
Future<void> stop() async {
|
||||
if (_start == null) {
|
||||
value = false;
|
||||
return;
|
||||
}
|
||||
final startedAt = _start!;
|
||||
final elapsed = DateTime.now().difference(_start!).inMilliseconds;
|
||||
const minDuration = 1000;
|
||||
if (elapsed >= minDuration) {
|
||||
value = false;
|
||||
return;
|
||||
}
|
||||
_timer = Timer(Duration(milliseconds: minDuration - elapsed), () {
|
||||
if (_start != startedAt) {
|
||||
return;
|
||||
}
|
||||
value = false;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
onUpdate(value) {
|
||||
globalState.appState = globalState.appState.copyWith(loading: value);
|
||||
@@ -407,16 +439,63 @@ class _CoreStatus extends _$CoreStatus with AutoDisposeNotifierMixin {
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class QueryMap extends _$QueryMap with AutoDisposeNotifierMixin {
|
||||
class Query extends _$Query with AutoDisposeNotifierMixin {
|
||||
late final QueryTag _tag;
|
||||
|
||||
@override
|
||||
Map<QueryTag, String> build() => globalState.appState.queryMap;
|
||||
String build(QueryTag tag) {
|
||||
_tag = tag;
|
||||
return globalState.appState.queryMap[tag] ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
onUpdate(value) {
|
||||
globalState.appState = globalState.appState.copyWith(queryMap: value);
|
||||
}
|
||||
|
||||
void updateQuery(QueryTag tag, String value) {
|
||||
this.value = Map.from(globalState.appState.queryMap)..[tag] = value;
|
||||
final newMap = Map<QueryTag, String>.from(globalState.appState.queryMap)
|
||||
..[_tag] = value;
|
||||
globalState.appState = globalState.appState.copyWith(queryMap: newMap);
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class SelectedItems extends _$SelectedItems with AutoDisposeNotifierMixin {
|
||||
late final String _key;
|
||||
|
||||
@override
|
||||
Set<String> build(String key) {
|
||||
_key = key;
|
||||
return globalState.appState.selectedItemsMap[_key] ?? {};
|
||||
}
|
||||
|
||||
@override
|
||||
onUpdate(value) {
|
||||
final newMap = globalState.appState.selectedItemsMap.copyWitUpdate(
|
||||
key,
|
||||
value.isEmpty ? null : value,
|
||||
);
|
||||
globalState.appState = globalState.appState.copyWith(
|
||||
selectedItemsMap: newMap,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@riverpod
|
||||
class SelectedItem extends _$SelectedItem with AutoDisposeNotifierMixin {
|
||||
late final String _key;
|
||||
|
||||
@override
|
||||
String build(String key) {
|
||||
_key = key;
|
||||
return globalState.appState.selectedItemMap[_key] ?? '';
|
||||
}
|
||||
|
||||
@override
|
||||
onUpdate(value) {
|
||||
final newMap = globalState.appState.selectedItemMap.copyWitUpdate(
|
||||
key,
|
||||
value.isEmpty ? null : value,
|
||||
);
|
||||
globalState.appState = globalState.appState.copyWith(
|
||||
selectedItemMap: newMap,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user