mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
add loginWithWebview, mixed explore page, app links, html node api;
improve ui
This commit is contained in:
@@ -3,9 +3,9 @@ part of 'components.dart';
|
||||
class SliverGridViewWithFixedItemHeight extends StatelessWidget {
|
||||
const SliverGridViewWithFixedItemHeight(
|
||||
{required this.delegate,
|
||||
required this.maxCrossAxisExtent,
|
||||
required this.itemHeight,
|
||||
super.key});
|
||||
required this.maxCrossAxisExtent,
|
||||
required this.itemHeight,
|
||||
super.key});
|
||||
|
||||
final SliverChildDelegate delegate;
|
||||
|
||||
@@ -16,13 +16,14 @@ class SliverGridViewWithFixedItemHeight extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SliverLayoutBuilder(
|
||||
builder: ((context, constraints) => SliverGrid(
|
||||
delegate: delegate,
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: maxCrossAxisExtent,
|
||||
childAspectRatio:
|
||||
calcChildAspectRatio(constraints.crossAxisExtent)),
|
||||
)));
|
||||
builder: (context, constraints) => SliverGrid(
|
||||
delegate: delegate,
|
||||
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
|
||||
maxCrossAxisExtent: maxCrossAxisExtent,
|
||||
childAspectRatio: calcChildAspectRatio(constraints.crossAxisExtent),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
double calcChildAspectRatio(double width) {
|
||||
@@ -35,7 +36,7 @@ class SliverGridViewWithFixedItemHeight extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
class SliverGridDelegateWithFixedHeight extends SliverGridDelegate{
|
||||
class SliverGridDelegateWithFixedHeight extends SliverGridDelegate {
|
||||
const SliverGridDelegateWithFixedHeight({
|
||||
required this.maxCrossAxisExtent,
|
||||
required this.itemHeight,
|
||||
@@ -58,23 +59,21 @@ class SliverGridDelegateWithFixedHeight extends SliverGridDelegate{
|
||||
crossAxisStride: width / crossItems,
|
||||
childMainAxisExtent: itemHeight,
|
||||
childCrossAxisExtent: width / crossItems,
|
||||
reverseCrossAxis: false
|
||||
);
|
||||
reverseCrossAxis: false);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
||||
if(oldDelegate is! SliverGridDelegateWithFixedHeight) return true;
|
||||
if(oldDelegate.maxCrossAxisExtent != maxCrossAxisExtent
|
||||
|| oldDelegate.itemHeight != itemHeight){
|
||||
if (oldDelegate is! SliverGridDelegateWithFixedHeight) return true;
|
||||
if (oldDelegate.maxCrossAxisExtent != maxCrossAxisExtent ||
|
||||
oldDelegate.itemHeight != itemHeight) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class SliverGridDelegateWithComics extends SliverGridDelegate{
|
||||
class SliverGridDelegateWithComics extends SliverGridDelegate {
|
||||
SliverGridDelegateWithComics([this.useBriefMode = false, this.scale]);
|
||||
|
||||
final bool useBriefMode;
|
||||
@@ -83,14 +82,17 @@ class SliverGridDelegateWithComics extends SliverGridDelegate{
|
||||
|
||||
@override
|
||||
SliverGridLayout getLayout(SliverConstraints constraints) {
|
||||
if(appdata.settings['comicDisplayMode'] == 'brief' || useBriefMode){
|
||||
return getBriefModeLayout(constraints, scale ?? appdata.settings['comicTileScale']);
|
||||
if (appdata.settings['comicDisplayMode'] == 'brief' || useBriefMode) {
|
||||
return getBriefModeLayout(
|
||||
constraints, scale ?? appdata.settings['comicTileScale']);
|
||||
} else {
|
||||
return getDetailedModeLayout(constraints, scale ?? appdata.settings['comicTileScale']);
|
||||
return getDetailedModeLayout(constraints,
|
||||
scale ?? (appdata.settings['comicTileScale'] as num).toDouble());
|
||||
}
|
||||
}
|
||||
|
||||
SliverGridLayout getDetailedModeLayout(SliverConstraints constraints, double scale){
|
||||
SliverGridLayout getDetailedModeLayout(
|
||||
SliverConstraints constraints, double scale) {
|
||||
const minCrossAxisExtent = 360;
|
||||
final itemHeight = 152 * scale;
|
||||
final width = constraints.crossAxisExtent;
|
||||
@@ -102,15 +104,17 @@ class SliverGridDelegateWithComics extends SliverGridDelegate{
|
||||
crossAxisStride: width / crossItems,
|
||||
childMainAxisExtent: itemHeight,
|
||||
childCrossAxisExtent: width / crossItems,
|
||||
reverseCrossAxis: false
|
||||
);
|
||||
reverseCrossAxis: false);
|
||||
}
|
||||
|
||||
SliverGridLayout getBriefModeLayout(SliverConstraints constraints, double scale){
|
||||
SliverGridLayout getBriefModeLayout(
|
||||
SliverConstraints constraints, double scale) {
|
||||
final maxCrossAxisExtent = 192.0 * scale;
|
||||
const childAspectRatio = 0.72;
|
||||
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);
|
||||
@@ -134,4 +138,4 @@ class SliverGridDelegateWithComics extends SliverGridDelegate{
|
||||
bool shouldRelayout(covariant SliverGridDelegate oldDelegate) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -199,7 +199,7 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
int _page = 1;
|
||||
|
||||
int _maxPage = 1;
|
||||
int? _maxPage;
|
||||
|
||||
Future<Res<List<S>>> loadData(int page);
|
||||
|
||||
@@ -211,10 +211,10 @@ abstract class MultiPageLoadingState<T extends StatefulWidget, S extends Object>
|
||||
|
||||
bool get isFirstLoading => _isFirstLoading;
|
||||
|
||||
bool get haveNextPage => _page <= _maxPage;
|
||||
bool get haveNextPage => _maxPage == null || _page <= _maxPage!;
|
||||
|
||||
void nextPage() {
|
||||
if (_page > _maxPage) return;
|
||||
if (_maxPage != null && _page > _maxPage!) return;
|
||||
if (_isLoading) return;
|
||||
_isLoading = true;
|
||||
loadData(_page).then((value) {
|
||||
|
Reference in New Issue
Block a user