2025-03-12 17:15:31 +08:00
|
|
|
import 'package:fl_clash/models/models.dart';
|
2025-02-09 18:39:38 +08:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:riverpod/riverpod.dart';
|
|
|
|
|
import 'context.dart';
|
|
|
|
|
|
|
|
|
|
mixin AutoDisposeNotifierMixin<T> on AutoDisposeNotifier<T> {
|
|
|
|
|
set value(T value) {
|
|
|
|
|
state = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool updateShouldNotify(previous, next) {
|
|
|
|
|
final res = super.updateShouldNotify(previous, next);
|
|
|
|
|
if (res) {
|
|
|
|
|
onUpdate(next);
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onUpdate(T value) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mixin PageMixin<T extends StatefulWidget> on State<T> {
|
|
|
|
|
void onPageShow() {
|
|
|
|
|
initPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
initPageState() {
|
|
|
|
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
|
|
|
|
final commonScaffoldState = context.commonScaffoldState;
|
|
|
|
|
commonScaffoldState?.actions = actions;
|
|
|
|
|
commonScaffoldState?.floatingActionButton = floatingActionButton;
|
|
|
|
|
commonScaffoldState?.onKeywordsUpdate = onKeywordsUpdate;
|
2025-03-12 17:15:31 +08:00
|
|
|
commonScaffoldState?.updateSearchState(
|
|
|
|
|
(_) => onSearch != null
|
|
|
|
|
? AppBarSearchState(
|
|
|
|
|
onSearch: onSearch!,
|
|
|
|
|
)
|
|
|
|
|
: null,
|
|
|
|
|
);
|
2025-02-09 18:39:38 +08:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void onPageHidden() {}
|
|
|
|
|
|
|
|
|
|
List<Widget> get actions => [];
|
|
|
|
|
|
|
|
|
|
Widget? get floatingActionButton => null;
|
|
|
|
|
|
|
|
|
|
Function(String)? get onSearch => null;
|
|
|
|
|
|
|
|
|
|
Function(List<String>)? get onKeywordsUpdate => null;
|
|
|
|
|
}
|