mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-06 09:13:48 +08:00
opt: item
chore: clean up widgets Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -1,27 +1,20 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:PiliPlus/common/constants.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'storage.dart';
|
||||
|
||||
class Grid {
|
||||
static double mediumCardWidth = GStorage.mediumCardWidth;
|
||||
static double smallCardWidth = GStorage.smallCardWidth;
|
||||
//
|
||||
// static double calculateActualWidth(BuildContext context, double maxCrossAxisExtent, double crossAxisSpacing, {double? screenWidthOffset}) {
|
||||
// double screenWidth = MediaQuery.of(context).size.width;
|
||||
// if (screenWidthOffset != null) {
|
||||
// screenWidth -= screenWidthOffset;
|
||||
// }
|
||||
// if (GStorage.setting.get(SettingBoxKey.useSideBar, defaultValue: false) as bool) {
|
||||
// screenWidth -= 55;
|
||||
// }
|
||||
// int columnCount = ((screenWidth - crossAxisSpacing) / (maxCrossAxisExtent + crossAxisSpacing)).ceil();
|
||||
// if (columnCount < 1){
|
||||
// columnCount = 1;
|
||||
// }
|
||||
// double columnWidth = (screenWidth - crossAxisSpacing) ~/ columnCount - crossAxisSpacing;
|
||||
// return columnWidth;
|
||||
// }
|
||||
|
||||
static videoCardHDelegate(context, {double minHeight = 90}) =>
|
||||
SliverGridDelegateWithExtentAndRatio(
|
||||
mainAxisSpacing: 2,
|
||||
maxCrossAxisExtent: Grid.smallCardWidth * 2,
|
||||
childAspectRatio: StyleString.aspectRatio * 2.4,
|
||||
minHeight: MediaQuery.textScalerOf(context).scale(minHeight),
|
||||
);
|
||||
}
|
||||
|
||||
class SliverGridDelegateWithExtentAndRatio extends SliverGridDelegate {
|
||||
@@ -37,10 +30,14 @@ class SliverGridDelegateWithExtentAndRatio extends SliverGridDelegate {
|
||||
this.crossAxisSpacing = 0.0,
|
||||
this.childAspectRatio = 1.0,
|
||||
this.mainAxisExtent = 0.0,
|
||||
this.minHeight = 0.0,
|
||||
}) : assert(maxCrossAxisExtent > 0),
|
||||
assert(mainAxisSpacing >= 0),
|
||||
assert(crossAxisSpacing >= 0),
|
||||
assert(childAspectRatio > 0);
|
||||
assert(childAspectRatio > 0),
|
||||
assert(minHeight >= 0);
|
||||
|
||||
final double minHeight;
|
||||
|
||||
/// The maximum extent of tiles in the cross axis.
|
||||
///
|
||||
@@ -91,8 +88,8 @@ class SliverGridDelegateWithExtentAndRatio extends SliverGridDelegate {
|
||||
constraints.crossAxisExtent - crossAxisSpacing * (crossAxisCount - 1),
|
||||
);
|
||||
final double childCrossAxisExtent = usableCrossAxisExtent / crossAxisCount;
|
||||
final double childMainAxisExtent =
|
||||
childCrossAxisExtent / childAspectRatio + mainAxisExtent;
|
||||
final double childMainAxisExtent = max(
|
||||
minHeight, childCrossAxisExtent / childAspectRatio + mainAxisExtent);
|
||||
return SliverGridRegularTileLayout(
|
||||
crossAxisCount: crossAxisCount,
|
||||
mainAxisStride: childMainAxisExtent + mainAxisSpacing,
|
||||
|
||||
@@ -17,7 +17,7 @@ import 'package:PiliPlus/models/user/danmaku_rule_adapter.dart';
|
||||
import 'package:PiliPlus/models/video/play/CDN.dart';
|
||||
import 'package:PiliPlus/models/video/play/quality.dart';
|
||||
import 'package:PiliPlus/models/video/play/subtitle.dart';
|
||||
import 'package:PiliPlus/pages/member/new/controller.dart' show MemberTabType;
|
||||
import 'package:PiliPlus/pages/member/controller.dart' show MemberTabType;
|
||||
import 'package:PiliPlus/pages/mine/index.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/bottom_progress_behavior.dart';
|
||||
import 'package:PiliPlus/plugin/pl_player/models/fullscreen_mode.dart';
|
||||
@@ -123,9 +123,6 @@ class GStorage {
|
||||
static int get previewQ =>
|
||||
setting.get(SettingBoxKey.previewQuality, defaultValue: 100);
|
||||
|
||||
static double get mediumCardWidth =>
|
||||
setting.get(SettingBoxKey.mediumCardWidth, defaultValue: 280.0);
|
||||
|
||||
static double get smallCardWidth =>
|
||||
setting.get(SettingBoxKey.smallCardWidth, defaultValue: 240.0);
|
||||
|
||||
@@ -807,7 +804,6 @@ class SettingBoxKey {
|
||||
customColor = 'customColor', // 自定义主题色
|
||||
enableSingleRow = 'enableSingleRow', // 首页单列
|
||||
displayMode = 'displayMode',
|
||||
mediumCardWidth = 'mediumCardWidth', // 首页列最大宽度(dp)
|
||||
smallCardWidth = 'smallCardWidth',
|
||||
videoPlayerRemoveSafeArea = 'videoPlayerRemoveSafeArea', // 视频播放器移除安全边距
|
||||
// videoPlayerShowStatusBarBackgroundColor =
|
||||
|
||||
Reference in New Issue
Block a user