mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-15 05:33:59 +08:00
@@ -1,8 +1,6 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/http/api.dart';
|
||||
import 'package:PiliPlus/http/init.dart';
|
||||
import 'package:PiliPlus/models/common/home_tab_type.dart';
|
||||
import 'package:PiliPlus/pages/common/common_controller.dart';
|
||||
import 'package:PiliPlus/pages/main/controller.dart';
|
||||
@@ -10,7 +8,6 @@ import 'package:PiliPlus/services/account_service.dart';
|
||||
import 'package:PiliPlus/utils/storage.dart';
|
||||
import 'package:PiliPlus/utils/storage_key.dart';
|
||||
import 'package:PiliPlus/utils/storage_pref.dart';
|
||||
import 'package:PiliPlus/utils/wbi_sign.dart';
|
||||
import 'package:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -23,10 +20,6 @@ class HomeController extends GetxController
|
||||
RxBool? showTopBar;
|
||||
late final bool hideTopBar;
|
||||
|
||||
bool enableSearchWord = Pref.enableSearchWord;
|
||||
late final RxString defaultSearch = ''.obs;
|
||||
late int lateCheckSearchAt = 0;
|
||||
|
||||
ScrollOrRefreshMixin get controller => tabs[tabController.index].ctr();
|
||||
|
||||
@override
|
||||
@@ -38,7 +31,7 @@ class HomeController extends GetxController
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
|
||||
hideTopBar = !Pref.useSideBar && Pref.hideTopBar;
|
||||
hideTopBar = Pref.hideTopBar;
|
||||
if (hideTopBar) {
|
||||
final mainCtr = Get.find<MainController>();
|
||||
switch (mainCtr.barHideType) {
|
||||
@@ -49,11 +42,6 @@ class HomeController extends GetxController
|
||||
}
|
||||
}
|
||||
|
||||
if (enableSearchWord) {
|
||||
lateCheckSearchAt = DateTime.now().millisecondsSinceEpoch;
|
||||
querySearchDefault();
|
||||
}
|
||||
|
||||
setTabConfig();
|
||||
}
|
||||
|
||||
@@ -84,17 +72,4 @@ class HomeController extends GetxController
|
||||
tabController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> querySearchDefault() async {
|
||||
try {
|
||||
final res = await Request().get(
|
||||
Api.searchDefault,
|
||||
queryParameters: await WbiSign.makSign({'web_location': 333.1365}),
|
||||
);
|
||||
if (res.data['code'] == 0) {
|
||||
defaultSearch.value = res.data['data']?['name'] ?? '';
|
||||
// defaultSearch.value = res.data['data']?['show_name'] ?? '';
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:PiliPlus/pages/main/controller.dart';
|
||||
import 'package:PiliPlus/pages/mine/controller.dart';
|
||||
import 'package:PiliPlus/utils/extension/get_ext.dart';
|
||||
import 'package:PiliPlus/utils/extension/size_ext.dart';
|
||||
import 'package:PiliPlus/utils/feed_back.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
@@ -51,7 +50,6 @@ class _HomePageState extends CommonPageState<HomePage>
|
||||
splashBorderRadius: Style.mdRadius,
|
||||
tabAlignment: TabAlignment.center,
|
||||
onTap: (_) {
|
||||
feedBack();
|
||||
if (!_homeController.tabController.indexIsChanging) {
|
||||
_homeController.animateToTop();
|
||||
}
|
||||
@@ -71,9 +69,7 @@ class _HomePageState extends CommonPageState<HomePage>
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
if (!_mainController.useSideBar &&
|
||||
MediaQuery.sizeOf(context).isPortrait)
|
||||
customAppBar(theme),
|
||||
if (MediaQuery.sizeOf(context).isPortrait) customAppBar(theme),
|
||||
tabBar,
|
||||
Expanded(
|
||||
child: onBuild(
|
||||
@@ -151,33 +147,17 @@ class _HomePageState extends CommonPageState<HomePage>
|
||||
splashColor: theme.colorScheme.primaryContainer.withValues(
|
||||
alpha: 0.3,
|
||||
),
|
||||
onTap: () => Get.toNamed(
|
||||
'/search',
|
||||
parameters: _homeController.enableSearchWord
|
||||
? {'hintText': _homeController.defaultSearch.value}
|
||||
: null,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 14),
|
||||
Icon(
|
||||
onTap: () => Get.toNamed('/search'),
|
||||
child: Align(
|
||||
alignment: .centerLeft,
|
||||
child: Padding(
|
||||
padding: const .only(left: 14),
|
||||
child: Icon(
|
||||
Icons.search_outlined,
|
||||
color: theme.colorScheme.onSecondaryContainer,
|
||||
semanticLabel: '搜索',
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Expanded(
|
||||
child: Obx(
|
||||
() => Text(
|
||||
_homeController.defaultSearch.value,
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: theme.colorScheme.outline),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user