mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-29 12:38:34 +00:00
@@ -54,3 +54,11 @@ extension StringExt on String {
|
||||
extension boolExt on bool {
|
||||
bool get not => !this;
|
||||
}
|
||||
|
||||
extension BuildContextExt on BuildContext {
|
||||
Color get vipColor {
|
||||
return Theme.of(this).brightness == Brightness.light
|
||||
? const Color(0xFFFF6699)
|
||||
: const Color(0xFFD44E7D);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class GlobalData {
|
||||
int imgQuality = 10;
|
||||
|
||||
int themeMode = 2;
|
||||
// int themeMode = 2;
|
||||
|
||||
bool grpcReply = true;
|
||||
|
||||
|
||||
@@ -125,21 +125,24 @@ class GStorage {
|
||||
static MemberTabType get memberTab => MemberTabType
|
||||
.values[setting.get(SettingBoxKey.memberTab, defaultValue: 0)];
|
||||
|
||||
static int get themeType =>
|
||||
setting.get(SettingBoxKey.themeMode, defaultValue: ThemeType.system.code);
|
||||
|
||||
static ThemeMode get themeMode {
|
||||
return switch (GlobalData().themeMode) {
|
||||
return switch (themeType) {
|
||||
0 => ThemeMode.light,
|
||||
1 => ThemeMode.dark,
|
||||
_ => ThemeMode.system
|
||||
};
|
||||
}
|
||||
|
||||
static Brightness get brightness {
|
||||
return switch (GlobalData().themeMode) {
|
||||
0 => Brightness.light,
|
||||
1 => Brightness.dark,
|
||||
_ => PlatformDispatcher.instance.platformBrightness
|
||||
};
|
||||
}
|
||||
// static Brightness get brightness {
|
||||
// return switch (_themeMode) {
|
||||
// 0 => Brightness.light,
|
||||
// 1 => Brightness.dark,
|
||||
// _ => PlatformDispatcher.instance.platformBrightness
|
||||
// };
|
||||
// }
|
||||
|
||||
static Future<void> init() async {
|
||||
final Directory dir = await getApplicationSupportDirectory();
|
||||
@@ -176,10 +179,10 @@ class GStorage {
|
||||
SettingBoxKey.defaultPicQa,
|
||||
defaultValue: 10,
|
||||
);
|
||||
GlobalData().themeMode = setting.get(
|
||||
SettingBoxKey.themeMode,
|
||||
defaultValue: ThemeType.system.code,
|
||||
);
|
||||
// GlobalData().themeMode = setting.get(
|
||||
// SettingBoxKey.themeMode,
|
||||
// defaultValue: ThemeType.system.code,
|
||||
// );
|
||||
GlobalData().grpcReply = grpcReply;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// 工具函数
|
||||
// ignore_for_file: non_constant_identifier_names
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
@@ -13,7 +10,6 @@ import 'package:PiliPalaX/models/bangumi/info.dart';
|
||||
import 'package:PiliPalaX/models/common/search_type.dart';
|
||||
import 'package:PiliPalaX/pages/video/detail/introduction/widgets/group_panel.dart';
|
||||
import 'package:PiliPalaX/utils/feed_back.dart';
|
||||
import 'package:PiliPalaX/utils/storage.dart';
|
||||
import 'package:crypto/crypto.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -369,12 +365,6 @@ class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
static Color get vipColor {
|
||||
return GStorage.brightness == Brightness.light
|
||||
? const Color(0xFFFF6699)
|
||||
: const Color(0xFFD44E7D);
|
||||
}
|
||||
|
||||
static Future<String> getCookiePath() async {
|
||||
final Directory tempDir = await getApplicationSupportDirectory();
|
||||
final String tempPath = "${tempDir.path}/.plpl/";
|
||||
@@ -542,17 +532,17 @@ class Utils {
|
||||
if (formatType == 'detail') {
|
||||
currentYearStr = 'MM-DD hh:mm';
|
||||
lastYearStr = 'YY-MM-DD hh:mm';
|
||||
return CustomStamp_str(
|
||||
return customStampStr(
|
||||
timestamp: timeStamp, date: lastYearStr, toInt: false);
|
||||
} else if (formatType == 'day') {
|
||||
if (distance <= 43200) {
|
||||
return CustomStamp_str(
|
||||
return customStampStr(
|
||||
timestamp: timeStamp,
|
||||
date: 'hh:mm',
|
||||
toInt: true,
|
||||
);
|
||||
}
|
||||
return CustomStamp_str(
|
||||
return customStampStr(
|
||||
timestamp: timeStamp,
|
||||
date: 'YY-MM-DD',
|
||||
toInt: true,
|
||||
@@ -566,16 +556,16 @@ class Utils {
|
||||
return '${(distance / 60 / 60).floor()}小时前';
|
||||
} else if (DateTime.fromMillisecondsSinceEpoch(time * 1000).year ==
|
||||
DateTime.fromMillisecondsSinceEpoch(timeStamp * 1000).year) {
|
||||
return CustomStamp_str(
|
||||
return customStampStr(
|
||||
timestamp: timeStamp, date: currentYearStr, toInt: false);
|
||||
} else {
|
||||
return CustomStamp_str(
|
||||
return customStampStr(
|
||||
timestamp: timeStamp, date: lastYearStr, toInt: false);
|
||||
}
|
||||
}
|
||||
|
||||
// 时间戳转时间
|
||||
static String CustomStamp_str({
|
||||
static String customStampStr({
|
||||
int? timestamp, // 为空则显示当前时间
|
||||
String? date, // 显示格式,比如:'YY年MM月DD日 hh:mm:ss'
|
||||
bool toInt = true, // 去除0开头
|
||||
@@ -587,8 +577,11 @@ class Utils {
|
||||
dynamic dateArr = timeStr.split(' ')[0];
|
||||
dynamic timeArr = timeStr.split(' ')[1];
|
||||
|
||||
// ignore: non_constant_identifier_names
|
||||
String YY = dateArr.split('-')[0];
|
||||
// ignore: non_constant_identifier_names
|
||||
String MM = dateArr.split('-')[1];
|
||||
// ignore: non_constant_identifier_names
|
||||
String DD = dateArr.split('-')[2];
|
||||
|
||||
String hh = timeArr.split(':')[0];
|
||||
|
||||
Reference in New Issue
Block a user