mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-06 02:54:49 +08:00
@@ -1,47 +1,23 @@
|
||||
import 'package:PiliPlus/utils/em.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class SearchSuggestModel {
|
||||
SearchSuggestModel({
|
||||
this.tag,
|
||||
this.term,
|
||||
});
|
||||
|
||||
List<SearchSuggestItem>? tag;
|
||||
String? term;
|
||||
|
||||
SearchSuggestModel.fromJson(Map<String, dynamic> json) {
|
||||
tag = (json['tag'] as List?)
|
||||
?.map<SearchSuggestItem>(
|
||||
(e) => SearchSuggestItem.fromJson(e, json['term']))
|
||||
?.map<SearchSuggestItem>((e) => SearchSuggestItem.fromJson(e))
|
||||
.toList();
|
||||
}
|
||||
}
|
||||
|
||||
class SearchSuggestItem {
|
||||
String? value;
|
||||
String? term;
|
||||
int? spid;
|
||||
late String textRich;
|
||||
|
||||
SearchSuggestItem.fromJson(Map<String, dynamic> json, String inputTerm) {
|
||||
value = json['value'];
|
||||
SearchSuggestItem.fromJson(Map<String, dynamic> json) {
|
||||
term = json['term'];
|
||||
textRich = json['name'];
|
||||
}
|
||||
}
|
||||
|
||||
Widget highlightText(BuildContext context, String str) {
|
||||
return Text.rich(TextSpan(children: [
|
||||
for (var i in Em.regTitle(str))
|
||||
TextSpan(
|
||||
text: i['text'],
|
||||
style: i['type'] == 'em'
|
||||
? TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
)
|
||||
: DefaultTextStyle.of(context).style,
|
||||
)
|
||||
]));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user