mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-06-08 20:14:51 +08:00
@@ -1,13 +1,13 @@
|
||||
import 'package:PiliPlus/common/style.dart';
|
||||
import 'package:PiliPlus/common/widgets/custom_height_widget.dart';
|
||||
import 'package:PiliPlus/common/widgets/image/network_img_layer.dart';
|
||||
import 'package:PiliPlus/common/widgets/scroll_physics.dart';
|
||||
import 'package:PiliPlus/pages/common/common_page.dart';
|
||||
import 'package:PiliPlus/models/common/home_tab_type.dart';
|
||||
import 'package:PiliPlus/pages/home/controller.dart';
|
||||
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:flutter/foundation.dart' show kDebugMode;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
|
||||
@@ -19,14 +19,11 @@ class HomePage extends StatefulWidget {
|
||||
State<HomePage> createState() => _HomePageState();
|
||||
}
|
||||
|
||||
class _HomePageState extends CommonPageState<HomePage>
|
||||
class _HomePageState extends State<HomePage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
final _homeController = Get.putOrFind(HomeController.new);
|
||||
final _mainController = Get.find<MainController>();
|
||||
|
||||
@override
|
||||
bool get needsCorrection => _homeController.hideTopBar;
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@@ -34,51 +31,36 @@ class _HomePageState extends CommonPageState<HomePage>
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
final theme = Theme.of(context);
|
||||
Widget tabBar;
|
||||
if (_homeController.tabs.length > 1) {
|
||||
tabBar = Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: SizedBox(
|
||||
height: 42,
|
||||
width: double.infinity,
|
||||
child: TabBar(
|
||||
controller: _homeController.tabController,
|
||||
tabs: _homeController.tabs.map((e) => Tab(text: e.label)).toList(),
|
||||
isScrollable: true,
|
||||
dividerColor: Colors.transparent,
|
||||
dividerHeight: 0,
|
||||
splashBorderRadius: Style.mdRadius,
|
||||
tabAlignment: TabAlignment.center,
|
||||
onTap: (_) {
|
||||
if (!_homeController.tabController.indexIsChanging) {
|
||||
_homeController.animateToTop();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
if (_homeController.hideTopBar &&
|
||||
_mainController.barHideType == .instant) {
|
||||
tabBar = Material(
|
||||
color: theme.colorScheme.surface,
|
||||
child: tabBar,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
tabBar = const SizedBox(height: 6);
|
||||
}
|
||||
return Column(
|
||||
children: [
|
||||
if (MediaQuery.sizeOf(context).isPortrait) customAppBar(theme),
|
||||
tabBar,
|
||||
Expanded(
|
||||
child: onBuild(
|
||||
tabBarView(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: SizedBox(
|
||||
height: 42,
|
||||
width: double.infinity,
|
||||
child: TabBar(
|
||||
controller: _homeController.tabController,
|
||||
children: _homeController.tabs.map((e) => e.page).toList(),
|
||||
tabs: HomeTabType.values.map((e) => Tab(text: e.label)).toList(),
|
||||
isScrollable: true,
|
||||
dividerColor: Colors.transparent,
|
||||
dividerHeight: 0,
|
||||
splashBorderRadius: Style.mdRadius,
|
||||
tabAlignment: TabAlignment.center,
|
||||
onTap: (_) {
|
||||
if (!_homeController.tabController.indexIsChanging) {
|
||||
_homeController.animateToTop();
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: tabBarView(
|
||||
controller: _homeController.tabController,
|
||||
children: HomeTabType.values.map((e) => e.page).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -94,39 +76,6 @@ class _HomePageState extends CommonPageState<HomePage>
|
||||
userAvatar(theme: theme, mainController: _mainController),
|
||||
],
|
||||
);
|
||||
if (_homeController.hideTopBar) {
|
||||
if (_mainController.barOffset case final barOffset?) {
|
||||
return Obx(
|
||||
() {
|
||||
final offset = barOffset.value;
|
||||
return CustomHeightWidget(
|
||||
offset: Offset(0, -offset),
|
||||
height: Style.topBarHeight - offset,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
if (_homeController.showTopBar case final showTopBar?) {
|
||||
return Obx(() {
|
||||
final showSearchBar = showTopBar.value;
|
||||
return AnimatedOpacity(
|
||||
opacity: showSearchBar ? 1 : 0,
|
||||
duration: const Duration(milliseconds: 300),
|
||||
child: AnimatedContainer(
|
||||
curve: Curves.easeInOutCubicEmphasized,
|
||||
duration: const Duration(milliseconds: 500),
|
||||
height: showSearchBar ? Style.topBarHeight : 0,
|
||||
padding: padding,
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
return Container(
|
||||
height: Style.topBarHeight,
|
||||
padding: padding,
|
||||
@@ -246,7 +195,7 @@ Widget userAvatar({
|
||||
Widget msgBadge(MainController mainController) {
|
||||
return Obx(
|
||||
() {
|
||||
if (mainController.accountService.isLogin.value) {
|
||||
if (mainController.accountService.isLogin.value || kDebugMode) {
|
||||
final count = mainController.msgUnReadCount.value;
|
||||
final isNumBadge = mainController.msgBadgeMode == .number;
|
||||
return IconButton(
|
||||
|
||||
Reference in New Issue
Block a user