mod: remove gradient bg

This commit is contained in:
bggRGjQaUbCoE
2024-09-01 18:22:22 +08:00
parent 280f690f8b
commit d117119890
4 changed files with 71 additions and 145 deletions

View File

@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
@@ -29,7 +28,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
late List defaultTabs;
late List<String> tabbarSort;
RxString defaultSearch = ''.obs;
late bool enableGradientBg;
late bool useSideBar;
@override
@@ -43,8 +41,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
if (setting.get(SettingBoxKey.enableSearchWord, defaultValue: true)) {
searchDefault();
}
enableGradientBg =
setting.get(SettingBoxKey.enableGradientBg, defaultValue: false);
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
// 进行tabs配置
setTabConfig();
@@ -98,22 +94,6 @@ class HomeController extends GetxController with GetTickerProviderStateMixin {
length: tabs.length,
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

View File

@@ -5,7 +5,6 @@ import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:PiliPalaX/common/widgets/network_img_layer.dart';
import 'package:PiliPalaX/utils/feed_back.dart';
import '../../utils/storage.dart';
import './controller.dart';
class HomePage extends StatefulWidget {
@@ -33,30 +32,15 @@ class _HomePageState extends State<HomePage>
@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,
// ));
// }
Brightness currentBrightness = MediaQuery.of(context).platformBrightness;
// 设置状态栏图标的亮度
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarIconBrightness: currentBrightness == Brightness.light
? Brightness.dark
: Brightness.light,
));
return Scaffold(
extendBody: true,
// 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,
),
),
appBar: AppBar(toolbarHeight: 0, elevation: 0),
body: Column(
children: [
if (!_homeController.useSideBar)
@@ -67,9 +51,7 @@ class _HomePageState extends State<HomePage>
ctr: _homeController,
),
if (_homeController.tabs.length > 1) ...[
if (_homeController.enableGradientBg) ...[
const CustomTabs(),
] else ...[
...[
const SizedBox(height: 4),
SizedBox(
width: double.infinity,

View File

@@ -2,7 +2,6 @@ import 'dart:async';
import 'dart:io';
import 'package:flutter/services.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:hive/hive.dart';

View File

@@ -29,7 +29,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
Box setting = GStorage.setting;
late bool enableMYBar;
late bool useSideBar;
late bool enableGradientBg;
@override
void initState() {
@@ -39,8 +38,6 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
PageController(initialPage: _mainController.selectedIndex);
enableMYBar = setting.get(SettingBoxKey.enableMYBar, defaultValue: true);
useSideBar = setting.get(SettingBoxKey.useSideBar, defaultValue: false);
enableGradientBg =
setting.get(SettingBoxKey.enableGradientBg, defaultValue: false);
}
void setIndex(int value) async {
@@ -114,38 +111,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
},
child: Scaffold(
extendBody: true,
body: Stack(children: [
// gradient background
if (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.6),
Theme.of(context)
.colorScheme
.primaryContainer
.withOpacity(0.6),
Theme.of(context).colorScheme.surface
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
stops: const [0.1, 0.4, 0.7]),
),
),
),
),
],
Row(
body: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (useSideBar) ...[
@@ -209,8 +175,7 @@ class _MainAppState extends State<MainApp> with SingleTickerProviderStateMixin {
),
if (useSideBar) SizedBox(width: context.width * 0.004),
],
)
]),
),
bottomNavigationBar: useSideBar
? null
: StreamBuilder(