feat: pure black theme

Closes #254

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-02-14 16:10:10 +08:00
parent 064c8a9dfe
commit 6c3062ba2d
25 changed files with 361 additions and 317 deletions

View File

@@ -275,9 +275,10 @@ class _ListSheetContentState extends State<ListSheetContent>
@override
Widget build(BuildContext context) {
return Container(
height: Utils.getSheetHeight(context),
return Material(
color: Theme.of(context).colorScheme.surface,
child: SizedBox(
height: Utils.getSheetHeight(context),
child: Column(
children: [
Container(
@@ -392,7 +393,8 @@ class _ListSheetContentState extends State<ListSheetContent>
: MdiIcons.sortNumericDescending,
onPressed: () {
setState(() {
reverse[_ctr?.index ?? 0] = !reverse[_ctr?.index ?? 0];
reverse[_ctr?.index ?? 0] =
!reverse[_ctr?.index ?? 0];
});
},
),
@@ -411,8 +413,7 @@ class _ListSheetContentState extends State<ListSheetContent>
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
if (_isList)
Material(
child: TabBar(
TabBar(
controller: _ctr,
padding: const EdgeInsets.only(right: 60),
isScrollable: true,
@@ -422,7 +423,6 @@ class _ListSheetContentState extends State<ListSheetContent>
dividerHeight: 1,
dividerColor: Theme.of(context).dividerColor.withOpacity(0.1),
),
),
Expanded(
child: _isList
? TabBarView(
@@ -437,6 +437,7 @@ class _ListSheetContentState extends State<ListSheetContent>
),
],
),
),
);
}
@@ -464,8 +465,7 @@ class _ListSheetContentState extends State<ListSheetContent>
},
);
Widget _buildBody(i, episodes) => Material(
child: ScrollablePositionedList.separated(
Widget _buildBody(i, episodes) => ScrollablePositionedList.separated(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).padding.bottom + 80,
),
@@ -488,6 +488,5 @@ class _ListSheetContentState extends State<ListSheetContent>
height: 1,
color: Theme.of(context).dividerColor.withOpacity(0.1),
),
),
);
}

View File

