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 {
|
class SliverGridViewWithFixedItemHeight extends StatelessWidget {
|
||||||
const SliverGridViewWithFixedItemHeight(
|
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;
|
final SliverChildDelegate delegate;
|
||||||
|
|
||||||
@@ -62,7 +65,8 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
|||||||
@override
|
@override
|
||||||
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
||||||
if (oldDelegate is! SliverGridDelegateWithFixedHeight) return true;
|
if (oldDelegate is! SliverGridDelegateWithFixedHeight) return true;
|
||||||
if (oldDelegate.maxCrossAxisExtent != maxCrossAxisExtent || oldDelegate.itemHeight != itemHeight) {
|
if (oldDelegate.maxCrossAxisExtent != maxCrossAxisExtent ||
|
||||||
|
oldDelegate.itemHeight != itemHeight) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -70,28 +74,29 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class SliverGridDelegateWithComics extends SliverGridDelegate {
|
class SliverGridDelegateWithComics extends SliverGridDelegate {
|
||||||
SliverGridDelegateWithComics([this.scale]);
|
SliverGridDelegateWithComics();
|
||||||
|
|
||||||
final bool useBriefMode = appdata.settings['comicDisplayMode'] == 'brief';
|
final bool useBriefMode = appdata.settings['comicDisplayMode'] == 'brief';
|
||||||
|
|
||||||
final double? scale;
|
final double scale = (appdata.settings['comicTileScale'] as num).toDouble();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
SliverGridLayout getLayout(SliverConstraints constraints) {
|
SliverGridLayout getLayout(SliverConstraints constraints) {
|
||||||
if (useBriefMode) {
|
if (useBriefMode) {
|
||||||
return getBriefModeLayout(
|
return getBriefModeLayout(
|
||||||
constraints,
|
constraints,
|
||||||
scale ?? (appdata.settings['comicTileScale'] as num).toDouble(),
|
scale,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return getDetailedModeLayout(
|
return getDetailedModeLayout(
|
||||||
constraints,
|
constraints,
|
||||||
scale ?? (appdata.settings['comicTileScale'] as num).toDouble(),
|
scale,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SliverGridLayout getDetailedModeLayout(SliverConstraints constraints, double scale) {
|
SliverGridLayout getDetailedModeLayout(
|
||||||
|
SliverConstraints constraints, double scale) {
|
||||||
const minCrossAxisExtent = 360;
|
const minCrossAxisExtent = 360;
|
||||||
final itemHeight = 152 * scale;
|
final itemHeight = 152 * scale;
|
||||||
final width = constraints.crossAxisExtent;
|
final width = constraints.crossAxisExtent;
|
||||||
@@ -106,11 +111,14 @@ class SliverGridDelegateWithComics extends SliverGridDelegate {
|
|||||||
reverseCrossAxis: false);
|
reverseCrossAxis: false);
|
||||||
}
|
}
|
||||||
|
|
||||||
SliverGridLayout getBriefModeLayout(SliverConstraints constraints, double scale) {
|
SliverGridLayout getBriefModeLayout(
|
||||||
|
SliverConstraints constraints, double scale) {
|
||||||
final maxCrossAxisExtent = 192.0 * scale;
|
final maxCrossAxisExtent = 192.0 * scale;
|
||||||
const childAspectRatio = 0.64;
|
const childAspectRatio = 0.64;
|
||||||
const crossAxisSpacing = 0.0;
|
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
|
// Ensure a minimum count of 1, can be zero and result in an infinite extent
|
||||||
// below when the window size is 0.
|
// below when the window size is 0.
|
||||||
crossAxisCount = math.max(1, crossAxisCount);
|
crossAxisCount = math.max(1, crossAxisCount);
|
||||||
@@ -133,7 +141,8 @@ class SliverGridDelegateWithComics extends SliverGridDelegate {
|
|||||||
@override
|
@override
|
||||||
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
||||||
if (oldDelegate is! SliverGridDelegateWithComics) return true;
|
if (oldDelegate is! SliverGridDelegateWithComics) return true;
|
||||||
if (oldDelegate.scale != scale || oldDelegate.useBriefMode != useBriefMode) {
|
if (oldDelegate.scale != scale ||
|
||||||
|
oldDelegate.useBriefMode != useBriefMode) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -977,14 +977,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.7.3"
|
version: "0.7.3"
|
||||||
text_scroll:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: text_scroll
|
|
||||||
sha256: "7869d86a6fdd725dee56bdd150216a99f0372b82fbfcac319214dbd5f36e1908"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "0.2.0"
|
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@@ -72,7 +72,6 @@ dependencies:
|
|||||||
shimmer_animation: ^2.1.0
|
shimmer_animation: ^2.1.0
|
||||||
flutter_memory_info: ^0.0.1
|
flutter_memory_info: ^0.0.1
|
||||||
syntax_highlight: ^0.4.0
|
syntax_highlight: ^0.4.0
|
||||||
text_scroll: ^0.2.0
|
|
||||||
flutter_7zip:
|
flutter_7zip:
|
||||||
git:
|
git:
|
||||||
url: https://github.com/wgh136/flutter_7zip
|
url: https://github.com/wgh136/flutter_7zip
|
||||||
|
Reference in New Issue
Block a user