|
|
|
@ -16,8 +16,7 @@ import '../styles.dart';
|
|
|
|
|
|
|
|
|
|
enum HomeTabs { newest, followed }
|
|
|
|
|
|
|
|
|
|
class HomeController extends GetxController
|
|
|
|
|
with GetSingleTickerProviderStateMixin {
|
|
|
|
|
class HomeController extends GetxController with GetSingleTickerProviderStateMixin {
|
|
|
|
|
double _navSearchButtonOffset = 90;
|
|
|
|
|
|
|
|
|
|
var showNavSearchButton = false.obs;
|
|
|
|
@ -36,15 +35,12 @@ class HomeController extends GetxController
|
|
|
|
|
void onInit() {
|
|
|
|
|
tabController = TabController(length: 2, vsync: this);
|
|
|
|
|
|
|
|
|
|
_navSearchButtonOffset =
|
|
|
|
|
48 * MediaQuery.of(Get.context!).textScaleFactor + 48;
|
|
|
|
|
_navSearchButtonOffset = 48 * MediaQuery.of(Get.context!).textScaleFactor + 48;
|
|
|
|
|
|
|
|
|
|
scrollController.addListener(() {
|
|
|
|
|
if (scrollController.offset >= _navSearchButtonOffset &&
|
|
|
|
|
!showNavSearchButton.value) {
|
|
|
|
|
if (scrollController.offset >= _navSearchButtonOffset && !showNavSearchButton.value) {
|
|
|
|
|
showNavSearchButton.value = true;
|
|
|
|
|
} else if (scrollController.offset < _navSearchButtonOffset &&
|
|
|
|
|
showNavSearchButton.value) {
|
|
|
|
|
} else if (scrollController.offset < _navSearchButtonOffset && showNavSearchButton.value) {
|
|
|
|
|
showNavSearchButton.value = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -102,11 +98,8 @@ class HomeTab extends StatelessWidget {
|
|
|
|
|
duration: const Duration(milliseconds: 100),
|
|
|
|
|
child: CupertinoButton(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
child: const Icon(CupertinoIcons.search,
|
|
|
|
|
size: 26, color: Styles.themeNavTitleColor),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
onSearchClick?.call();
|
|
|
|
|
},
|
|
|
|
|
child: const Icon(CupertinoIcons.bell, size: 26, color: Styles.themeNavTitleColor),
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
@ -121,8 +114,7 @@ class HomeTab extends StatelessWidget {
|
|
|
|
|
duration: const Duration(milliseconds: 100),
|
|
|
|
|
child: CupertinoButton(
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
child: const Icon(CupertinoIcons.search,
|
|
|
|
|
size: 26, color: Styles.themeNavTitleColor),
|
|
|
|
|
child: const Icon(CupertinoIcons.search, size: 26, color: Styles.themeNavTitleColor),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
onSearchClick?.call();
|
|
|
|
|
},
|
|
|
|
@ -144,13 +136,12 @@ class HomeTab extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
slivers: <Widget>[
|
|
|
|
|
IsekaiSliverNavigationBar(
|
|
|
|
|
leading: _buildNotificationIconButton(),
|
|
|
|
|
leading: _buildSearchIconButton(),
|
|
|
|
|
backgroundColor: Styles.themeMainColor,
|
|
|
|
|
brightness: Brightness.dark,
|
|
|
|
|
largeTitle: const Text('首页',
|
|
|
|
|
style: TextStyle(color: Styles.themeNavTitleColor)),
|
|
|
|
|
largeTitle: const Text('首页', style: TextStyle(color: Styles.themeNavTitleColor)),
|
|
|
|
|
border: Border.all(style: BorderStyle.none),
|
|
|
|
|
trailing: _buildSearchIconButton(),
|
|
|
|
|
trailing: _buildNotificationIconButton(),
|
|
|
|
|
),
|
|
|
|
|
SliverPersistentHeader(
|
|
|
|
|
delegate: _SliverAppBarDelegate(
|
|
|
|
@ -181,12 +172,10 @@ class HomeTab extends StatelessWidget {
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.all(1),
|
|
|
|
|
child: const Icon(CupertinoIcons.search,
|
|
|
|
|
color: Colors.black54),
|
|
|
|
|
child: const Icon(CupertinoIcons.search, color: Colors.black54),
|
|
|
|
|
),
|
|
|
|
|
const Text("搜索页面...",
|
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
|
style: TextStyle(color: Colors.black54))
|
|
|
|
|
textAlign: TextAlign.center, style: TextStyle(color: Colors.black54))
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -216,10 +205,7 @@ class HomeTab extends StatelessWidget {
|
|
|
|
|
indicatorColor: Styles.themeMainColor,
|
|
|
|
|
labelColor: Styles.themeMainColor,
|
|
|
|
|
unselectedLabelColor: Colors.black45,
|
|
|
|
|
tabs: const [
|
|
|
|
|
CollapsedTabText('最新'),
|
|
|
|
|
CollapsedTabText('关注')
|
|
|
|
|
],
|
|
|
|
|
tabs: const [CollapsedTabText('最新'), CollapsedTabText('关注')],
|
|
|
|
|
onTap: (int selected) {},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
@ -264,8 +250,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate {
|
|
|
|
|
double get maxExtent => max(maxHeight, minHeight);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(
|
|
|
|
|
BuildContext context, double shrinkOffset, bool overlapsContent) {
|
|
|
|
|
Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) {
|
|
|
|
|
return SizedBox.expand(child: child);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|