diff --git a/lib/pages/dynamics/view.dart b/lib/pages/dynamics/view.dart index 1775798e..495eb770 100644 --- a/lib/pages/dynamics/view.dart +++ b/lib/pages/dynamics/view.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:custom_sliding_segmented_control/custom_sliding_segmented_control.dart'; import 'package:easy_debounce/easy_throttle.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:hive/hive.dart'; import 'package:pilipala/common/skeleton/dynamic_card.dart'; @@ -77,10 +78,14 @@ class _DynamicsPageState extends State Widget build(BuildContext context) { super.build(context); return Scaffold( + backgroundColor: Colors.transparent, appBar: AppBar( elevation: 0, scrolledUnderElevation: 0, - titleSpacing: 0, + backgroundColor: Colors.transparent, + systemOverlayStyle: Theme.of(context).brightness == Brightness.dark + ? SystemUiOverlayStyle.light + : SystemUiOverlayStyle.dark, title: SizedBox( height: 34, child: Stack( diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index 74072b2f..0163723b 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -46,104 +46,66 @@ class _HomePageState extends State @override Widget build(BuildContext context) { super.build(context); - Brightness currentBrightness = MediaQuery.of(context).platformBrightness; - // 设置状态栏图标的亮度 - if (_homeController.enableGradientBg) { - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( - statusBarIconBrightness: currentBrightness == Brightness.light - ? Brightness.dark - : Brightness.light, - )); - } return Scaffold( extendBody: true, extendBodyBehindAppBar: true, - appBar: _homeController.enableGradientBg - ? null - : AppBar(toolbarHeight: 0, elevation: 0), - body: Stack( + backgroundColor: Colors.transparent, + appBar: AppBar( + toolbarHeight: 0, + elevation: 0, + backgroundColor: Colors.transparent, + systemOverlayStyle: Theme.of(context).brightness == Brightness.dark + ? SystemUiOverlayStyle.light + : SystemUiOverlayStyle.dark, + ), + body: Column( children: [ - // gradient background - if (_homeController.enableGradientBg) ...[ - Align( - alignment: Alignment.topLeft, - child: Opacity( - opacity: 0.6, - child: Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Theme.of(context) - .colorScheme - .primary - .withOpacity(0.4), - Theme.of(context) - .colorScheme - .surface - .withOpacity(0.5), - Theme.of(context).colorScheme.surface - ], - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - stops: const [0.1, 0.3, 0.5]), + CustomAppBar( + stream: _homeController.hideSearchBar + ? stream + : StreamController.broadcast().stream, + ctr: _homeController, + callback: showUserBottomSheet, + ), + if (_homeController.tabs.length > 1) ...[ + if (_homeController.enableGradientBg) ...[ + const CustomTabs(), + ] else ...[ + Container( + width: double.infinity, + height: 42, + padding: const EdgeInsets.only(top: 4), + child: Align( + alignment: Alignment.center, + child: TabBar( + controller: _homeController.tabController, + tabs: [ + for (var i in _homeController.tabs) Tab(text: i['label']) + ], + isScrollable: true, + dividerColor: Colors.transparent, + enableFeedback: true, + splashBorderRadius: BorderRadius.circular(10), + tabAlignment: TabAlignment.center, + onTap: (value) { + feedBack(); + if (_homeController.initialIndex.value == value) { + _homeController.tabsCtrList[value]().animateToTop(); + } + _homeController.initialIndex.value = value; + }, ), ), ), - ), - ], - Column( - children: [ - CustomAppBar( - stream: _homeController.hideSearchBar - ? stream - : StreamController.broadcast().stream, - ctr: _homeController, - callback: showUserBottomSheet, - ), - if (_homeController.tabs.length > 1) ...[ - if (_homeController.enableGradientBg) ...[ - const CustomTabs(), - ] else ...[ - const SizedBox(height: 4), - SizedBox( - width: double.infinity, - height: 42, - child: Align( - alignment: Alignment.center, - child: TabBar( - controller: _homeController.tabController, - tabs: [ - for (var i in _homeController.tabs) - Tab(text: i['label']) - ], - isScrollable: true, - dividerColor: Colors.transparent, - enableFeedback: true, - splashBorderRadius: BorderRadius.circular(10), - tabAlignment: TabAlignment.center, - onTap: (value) { - feedBack(); - if (_homeController.initialIndex.value == value) { - _homeController.tabsCtrList[value]().animateToTop(); - } - _homeController.initialIndex.value = value; - }, - ), - ), - ), - ], - ] else ...[ - const SizedBox(height: 6), - ], - Expanded( - child: TabBarView( - controller: _homeController.tabController, - children: _homeController.tabsPageList, - ), - ), ], + ] else ...[ + const SizedBox(height: 6), + ], + Expanded( + child: TabBarView( + controller: _homeController.tabController, + children: _homeController.tabsPageList, + ), ), ], ), @@ -280,7 +242,10 @@ class DefaultUser extends StatelessWidget { style: ButtonStyle( padding: MaterialStateProperty.all(EdgeInsets.zero), backgroundColor: MaterialStateProperty.resolveWith((states) { - return Theme.of(context).colorScheme.onInverseSurface; + return Theme.of(context) + .colorScheme + .onSecondaryContainer + .withOpacity(0.05); }), ), onPressed: () => callback?.call(), @@ -317,7 +282,7 @@ class _CustomTabsState extends State { Widget build(BuildContext context) { return Container( height: 44, - margin: const EdgeInsets.only(top: 4), + margin: const EdgeInsets.only(top: 8), child: Obx( () => ListView.separated( padding: const EdgeInsets.symmetric(horizontal: 14.0), diff --git a/lib/pages/main/controller.dart b/lib/pages/main/controller.dart index 2ef2bf7f..849e16d5 100644 --- a/lib/pages/main/controller.dart +++ b/lib/pages/main/controller.dart @@ -26,6 +26,7 @@ class MainController extends GetxController { Box userInfoCache = GStrorage.userInfo; RxBool userLogin = false.obs; late Rx dynamicBadgeType = DynamicBadgeMode.number.obs; + late bool enableGradientBg; @override void onInit() { @@ -44,6 +45,8 @@ class MainController extends GetxController { if (dynamicBadgeType.value != DynamicBadgeMode.hidden) { getUnreadDynamic(); } + enableGradientBg = + setting.get(SettingBoxKey.enableGradientBg, defaultValue: true); } void onBackPressed(BuildContext context) { diff --git a/lib/pages/main/view.dart b/lib/pages/main/view.dart index 29573501..20a12d35 100644 --- a/lib/pages/main/view.dart +++ b/lib/pages/main/view.dart @@ -117,14 +117,47 @@ class _MainAppState extends State with SingleTickerProviderStateMixin { }, child: Scaffold( extendBody: true, - body: PageView( - physics: const NeverScrollableScrollPhysics(), - controller: _mainController.pageController, - onPageChanged: (index) { - _mainController.selectedIndex = index; - setState(() {}); - }, - children: _mainController.pages, + body: Stack( + children: [ + if (_mainController.enableGradientBg) + Align( + alignment: Alignment.topLeft, + child: Opacity( + opacity: 0.6, + child: Container( + width: MediaQuery.of(context).size.width, + // height: MediaQuery.of(context).size.height, + height: MediaQuery.of(context).padding.top + 400, + decoration: BoxDecoration( + gradient: LinearGradient( + colors: [ + Theme.of(context) + .colorScheme + .primary + .withOpacity(0.6), + Theme.of(context) + .colorScheme + .surface + .withOpacity(0.3), + Theme.of(context).colorScheme.surface + ], + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + stops: const [0.1, 0.8, 1]), + ), + ), + ), + ), + PageView( + physics: const NeverScrollableScrollPhysics(), + controller: _mainController.pageController, + onPageChanged: (index) { + _mainController.selectedIndex = index; + setState(() {}); + }, + children: _mainController.pages, + ), + ], ), bottomNavigationBar: _mainController.navigationBars.length > 1 ? StreamBuilder( diff --git a/lib/pages/media/view.dart b/lib/pages/media/view.dart index cc413e59..3694fa68 100644 --- a/lib/pages/media/view.dart +++ b/lib/pages/media/view.dart @@ -1,11 +1,11 @@ import 'dart:async'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:get/get.dart'; import 'package:pilipala/common/widgets/network_img_layer.dart'; import 'package:pilipala/models/user/fav_folder.dart'; import 'package:pilipala/pages/media/index.dart'; -import 'package:pilipala/utils/main_stream.dart'; import 'package:pilipala/utils/utils.dart'; class MediaPage extends StatefulWidget { @@ -46,7 +46,16 @@ class _MediaPageState extends State super.build(context); Color primary = Theme.of(context).colorScheme.primary; return Scaffold( - appBar: AppBar(toolbarHeight: 30), + backgroundColor: Colors.transparent, + appBar: AppBar( + elevation: 0, + scrolledUnderElevation: 0, + toolbarHeight: 30, + backgroundColor: Colors.transparent, + systemOverlayStyle: Theme.of(context).brightness == Brightness.dark + ? SystemUiOverlayStyle.light + : SystemUiOverlayStyle.dark, + ), body: SingleChildScrollView( controller: mediaController.scrollController, child: Column( diff --git a/lib/pages/rank/controller.dart b/lib/pages/rank/controller.dart index 64395ec7..bb34b13f 100644 --- a/lib/pages/rank/controller.dart +++ b/lib/pages/rank/controller.dart @@ -17,13 +17,10 @@ class RankController extends GetxController with GetTickerProviderStateMixin { Box setting = GStrorage.setting; late final StreamController searchBarStream = StreamController.broadcast(); - late bool enableGradientBg; @override void onInit() { super.onInit(); - enableGradientBg = - setting.get(SettingBoxKey.enableGradientBg, defaultValue: true); // 进行tabs配置 setTabConfig(); } diff --git a/lib/pages/rank/view.dart b/lib/pages/rank/view.dart index 4efa2b4e..218e60cf 100644 --- a/lib/pages/rank/view.dart +++ b/lib/pages/rank/view.dart @@ -31,94 +31,56 @@ class _RankPageState extends State @override Widget build(BuildContext context) { super.build(context); - Brightness currentBrightness = MediaQuery.of(context).platformBrightness; - // 设置状态栏图标的亮度 - if (_rankController.enableGradientBg) { - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( - statusBarIconBrightness: currentBrightness == Brightness.light - ? Brightness.dark - : Brightness.light, - )); - } return Scaffold( extendBody: true, - extendBodyBehindAppBar: false, - appBar: _rankController.enableGradientBg - ? null - : AppBar(toolbarHeight: 0, elevation: 0), - body: Stack( + extendBodyBehindAppBar: true, + backgroundColor: Colors.transparent, + appBar: AppBar( + toolbarHeight: 0, + elevation: 0, + backgroundColor: Colors.transparent, + systemOverlayStyle: Theme.of(context).brightness == Brightness.dark + ? SystemUiOverlayStyle.light + : SystemUiOverlayStyle.dark, + ), + body: Column( children: [ - // gradient background - if (_rankController.enableGradientBg) ...[ - Align( - alignment: Alignment.topLeft, - child: Opacity( - opacity: 0.6, - child: Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height, - decoration: BoxDecoration( - gradient: LinearGradient( - colors: [ - Theme.of(context) - .colorScheme - .primary - .withOpacity(0.9), - Theme.of(context) - .colorScheme - .primary - .withOpacity(0.5), - Theme.of(context).colorScheme.surface - ], - begin: Alignment.topLeft, - end: Alignment.bottomRight, - stops: const [0, 0.0034, 0.34]), - ), + const CustomAppBar(), + if (_rankController.tabs.length > 1) ...[ + const SizedBox(height: 4), + SizedBox( + width: double.infinity, + height: 42, + child: Align( + alignment: Alignment.center, + child: TabBar( + controller: _rankController.tabController, + tabs: [ + for (var i in _rankController.tabs) Tab(text: i['label']) + ], + isScrollable: true, + dividerColor: Colors.transparent, + enableFeedback: true, + splashBorderRadius: BorderRadius.circular(10), + tabAlignment: TabAlignment.center, + onTap: (value) { + feedBack(); + if (_rankController.initialIndex.value == value) { + _rankController.tabsCtrList[value].animateToTop(); + } + _rankController.initialIndex.value = value; + }, ), ), ), + ] else ...[ + const SizedBox(height: 6), ], - Column( - children: [ - const CustomAppBar(), - if (_rankController.tabs.length > 1) ...[ - const SizedBox(height: 4), - SizedBox( - width: double.infinity, - height: 42, - child: Align( - alignment: Alignment.center, - child: TabBar( - controller: _rankController.tabController, - tabs: [ - for (var i in _rankController.tabs) - Tab(text: i['label']) - ], - isScrollable: true, - dividerColor: Colors.transparent, - enableFeedback: true, - splashBorderRadius: BorderRadius.circular(10), - tabAlignment: TabAlignment.center, - onTap: (value) { - feedBack(); - if (_rankController.initialIndex.value == value) { - _rankController.tabsCtrList[value].animateToTop(); - } - _rankController.initialIndex.value = value; - }, - ), - ), - ), - ] else ...[ - const SizedBox(height: 6), - ], - Expanded( - child: TabBarView( - controller: _rankController.tabController, - children: _rankController.tabsPageList, - ), - ), - ], + Expanded( + child: TabBarView( + controller: _rankController.tabController, + children: _rankController.tabsPageList, + ), ), ], ), diff --git a/lib/pages/video/detail/view.dart b/lib/pages/video/detail/view.dart index 02a0bbe1..beb9dca1 100644 --- a/lib/pages/video/detail/view.dart +++ b/lib/pages/video/detail/view.dart @@ -4,6 +4,7 @@ import 'dart:ui'; import 'package:extended_nested_scroll_view/extended_nested_scroll_view.dart'; import 'package:floating/floating.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:flutter_svg/svg.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart';