Compare commits
2 Commits
v1.0.22.04
...
feature-ho
Author | SHA1 | Date | |
---|---|---|---|
41c40dfbc4 | |||
5d9ecab1b0 |
@ -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'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,84 +0,0 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
||||||
|
|
||||||
part of 'hot.dart';
|
|
||||||
|
|
||||||
// **************************************************************************
|
|
||||||
// TypeAdapterGenerator
|
|
||||||
// **************************************************************************
|
|
||||||
|
|
||||||
class HotSearchModelAdapter extends TypeAdapter<HotSearchModel> {
|
|
||||||
@override
|
|
||||||
final int typeId = 6;
|
|
||||||
|
|
||||||
@override
|
|
||||||
HotSearchModel read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return HotSearchModel(
|
|
||||||
list: (fields[0] as List?)?.cast<HotSearchItem>(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, HotSearchModel obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(1)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.list);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is HotSearchModelAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
||||||
|
|
||||||
class HotSearchItemAdapter extends TypeAdapter<HotSearchItem> {
|
|
||||||
@override
|
|
||||||
final int typeId = 7;
|
|
||||||
|
|
||||||
@override
|
|
||||||
HotSearchItem read(BinaryReader reader) {
|
|
||||||
final numOfFields = reader.readByte();
|
|
||||||
final fields = <int, dynamic>{
|
|
||||||
for (int i = 0; i < numOfFields; i++) reader.readByte(): reader.read(),
|
|
||||||
};
|
|
||||||
return HotSearchItem(
|
|
||||||
keyword: fields[0] as String?,
|
|
||||||
showName: fields[1] as String?,
|
|
||||||
wordType: fields[2] as int?,
|
|
||||||
icon: fields[3] as String?,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
void write(BinaryWriter writer, HotSearchItem obj) {
|
|
||||||
writer
|
|
||||||
..writeByte(4)
|
|
||||||
..writeByte(0)
|
|
||||||
..write(obj.keyword)
|
|
||||||
..writeByte(1)
|
|
||||||
..write(obj.showName)
|
|
||||||
..writeByte(2)
|
|
||||||
..write(obj.wordType)
|
|
||||||
..writeByte(3)
|
|
||||||
..write(obj.icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode => typeId.hashCode;
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) =>
|
|
||||||
identical(this, other) ||
|
|
||||||
other is HotSearchItemAdapter &&
|
|
||||||
runtimeType == other.runtimeType &&
|
|
||||||
typeId == other.typeId;
|
|
||||||
}
|
|
@ -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,15 +193,7 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// 缓存数据
|
return const SizedBox();
|
||||||
if (_searchController.hotSearchList.isNotEmpty) {
|
|
||||||
return HotKeyword(
|
|
||||||
width: width,
|
|
||||||
hotSearchList: _searchController.hotSearchList,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
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,
|
||||||
|
@ -4,7 +4,6 @@ import 'dart:io';
|
|||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
import 'package:pilipala/models/model_owner.dart';
|
import 'package:pilipala/models/model_owner.dart';
|
||||||
import 'package:pilipala/models/search/hot.dart';
|
|
||||||
import 'package:pilipala/models/user/info.dart';
|
import 'package:pilipala/models/user/info.dart';
|
||||||
|
|
||||||
class GStrorage {
|
class GStrorage {
|
||||||
@ -48,8 +47,6 @@ class GStrorage {
|
|||||||
Hive.registerAdapter(OwnerAdapter());
|
Hive.registerAdapter(OwnerAdapter());
|
||||||
Hive.registerAdapter(UserInfoDataAdapter());
|
Hive.registerAdapter(UserInfoDataAdapter());
|
||||||
Hive.registerAdapter(LevelInfoAdapter());
|
Hive.registerAdapter(LevelInfoAdapter());
|
||||||
Hive.registerAdapter(HotSearchModelAdapter());
|
|
||||||
Hive.registerAdapter(HotSearchItemAdapter());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> lazyInit() async {
|
static Future<void> lazyInit() async {
|
||||||
|
Reference in New Issue
Block a user