mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
mod: remove gradient bg
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:math';
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -29,7 +28,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
|||||||
late List defaultTabs;
|
late List defaultTabs;
|
||||||
late List<String> tabbarSort;
|
late List<String> tabbarSort;
|
||||||
RxString defaultSearch = ''.obs;
|
RxString defaultSearch = ''.obs;
|
||||||
late bool enableGradientBg;
|
|
||||||
late bool useSideBar;
|
late bool useSideBar;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -43,8 +41,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
|||||||
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
|
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
|
||||||
searchDefault();
|
searchDefault();
|
||||||
}
|
}
|
||||||
enableGradientBg =
|
|
||||||
setting.get(SettingBoxKey.enableGradientBg, defaultValue: false);
|
|
||||||
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
|
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
|
||||||
// 进行tabs配置
|
// 进行tabs配置
|
||||||
setTabConfig();
|
setTabConfig();
|
||||||
@@ -98,22 +94,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
|
|||||||
length: tabs.length,
|
length: tabs.length,
|
||||||
vsync: this,
|
vsync: this,
|
||||||
);
|
);
|
||||||
// 监听 tabController 切换
|
|
||||||
if (enableGradientBg) {
|
|
||||||
tabController.animation!.addListener(() {
|
|
||||||
if (tabController.indexIsChanging) {
|
|
||||||
if (initialIndex.value != tabController.index) {
|
|
||||||
initialIndex.value = tabController.index;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
final int temp = tabController.animation!.value.round();
|
|
||||||
if (initialIndex.value != temp) {
|
|
||||||
initialIndex.value = temp;
|
|
||||||
tabController.index = initialIndex.value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
|
||||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||||
import '../../utils/storage.dart';
|
|
||||||
import './controller.dart';
|
import './controller.dart';
|
||||||
|
|
||||||
class HomePage extends StatefulWidget {
|
class HomePage extends StatefulWidget {
|
||||||
@@ -33,30 +32,15 @@ class _HomePageState extends State<HomePage>
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
// Brightness currentBrightness = MediaQuery.of(context).platformBrightness;
|
Brightness currentBrightness = MediaQuery.of(context).platformBrightness;
|
||||||
// // 设置状态栏图标的亮度
|
// 设置状态栏图标的亮度
|
||||||
// if (_homeController.enableGradientBg) {
|
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
||||||
// SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
|
statusBarIconBrightness: currentBrightness == Brightness.light
|
||||||
// statusBarIconBrightness: currentBrightness == Brightness.light
|
? Brightness.dark
|
||||||
// ? Brightness.dark
|
: Brightness.light,
|
||||||
// : Brightness.light,
|
));
|
||||||
// ));
|
|
||||||
// }
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBody: true,
|
appBar: AppBar(toolbarHeight: 0, elevation: 0),
|
||||||
// extendBodyBehindAppBar: true,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
appBar: AppBar(
|
|
||||||
toolbarHeight: 0,
|
|
||||||
elevation: 0,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
systemOverlayStyle: SystemUiOverlayStyle(
|
|
||||||
statusBarIconBrightness:
|
|
||||||
Theme.of(context).brightness == Brightness.dark
|
|
||||||
? Brightness.light
|
|
||||||
: Brightness.dark,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
if (!_homeController.useSideBar)
|
if (!_homeController.useSideBar)
|
||||||
@@ -67,9 +51,7 @@ class _HomePageState extends State<HomePage>
|
|||||||
ctr: _homeController,
|
ctr: _homeController,
|
||||||
),
|
),
|
||||||
if (_homeController.tabs.length > 1) ...[
|
if (_homeController.tabs.length > 1) ...[
|
||||||
if (_homeController.enableGradientBg) ...[
|
...[
|
||||||
const CustomTabs(),
|
|
||||||
] else ...[
|
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
Box setting = GStorage.setting;
|
Box setting = GStorage.setting;
|
||||||
late bool enableMYBar;
|
late bool enableMYBar;
|
||||||
late bool useSideBar;
|
late bool useSideBar;
|
||||||
late bool enableGradientBg;
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
@@ -39,8 +38,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
PageController(initialPage: _mainController.selectedIndex);
|
PageController(initialPage: _mainController.selectedIndex);
|
||||||
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
|
||||||
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
|
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
|
||||||
enableGradientBg =
|
|
||||||
setting.get(SettingBoxKey.enableGradientBg, defaultValue: false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setIndex(int value) async {
|
void setIndex(int value) async {
|
||||||
@@ -114,103 +111,71 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
|
|||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
extendBody: true,
|
extendBody: true,
|
||||||
body: Stack(children: [
|
body: Row(
|
||||||
// gradient background
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
if (enableGradientBg) ...[
|
children: [
|
||||||
Align(
|
if (useSideBar) ...[
|
||||||
alignment: Alignment.topLeft,
|
SizedBox(
|
||||||
child: Opacity(
|
width: context.width * 0.0387 +
|
||||||
opacity: 0.6,
|
36.801 +
|
||||||
child: Container(
|
MediaQuery.of(context).padding.left,
|
||||||
width: MediaQuery.of(context).size.width,
|
child: NavigationRail(
|
||||||
height: MediaQuery.of(context).size.height,
|
groupAlignment: 1,
|
||||||
decoration: BoxDecoration(
|
minWidth: context.width * 0.0286 + 28.56,
|
||||||
gradient: LinearGradient(
|
backgroundColor: Colors.transparent,
|
||||||
colors: [
|
selectedIndex: _mainController.selectedIndex,
|
||||||
Theme.of(context)
|
onDestinationSelected: (value) => setIndex(value),
|
||||||
.colorScheme
|
labelType: NavigationRailLabelType.none,
|
||||||
.primary
|
leading: UserAndSearchVertical(ctr: _homeController),
|
||||||
.withOpacity(0.6),
|
destinations: _mainController.navigationBars
|
||||||
Theme.of(context)
|
.map((e) => NavigationRailDestination(
|
||||||
.colorScheme
|
icon: Badge(
|
||||||
.primaryContainer
|
label: _mainController.dynamicBadgeType ==
|
||||||
.withOpacity(0.6),
|
DynamicBadgeMode.number
|
||||||
Theme.of(context).colorScheme.surface
|
? Text(e['count'].toString())
|
||||||
],
|
: null,
|
||||||
begin: Alignment.topLeft,
|
padding:
|
||||||
end: Alignment.bottomRight,
|
const EdgeInsets.symmetric(horizontal: 4),
|
||||||
stops: const [0.1, 0.4, 0.7]),
|
isLabelVisible:
|
||||||
),
|
_mainController.dynamicBadgeType !=
|
||||||
),
|
DynamicBadgeMode.hidden &&
|
||||||
|
e['count'] > 0,
|
||||||
|
child: e['icon'],
|
||||||
|
backgroundColor:
|
||||||
|
Theme.of(context).colorScheme.primary,
|
||||||
|
textColor: Theme.of(context)
|
||||||
|
.colorScheme
|
||||||
|
.onInverseSurface,
|
||||||
|
),
|
||||||
|
selectedIcon: e['selectIcon'],
|
||||||
|
label: Text(e['label']),
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
vertical: 0.01 * context.height),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
trailing: SizedBox(height: 0.1 * context.height),
|
||||||
|
)),
|
||||||
|
],
|
||||||
|
VerticalDivider(
|
||||||
|
width: 1,
|
||||||
|
indent: MediaQuery.of(context).padding.top,
|
||||||
|
endIndent: MediaQuery.of(context).padding.bottom,
|
||||||
|
color: Theme.of(context).colorScheme.outline.withOpacity(0.06),
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: PageView(
|
||||||
|
physics: const NeverScrollableScrollPhysics(),
|
||||||
|
controller: _mainController.pageController,
|
||||||
|
onPageChanged: (index) {
|
||||||
|
_mainController.selectedIndex = index;
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
children: _mainController.pages,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
if (useSideBar) SizedBox(width: context.width * 0.004),
|
||||||
],
|
],
|
||||||
Row(
|
),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
if (useSideBar) ...[
|
|
||||||
SizedBox(
|
|
||||||
width: context.width * 0.0387 +
|
|
||||||
36.801 +
|
|
||||||
MediaQuery.of(context).padding.left,
|
|
||||||
child: NavigationRail(
|
|
||||||
groupAlignment: 1,
|
|
||||||
minWidth: context.width * 0.0286 + 28.56,
|
|
||||||
backgroundColor: Colors.transparent,
|
|
||||||
selectedIndex: _mainController.selectedIndex,
|
|
||||||
onDestinationSelected: (value) => setIndex(value),
|
|
||||||
labelType: NavigationRailLabelType.none,
|
|
||||||
leading: UserAndSearchVertical(ctr: _homeController),
|
|
||||||
destinations: _mainController.navigationBars
|
|
||||||
.map((e) => NavigationRailDestination(
|
|
||||||
icon: Badge(
|
|
||||||
label: _mainController.dynamicBadgeType ==
|
|
||||||
DynamicBadgeMode.number
|
|
||||||
? Text(e['count'].toString())
|
|
||||||
: null,
|
|
||||||
padding:
|
|
||||||
const EdgeInsets.symmetric(horizontal: 4),
|
|
||||||
isLabelVisible:
|
|
||||||
_mainController.dynamicBadgeType !=
|
|
||||||
DynamicBadgeMode.hidden &&
|
|
||||||
e['count'] > 0,
|
|
||||||
child: e['icon'],
|
|
||||||
backgroundColor:
|
|
||||||
Theme.of(context).colorScheme.primary,
|
|
||||||
textColor: Theme.of(context)
|
|
||||||
.colorScheme
|
|
||||||
.onInverseSurface,
|
|
||||||
),
|
|
||||||
selectedIcon: e['selectIcon'],
|
|
||||||
label: Text(e['label']),
|
|
||||||
padding: EdgeInsets.symmetric(
|
|
||||||
vertical: 0.01 * context.height),
|
|
||||||
))
|
|
||||||
.toList(),
|
|
||||||
trailing: SizedBox(height: 0.1 * context.height),
|
|
||||||
)),
|
|
||||||
],
|
|
||||||
VerticalDivider(
|
|
||||||
width: 1,
|
|
||||||
indent: MediaQuery.of(context).padding.top,
|
|
||||||
endIndent: MediaQuery.of(context).padding.bottom,
|
|
||||||
color: Theme.of(context).colorScheme.outline.withOpacity(0.06),
|
|
||||||
),
|
|
||||||
Expanded(
|
|
||||||
child: PageView(
|
|
||||||
physics: const NeverScrollableScrollPhysics(),
|
|
||||||
controller: _mainController.pageController,
|
|
||||||
onPageChanged: (index) {
|
|
||||||
_mainController.selectedIndex = index;
|
|
||||||
setState(() {});
|
|
||||||
},
|
|
||||||
children: _mainController.pages,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (useSideBar) SizedBox(width: context.width * 0.004),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
bottomNavigationBar: useSideBar
|
bottomNavigationBar: useSideBar
|
||||||
? null
|
? null
|
||||||
: StreamBuilder(
|
: StreamBuilder(
|
||||||
|
|||||||
Reference in New Issue
Block a user