@@ -6,13 +6,14 @@ Widget statDanMu({
String? theme,
dynamic danmu,
String? size,
Color? textColor,
}) {
Map<String, Color> colorObject = {
'white': Colors.white,
'gray': Theme.of(context).colorScheme.outline.withOpacity(0.8),
'black': Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
};
Color color = colorObject[theme]!;
Color color = textColor ?? colorObject[theme]!;
return Row(
children: [
Icon(

View File

@@ -7,13 +7,14 @@ Widget statView({
dynamic view,
String? size,
String? goto,
Color? textColor,
}) {
Map<String, Color> colorObject = {
'white': Colors.white,
'gray': Theme.of(context).colorScheme.outline.withOpacity(0.8),
'black': Theme.of(context).colorScheme.onSurface.withOpacity(0.7),
};
Color color = colorObject[theme]!;
Color color = textColor ?? colorObject[theme]!;
return Row(
children: [
Icon(

View File

@@ -2,6 +2,7 @@ import 'dart:io';
import 'package:PiliPlus/build_config.dart';
import 'package:PiliPlus/utils/cache_manage.dart';
import 'package:PiliPlus/utils/utils.dart';
import 'package:flex_seed_scheme/flex_seed_scheme.dart';
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
@@ -177,6 +178,7 @@ class MyApp extends StatelessWidget {
// tones: FlexTones.soft(Brightness.dark),
);
}
// 图片缓存
// PaintingBinding.instance.imageCache.maximumSizeBytes = 1000 << 20;
return GetMaterialApp(
@@ -229,7 +231,7 @@ class MyApp extends StatelessWidget {
bool isDark = false,
required FlexSchemeVariant variant,
}) {
return ThemeData(
ThemeData themeData = ThemeData(
colorScheme: colorScheme,
useMaterial3: true,
appBarTheme: AppBarTheme(
@@ -282,6 +284,10 @@ class MyApp extends StatelessWidget {
),
),
);
if (isDark && GStorage.isPureBlackTheme) {
themeData = Utils.darkenTheme(themeData);
}
return themeData;
}
}

View File

@@ -450,6 +450,7 @@ class _BangumiInfoState extends State<BangumiInfo>
return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) {
return Material(
color: Theme.of(context).colorScheme.surface,
child: Padding(
padding: const EdgeInsets.only(top: 1),
child: SizedBox(

View File

@@ -136,7 +136,6 @@ class _DynamicsPageState extends State<DynamicsPage>
super.build(context);
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
appBar: AppBar(
leading: upPanelPosition == UpPanelPosition.rightDrawer
? _createDynamicBtn(false)

View File

@@ -39,7 +39,7 @@ class DynamicPanel extends StatelessWidget {
child: Material(
elevation: 0,
clipBehavior: Clip.hardEdge,
color: Theme.of(context).cardColor.withOpacity(0.5),
color: Colors.transparent,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5),
),

View File

@@ -47,6 +47,7 @@ class _HomePageState extends State<HomePage>
if (_homeController.tabs.length > 1) ...[
const SizedBox(height: 4),
Material(
color: Theme.of(context).colorScheme.surface,
child: SizedBox(
height: 42,
child: TabBar(

View File

@@ -134,7 +134,9 @@ class _MemberPageNewState extends State<MemberPageNew>
);
}
Widget get _buildTab => TabBar(
Widget get _buildTab => Material(
color: Theme.of(context).colorScheme.surface,
child: TabBar(
controller: _userController.tabController,
tabs: _userController.tabs,
onTap: (value) {
@@ -142,6 +144,7 @@ class _MemberPageNewState extends State<MemberPageNew>
_key.currentState?.outerController.animToTop();
}
},
),
);
Widget get _buildBody => SafeArea(
@@ -198,9 +201,7 @@ class _MemberPageNewState extends State<MemberPageNew>
bottom: needTab && (_userController.tab2?.length ?? -1) > 1
? PreferredSize(
preferredSize: Size.fromHeight(48),
child: Material(
child: _buildTab,
),
)
: null,
actions: [

View File

@@ -23,6 +23,7 @@ class HotKeyword extends StatelessWidget {
SizedBox(
width: width! / 2 - 4,
child: Material(
color: Colors.transparent,
borderRadius: BorderRadius.circular(3),
clipBehavior: Clip.hardEdge,
child: InkWell(

View File

@@ -31,9 +31,11 @@ class SearchText extends StatelessWidget {
onTap: () {
onTap?.call(text);
},
onLongPress: () {
onLongPress?.call(text);
},
onLongPress: onLongPress != null
? () {
onLongPress!(text);
}
: null,
borderRadius: BorderRadius.circular(6),
child: Padding(
padding: padding ??

View File

@@ -294,7 +294,6 @@ class ArticlePanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongPress: (_) {},
bgColor: item['value'] == currentOrderFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,
@@ -328,7 +327,6 @@ class ArticlePanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongPress: (_) {},
bgColor: item['value'] == currentZoneFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,

View File

@@ -222,7 +222,6 @@ class UserPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongPress: (_) {},
bgColor: item['value'] == currentOrderFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,
@@ -256,7 +255,6 @@ class UserPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongPress: (_) {},
bgColor: item['value'] == currentUserTypeFilterval.value
? Theme.of(context).colorScheme.secondaryContainer
: null,

View File

@@ -38,12 +38,15 @@ Widget searchVideoPanel(context, ctr, LoadingState loadingState) {
// spacing: ,
children: [
for (var i in controller.filterList) ...[
CustomFilterChip(
label: i['label'],
type: i['type'],
selectedType: controller.selectedType.value,
callFn: (bool selected) async {
debugPrint('selected: $selected');
SearchText(
fontSize: 13,
text: i['label'],
bgColor: Colors.transparent,
textColor:
controller.selectedType.value == i['type']
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline,
onTap: (value) async {
controller.selectedType.value = i['type'];
ctr.order.value =
i['type'].toString().split('.').last;
@@ -122,51 +125,6 @@ Widget searchVideoPanel(context, ctr, LoadingState loadingState) {
);
}
class CustomFilterChip extends StatelessWidget {
const CustomFilterChip({
this.label,
this.type,
this.selectedType,
this.callFn,
super.key,
});
final String? label;
final ArchiveFilterType? type;
final ArchiveFilterType? selectedType;
final Function? callFn;
@override
Widget build(BuildContext context) {
return SizedBox(
height: 34,
child: FilterChip(
padding: const EdgeInsets.only(left: 8, right: 8),
labelPadding: EdgeInsets.zero,
label: Text(
label!,
style: const TextStyle(fontSize: 13),
),
labelStyle: TextStyle(
color: type == selectedType
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.outline),
selected: type == selectedType,
showCheckmark: false,
shape: ContinuousRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
selectedColor: Colors.transparent,
// backgroundColor:
// Theme.of(context).colorScheme.surfaceVariant.withOpacity(0.5),
backgroundColor: Colors.transparent,
side: BorderSide.none,
onSelected: (bool selected) => callFn?.call(selected),
),
);
}
}
class VideoPanelController extends GetxController {
RxList<Map> filterList = [{}].obs;
Rx<ArchiveFilterType> selectedType = ArchiveFilterType.values.first.obs;
@@ -304,7 +262,6 @@ class VideoPanelController extends GetxController {
}
});
},
onLongPress: (_) {},
bgColor: currentPubTimeFilterval == -1 &&
(isFirst ? customPubBegin : customPubEnd)
? Theme.of(context).colorScheme.secondaryContainer
@@ -380,7 +337,6 @@ class VideoPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongPress: (_) {},
bgColor: item['value'] == currentPubTimeFilterval
? Theme.of(context)
.colorScheme
@@ -431,7 +387,6 @@ class VideoPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongPress: (_) {},
bgColor: item['value'] == currentTimeFilterval
? Theme.of(context)
.colorScheme
@@ -469,7 +424,6 @@ class VideoPanelController extends GetxController {
await ctr.onRefresh();
SmartDialog.dismiss();
},
onLongPress: (_) {},
bgColor: item['value'] == currentZoneFilterval
? Theme.of(context)
.colorScheme

View File

@@ -480,6 +480,18 @@ List<SettingsModel> get styleSettings => [
title: '主题模式',
getSubtitle: () => '当前模式:${GStorage.themeType.description}',
),
SettingsModel(
settingsType: SettingsType.sw1tch,
leading: const Icon(Icons.invert_colors),
title: '纯黑主题',
setKey: SettingBoxKey.isPureBlackTheme,
defaultVal: false,
onChanged: (value) {
if (Theme.of(Get.context!).brightness == Brightness.dark) {
Get.forceAppUpdate();
}
},
),
SettingsModel(
settingsType: SettingsType.normal,
onTap: (setState) => Get.toNamed('/colorSetting'),

View File

@@ -557,6 +557,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
? videoDetail.stat?.view ?? '-'
: videoItem['stat']?.view ?? '-',
size: 'medium',
textColor: t.colorScheme.outline,
),
const SizedBox(width: 10),
statDanMu(
@@ -566,6 +567,7 @@ class _VideoInfoState extends State<VideoInfo> with TickerProviderStateMixin {
? videoDetail.stat?.danmu ?? '-'
: videoItem['stat']?.danmu ?? '-',
size: 'medium',
textColor: t.colorScheme.outline,
),
const SizedBox(width: 10),
Text(

View File

@@ -88,6 +88,7 @@ class _FavPanelState extends State<FavPanel> {
),
Expanded(
child: Material(
color: Theme.of(context).colorScheme.surface,
child: FutureBuilder(
future: _futureBuilderFuture,
builder: (BuildContext context, AsyncSnapshot snapshot) {

View File

@@ -98,6 +98,7 @@ class _GroupPanelState extends State<GroupPanel> {
),
Expanded(
child: Material(
color: Theme.of(context).colorScheme.surface,
child: FutureBuilder(
future: _futureBuilderFuture,
builder: (BuildContext context, AsyncSnapshot snapshot) {

View File

@@ -60,11 +60,9 @@ class _RelatedVideoPanelState extends State<RelatedVideoPanel>
height: MediaQuery.of(context).padding.bottom,
);
} else {
return Material(
child: VideoCardH(
return VideoCardH(
videoItem: loadingState.response[index],
showPubdate: true,
),
);
}
}, childCount: loadingState.response.length + 1),

View File

@@ -134,10 +134,7 @@ class ReplyItem extends StatelessWidget {
indent: 55,
endIndent: 15,
height: 0.3,
color: Theme.of(context)
.colorScheme
.onInverseSurface
.withOpacity(0.5),
color: Theme.of(context).colorScheme.outline.withOpacity(0.08),
)
],
),

View File

@@ -160,8 +160,7 @@ class ReplyItemGrpc extends StatelessWidget {
indent: 55,
endIndent: 15,
height: 0.3,
color:
Theme.of(context).colorScheme.onInverseSurface.withOpacity(0.5),
color: Theme.of(context).colorScheme.outline.withOpacity(0.08),
)
],
);

View File

@@ -1280,7 +1280,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
),
),
child: Material(
child: Row(
children: [
if (tabs.isEmpty)
@@ -1307,8 +1306,7 @@ class _VideoDetailPageState extends State<VideoDetailPage>
'发弹幕',
style: TextStyle(
fontSize: 12,
color:
Theme.of(context).colorScheme.onSurfaceVariant,
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
),
@@ -1349,7 +1347,6 @@ class _VideoDetailPageState extends State<VideoDetailPage>
),
],
),
),
);
}
@@ -1521,7 +1518,10 @@ class _VideoDetailPageState extends State<VideoDetailPage>
height: 1,
indent: 12,
endIndent: 12,
color: Theme.of(context).dividerColor.withOpacity(0.06),
color: Theme.of(context)
.colorScheme
.outline
.withOpacity(0.08),
),
),
),

View File

@@ -97,3 +97,21 @@ extension Unique<E, Id> on List<E> {
return list;
}
}
extension ColorExtension on Color {
Color darken([double amount = .5]) {
assert(amount >= 0 && amount <= 1, 'Amount must be between 0 and 1');
return Color.lerp(this, Colors.black, amount)!;
}
Color blend(Color color, [double fraction = 0.5]) {
assert(fraction >= 0 && fraction <= 1, 'Fraction must be between 0 and 1');
final blendedRed = (red * (1 - fraction) + color.red * fraction).toInt();
final blendedGreen =
(green * (1 - fraction) + color.green * fraction).toInt();
final blendedBlue = (blue * (1 - fraction) + color.blue * fraction).toInt();
final blendedAlpha =
(alpha * (1 - fraction) + color.alpha * fraction).toInt();
return Color.fromARGB(blendedAlpha, blendedRed, blendedGreen, blendedBlue);
}
}

View File

@@ -367,6 +367,9 @@ class GStorage {
static bool get coinWithLike =>
GStorage.setting.get(SettingBoxKey.coinWithLike, defaultValue: false);
static bool get isPureBlackTheme =>
GStorage.setting.get(SettingBoxKey.isPureBlackTheme, defaultValue: false);
static List<double> get dynamicDetailRatio => List<double>.from(setting
.get(SettingBoxKey.dynamicDetailRatio, defaultValue: [60.0, 40.0]));
@@ -599,6 +602,7 @@ class SettingBoxKey {
showDmChart = 'showDmChart',
enableCommAntifraud = 'enableCommAntifraud',
coinWithLike = 'coinWithLike',
isPureBlackTheme = 'isPureBlackTheme',
// Sponsor Block
enableSponsorBlock = 'enableSponsorBlock',

View File

@@ -44,6 +44,56 @@ class Utils {
static const channel = MethodChannel("PiliPlus");
static darkenTheme(ThemeData themeData) {
// return themeData;
Color color = themeData.colorScheme.surfaceContainerHighest.darken(0.7);
return themeData.copyWith(
scaffoldBackgroundColor: Colors.black,
appBarTheme: themeData.appBarTheme.copyWith(
backgroundColor: Colors.black,
),
cardTheme: themeData.cardTheme.copyWith(
color: Colors.black,
),
dialogTheme: themeData.dialogTheme.copyWith(
backgroundColor: color,
),
bottomSheetTheme:
themeData.bottomSheetTheme.copyWith(backgroundColor: color),
bottomNavigationBarTheme:
themeData.bottomNavigationBarTheme.copyWith(backgroundColor: color),
navigationBarTheme:
themeData.navigationBarTheme.copyWith(backgroundColor: color),
navigationRailTheme:
themeData.navigationRailTheme.copyWith(backgroundColor: Colors.black),
colorScheme: themeData.colorScheme.copyWith(
primary: themeData.colorScheme.primary.darken(0.1),
onPrimary: themeData.colorScheme.onPrimary.darken(0.1),
primaryContainer: themeData.colorScheme.primaryContainer.darken(0.1),
onPrimaryContainer:
themeData.colorScheme.onPrimaryContainer.darken(0.1),
inversePrimary: themeData.colorScheme.inversePrimary.darken(0.1),
secondary: themeData.colorScheme.secondary.darken(0.1),
onSecondary: themeData.colorScheme.onSecondary.darken(0.1),
secondaryContainer:
themeData.colorScheme.secondaryContainer.darken(0.1),
onSecondaryContainer:
themeData.colorScheme.onSecondaryContainer.darken(0.1),
error: themeData.colorScheme.error.darken(0.1),
surface: Colors.black,
onSurface: themeData.colorScheme.onSurface.darken(0.15),
surfaceTint: themeData.colorScheme.surfaceTint.darken(),
inverseSurface: themeData.colorScheme.inverseSurface.darken(),
onInverseSurface: themeData.colorScheme.onInverseSurface.darken(),
surfaceContainer: themeData.colorScheme.surfaceContainer.darken(),
surfaceContainerHigh:
themeData.colorScheme.surfaceContainerHigh.darken(),
surfaceContainerHighest:
themeData.colorScheme.surfaceContainerHighest.darken(0.4),
),
);
}
static void onCopyOrMove({
required BuildContext context,
required bool isCopy,