mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
fix search, locale
This commit is contained in:
@@ -539,7 +539,7 @@ class SearchBarController {
|
||||
|
||||
final void Function(String text)? onSearch;
|
||||
|
||||
final String initialText;
|
||||
String currentText;
|
||||
|
||||
void setText(String text) {
|
||||
_state?.setText(text);
|
||||
@@ -551,7 +551,7 @@ class SearchBarController {
|
||||
setText(text);
|
||||
}
|
||||
|
||||
SearchBarController({this.onSearch, this.initialText = ''});
|
||||
SearchBarController({this.onSearch, this.currentText = ''});
|
||||
}
|
||||
|
||||
abstract mixin class _SearchBarMixin {
|
||||
@@ -591,7 +591,7 @@ class _SliverSearchBarState extends State<SliverSearchBar>
|
||||
void initState() {
|
||||
_controller = widget.controller;
|
||||
_controller._state = this;
|
||||
_editingController = TextEditingController(text: _controller.initialText);
|
||||
_editingController = TextEditingController(text: _controller.currentText);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@@ -747,7 +747,7 @@ class _SearchBarState extends State<AppSearchBar> with _SearchBarMixin {
|
||||
void initState() {
|
||||
_controller = widget.controller;
|
||||
_controller._state = this;
|
||||
_editingController = TextEditingController(text: _controller.initialText);
|
||||
_editingController = TextEditingController(text: _controller.currentText);
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,6 @@ import 'package:path_provider/path_provider.dart';
|
||||
|
||||
import 'appdata.dart';
|
||||
|
||||
|
||||
export "widget_utils.dart";
|
||||
export "context.dart";
|
||||
|
||||
@@ -14,12 +13,18 @@ class _App {
|
||||
final version = "1.0.0";
|
||||
|
||||
bool get isAndroid => Platform.isAndroid;
|
||||
|
||||
bool get isIOS => Platform.isIOS;
|
||||
|
||||
bool get isWindows => Platform.isWindows;
|
||||
|
||||
bool get isLinux => Platform.isLinux;
|
||||
|
||||
bool get isMacOS => Platform.isMacOS;
|
||||
|
||||
bool get isDesktop =>
|
||||
Platform.isWindows || Platform.isLinux || Platform.isMacOS;
|
||||
|
||||
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
||||
|
||||
Locale get locale {
|
||||
@@ -28,6 +33,12 @@ class _App {
|
||||
deviceLocale.scriptCode == "Hant") {
|
||||
deviceLocale = const Locale("zh", "TW");
|
||||
}
|
||||
if (appdata.settings['language'] != 'system') {
|
||||
return Locale(
|
||||
appdata.settings['language'].split('-')[0],
|
||||
appdata.settings['language'].split('-')[1],
|
||||
);
|
||||
}
|
||||
return deviceLocale;
|
||||
}
|
||||
|
||||
@@ -45,7 +56,7 @@ class _App {
|
||||
}
|
||||
|
||||
void pop() {
|
||||
if(rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||
if (rootNavigatorKey.currentState?.canPop() ?? false) {
|
||||
rootNavigatorKey.currentState?.pop();
|
||||
} else if (mainNavigatorKey?.currentState?.canPop() ?? false) {
|
||||
mainNavigatorKey?.currentState?.pop();
|
||||
@@ -57,7 +68,7 @@ class _App {
|
||||
Future<void> init() async {
|
||||
cachePath = (await getApplicationCacheDirectory()).path;
|
||||
dataPath = (await getApplicationSupportDirectory()).path;
|
||||
mainColor = switch(appdata.settings['color']) {
|
||||
mainColor = switch (appdata.settings['color']) {
|
||||
'red' => Colors.red,
|
||||
'pink' => Colors.pink,
|
||||
'purple' => Colors.purple,
|
||||
|
@@ -42,10 +42,14 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
||||
|
||||
void search([String? text]) {
|
||||
if (text != null) {
|
||||
if(suggestionsController.entry != null) {
|
||||
suggestionsController.remove();
|
||||
}
|
||||
setState(() {
|
||||
this.text = text;
|
||||
});
|
||||
appdata.addSearchHistory(text);
|
||||
controller.currentText = text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,10 +84,18 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
Future.microtask(() {
|
||||
suggestionsController.remove();
|
||||
});
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
controller = SearchBarController(
|
||||
initialText: widget.text,
|
||||
currentText: widget.text,
|
||||
onSearch: search,
|
||||
);
|
||||
sourceKey = widget.sourceKey;
|
||||
|
Reference in New Issue
Block a user