feat: 热搜词跳转直播
This commit is contained in:
@ -1,14 +1,8 @@
|
|||||||
import 'package:hive/hive.dart';
|
|
||||||
|
|
||||||
part 'hot.g.dart';
|
|
||||||
|
|
||||||
@HiveType(typeId: 6)
|
|
||||||
class HotSearchModel {
|
class HotSearchModel {
|
||||||
HotSearchModel({
|
HotSearchModel({
|
||||||
this.list,
|
this.list,
|
||||||
});
|
});
|
||||||
|
|
||||||
@HiveField(0)
|
|
||||||
List<HotSearchItem>? list;
|
List<HotSearchItem>? list;
|
||||||
|
|
||||||
HotSearchModel.fromJson(Map<String, dynamic> json) {
|
HotSearchModel.fromJson(Map<String, dynamic> json) {
|
||||||
@ -18,7 +12,6 @@ class HotSearchModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@HiveType(typeId: 7)
|
|
||||||
class HotSearchItem {
|
class HotSearchItem {
|
||||||
HotSearchItem({
|
HotSearchItem({
|
||||||
this.keyword,
|
this.keyword,
|
||||||
@ -27,20 +20,19 @@ class HotSearchItem {
|
|||||||
this.icon,
|
this.icon,
|
||||||
});
|
});
|
||||||
|
|
||||||
@HiveField(0)
|
|
||||||
String? keyword;
|
String? keyword;
|
||||||
@HiveField(1)
|
|
||||||
String? showName;
|
String? showName;
|
||||||
// 4/5热 11话题 8普通 7直播
|
// 4/5热 11话题 8普通 7直播
|
||||||
@HiveField(2)
|
|
||||||
int? wordType;
|
int? wordType;
|
||||||
@HiveField(3)
|
|
||||||
String? icon;
|
String? icon;
|
||||||
|
List? liveId;
|
||||||
|
|
||||||
HotSearchItem.fromJson(Map<String, dynamic> json) {
|
HotSearchItem.fromJson(Map<String, dynamic> json) {
|
||||||
keyword = json['keyword'];
|
keyword = json['keyword'];
|
||||||
showName = json['show_name'];
|
showName = json['show_name'];
|
||||||
wordType = json['word_type'];
|
wordType = json['word_type'];
|
||||||
icon = json['icon'];
|
icon = json['icon'];
|
||||||
|
liveId = json['live_id'];
|
||||||
|
liveId = json['live_id'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class SSearchController extends GetxController {
|
|||||||
// 其他页面跳转过来
|
// 其他页面跳转过来
|
||||||
if (Get.parameters.keys.isNotEmpty) {
|
if (Get.parameters.keys.isNotEmpty) {
|
||||||
if (Get.parameters['keyword'] != null) {
|
if (Get.parameters['keyword'] != null) {
|
||||||
onClickKeyword(Get.parameters['keyword']!);
|
onClickKeyword(Get.parameters['keyword']!, null);
|
||||||
}
|
}
|
||||||
if (Get.parameters['hintText'] != null) {
|
if (Get.parameters['hintText'] != null) {
|
||||||
hintText = Get.parameters['hintText']!;
|
hintText = Get.parameters['hintText']!;
|
||||||
@ -88,7 +88,12 @@ class SSearchController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 点击热搜关键词
|
// 点击热搜关键词
|
||||||
void onClickKeyword(String keyword) {
|
void onClickKeyword(String keyword, item) {
|
||||||
|
if (item != null && item.wordType == 7) {
|
||||||
|
Get.toNamed('/liveRoom?roomid=${item.liveId.first}',
|
||||||
|
arguments: {'liveItem': null, 'heroTag': '${item.liveId.first}'});
|
||||||
|
return;
|
||||||
|
}
|
||||||
searchKeyWord.value = keyword;
|
searchKeyWord.value = keyword;
|
||||||
controller.value.text = keyword;
|
controller.value.text = keyword;
|
||||||
// 移动光标
|
// 移动光标
|
||||||
|
|||||||
@ -115,8 +115,8 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
customBorder: RoundedRectangleBorder(
|
customBorder: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
),
|
),
|
||||||
onTap: () => ssCtr
|
onTap: () => ssCtr.onClickKeyword(
|
||||||
.onClickKeyword(ssCtr.searchSuggestList[index].term!),
|
ssCtr.searchSuggestList[index].term!, null),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(left: 20, top: 9, bottom: 9),
|
padding: const EdgeInsets.only(left: 20, top: 9, bottom: 9),
|
||||||
child: ssCtr.searchSuggestList[index].textRich,
|
child: ssCtr.searchSuggestList[index].textRich,
|
||||||
@ -178,11 +178,11 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
width: width,
|
width: width,
|
||||||
// ignore: invalid_use_of_protected_member
|
// ignore: invalid_use_of_protected_member
|
||||||
hotSearchList: _searchController.hotSearchList.value,
|
hotSearchList: _searchController.hotSearchList.value,
|
||||||
onClick: (keyword) async {
|
onClick: (keyword, item) async {
|
||||||
_searchController.searchFocusNode.unfocus();
|
_searchController.searchFocusNode.unfocus();
|
||||||
await Future.delayed(
|
await Future.delayed(
|
||||||
const Duration(milliseconds: 150));
|
const Duration(milliseconds: 150));
|
||||||
_searchController.onClickKeyword(keyword);
|
_searchController.onClickKeyword(keyword, item);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -193,7 +193,6 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 缓存数据
|
|
||||||
return const SizedBox();
|
return const SizedBox();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -26,7 +26,7 @@ class HotKeyword extends StatelessWidget {
|
|||||||
borderRadius: BorderRadius.circular(3),
|
borderRadius: BorderRadius.circular(3),
|
||||||
clipBehavior: Clip.hardEdge,
|
clipBehavior: Clip.hardEdge,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () => onClick!(i.keyword),
|
onTap: () => onClick!(i.keyword, i),
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: EdgeInsets.only(
|
padding: EdgeInsets.only(
|
||||||
left: 2,
|
left: 2,
|
||||||
|
|||||||
Reference in New Issue
Block a user