mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
fix search, locale
This commit is contained in:
@@ -539,7 +539,7 @@ class SearchBarController {
|
|||||||
|
|
||||||
final void Function(String text)? onSearch;
|
final void Function(String text)? onSearch;
|
||||||
|
|
||||||
final String initialText;
|
String currentText;
|
||||||
|
|
||||||
void setText(String text) {
|
void setText(String text) {
|
||||||
_state?.setText(text);
|
_state?.setText(text);
|
||||||
@@ -551,7 +551,7 @@ class SearchBarController {
|
|||||||
setText(text);
|
setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
SearchBarController({this.onSearch, this.initialText = ''});
|
SearchBarController({this.onSearch, this.currentText = ''});
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract mixin class _SearchBarMixin {
|
abstract mixin class _SearchBarMixin {
|
||||||
@@ -591,7 +591,7 @@ class _SliverSearchBarState extends State<SliverSearchBar>
|
|||||||
void initState() {
|
void initState() {
|
||||||
_controller = widget.controller;
|
_controller = widget.controller;
|
||||||
_controller._state = this;
|
_controller._state = this;
|
||||||
_editingController = TextEditingController(text: _controller.initialText);
|
_editingController = TextEditingController(text: _controller.currentText);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -747,7 +747,7 @@ class _SearchBarState extends State<AppSearchBar> with _SearchBarMixin {
|
|||||||
void initState() {
|
void initState() {
|
||||||
_controller = widget.controller;
|
_controller = widget.controller;
|
||||||
_controller._state = this;
|
_controller._state = this;
|
||||||
_editingController = TextEditingController(text: _controller.initialText);
|
_editingController = TextEditingController(text: _controller.currentText);
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,7 +6,6 @@ import 'package:path_provider/path_provider.dart';
|
|||||||
|
|
||||||
import 'appdata.dart';
|
import 'appdata.dart';
|
||||||
|
|
||||||
|
|
||||||
export "widget_utils.dart";
|
export "widget_utils.dart";
|
||||||
export "context.dart";
|
export "context.dart";
|
||||||
|
|
||||||
@@ -14,12 +13,18 @@ class _App {
|
|||||||
final version = "1.0.0";
|
final version = "1.0.0";
|
||||||
|
|
||||||
bool get isAndroid => Platform.isAndroid;
|
bool get isAndroid => Platform.isAndroid;
|
||||||
|
|
||||||
bool get isIOS => Platform.isIOS;
|
bool get isIOS => Platform.isIOS;
|
||||||
|
|
||||||
bool get isWindows => Platform.isWindows;
|
bool get isWindows => Platform.isWindows;
|
||||||
|
|
||||||
bool get isLinux => Platform.isLinux;
|
bool get isLinux => Platform.isLinux;
|
||||||
|
|
||||||
bool get isMacOS => Platform.isMacOS;
|
bool get isMacOS => Platform.isMacOS;
|
||||||
|
|
||||||
bool get isDesktop =>
|
bool get isDesktop =>
|
||||||
Platform.isWindows || Platform.isLinux || Platform.isMacOS;
|
Platform.isWindows || Platform.isLinux || Platform.isMacOS;
|
||||||
|
|
||||||
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
bool get isMobile => Platform.isAndroid || Platform.isIOS;
|
||||||
|
|
||||||
Locale get locale {
|
Locale get locale {
|
||||||
@@ -28,6 +33,12 @@ class _App {
|
|||||||
deviceLocale.scriptCode == "Hant") {
|
deviceLocale.scriptCode == "Hant") {
|
||||||
deviceLocale = const Locale("zh", "TW");
|
deviceLocale = const Locale("zh", "TW");
|
||||||
}
|
}
|
||||||
|
if (appdata.settings['language'] != 'system') {
|
||||||
|
return Locale(
|
||||||
|
appdata.settings['language'].split('-')[0],
|
||||||
|
appdata.settings['language'].split('-')[1],
|
||||||
|
);
|
||||||
|
}
|
||||||
return deviceLocale;
|
return deviceLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,10 +42,14 @@ class _SearchResultPageState extends State<SearchResultPage> {
|
|||||||
|
|
||||||
void search([String? text]) {
|
void search([String? text]) {
|
||||||
if (text != null) {
|
if (text != null) {
|
||||||
|
if(suggestionsController.entry != null) {
|
||||||
|
suggestionsController.remove();
|
||||||
|
}
|
||||||
setState(() {
|
setState(() {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
});
|
});
|
||||||
appdata.addSearchHistory(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
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
controller = SearchBarController(
|
controller = SearchBarController(
|
||||||
initialText: widget.text,
|
currentText: widget.text,
|
||||||
onSearch: search,
|
onSearch: search,
|
||||||
);
|
);
|
||||||
sourceKey = widget.sourceKey;
|
sourceKey = widget.sourceKey;
|
||||||
|
Reference in New Issue
Block a user