mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Remove text_scroll & Improve layout
This commit is contained in:
@@ -2,7 +2,10 @@ part of 'components.dart';
|
||||
|
||||
class SliverGridViewWithFixedItemHeight extends StatelessWidget {
|
||||
const SliverGridViewWithFixedItemHeight(
|
||||
{required this.delegate, required this.maxCrossAxisExtent, required this.itemHeight, super.key});
|
||||
{required this.delegate,
|
||||
required this.maxCrossAxisExtent,
|
||||
required this.itemHeight,
|
||||
super.key});
|
||||
|
||||
final SliverChildDelegate delegate;
|
||||
|
||||
@@ -62,7 +65,8 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
||||
@override
|
||||
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
||||
if (oldDelegate is! SliverGridDelegateWithFixedHeight) return true;
|
||||
if (oldDelegate.maxCrossAxisExtent != maxCrossAxisExtent || oldDelegate.itemHeight != itemHeight) {
|
||||
if (oldDelegate.maxCrossAxisExtent != maxCrossAxisExtent ||
|
||||
oldDelegate.itemHeight != itemHeight) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -70,28 +74,29 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
||||
}
|
||||
|
||||
class SliverGridDelegateWithComics extends SliverGridDelegate {
|
||||
SliverGridDelegateWithComics([this.scale]);
|
||||
SliverGridDelegateWithComics();
|
||||
|
||||
final bool useBriefMode = appdata.settings['comicDisplayMode'] == 'brief';
|
||||
|
||||
final double? scale;
|
||||
final double scale = (appdata.settings['comicTileScale'] as num).toDouble();
|
||||
|
||||
@override
|
||||
SliverGridLayout getLayout(SliverConstraints constraints) {
|
||||
if (useBriefMode) {
|
||||
return getBriefModeLayout(
|
||||
constraints,
|
||||
scale ?? (appdata.settings['comicTileScale'] as num).toDouble(),
|
||||
scale,
|
||||
);
|
||||
} else {
|
||||
return getDetailedModeLayout(
|
||||
constraints,
|
||||
scale ?? (appdata.settings['comicTileScale'] as num).toDouble(),
|
||||
scale,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
SliverGridLayout getDetailedModeLayout(SliverConstraints constraints, double scale) {
|
||||
SliverGridLayout getDetailedModeLayout(
|
||||
SliverConstraints constraints, double scale) {
|
||||
const minCrossAxisExtent = 360;
|
||||
final itemHeight = 152 * scale;
|
||||
final width = constraints.crossAxisExtent;
|
||||
@@ -106,11 +111,14 @@ class SliverGridDelegateWithComics extends SliverGridDelegate {
|
||||
reverseCrossAxis: false);
|
||||
}
|
||||
|
||||
SliverGridLayout getBriefModeLayout(SliverConstraints constraints, double scale) {
|
||||
SliverGridLayout getBriefModeLayout(
|
||||
SliverConstraints constraints, double scale) {
|
||||
final maxCrossAxisExtent = 192.0 * scale;
|
||||
const childAspectRatio = 0.64;
|
||||
const crossAxisSpacing = 0.0;
|
||||
int crossAxisCount = (constraints.crossAxisExtent / (maxCrossAxisExtent + crossAxisSpacing)).ceil();
|
||||
int crossAxisCount =
|
||||
(constraints.crossAxisExtent / (maxCrossAxisExtent + crossAxisSpacing))
|
||||
.ceil();
|
||||
// Ensure a minimum count of 1, can be zero and result in an infinite extent
|
||||
// below when the window size is 0.
|
||||
crossAxisCount = math.max(1, crossAxisCount);
|
||||
@@ -133,7 +141,8 @@ class SliverGridDelegateWithComics extends SliverGridDelegate {
|
||||
@override
|
||||
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
||||
if (oldDelegate is! SliverGridDelegateWithComics) return true;
|
||||
if (oldDelegate.scale != scale || oldDelegate.useBriefMode != useBriefMode) {
|
||||
if (oldDelegate.scale != scale ||
|
||||
oldDelegate.useBriefMode != useBriefMode) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
Reference in New Issue
Block a user