mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 07:47:24 +00:00
Added a 'Back to Top' button. Close #276
This commit is contained in:
@@ -75,6 +75,8 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
|
|
||||||
bool isDownloaded = false;
|
bool isDownloaded = false;
|
||||||
|
|
||||||
|
bool showFAB = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReadEnd() {
|
void onReadEnd() {
|
||||||
history ??=
|
history ??=
|
||||||
@@ -114,7 +116,15 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
ComicDetails get comic => data!;
|
ComicDetails get comic => data!;
|
||||||
|
|
||||||
void onScroll() {
|
void onScroll() {
|
||||||
if (scrollController.offset > 100) {
|
var offset = scrollController.position.pixels -
|
||||||
|
scrollController.position.minScrollExtent;
|
||||||
|
var showFAB = offset > 0;
|
||||||
|
if (showFAB != this.showFAB) {
|
||||||
|
setState(() {
|
||||||
|
this.showFAB = showFAB;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (offset > 100) {
|
||||||
if (!showAppbarTitle) {
|
if (!showAppbarTitle) {
|
||||||
setState(() {
|
setState(() {
|
||||||
showAppbarTitle = true;
|
showAppbarTitle = true;
|
||||||
@@ -133,7 +143,18 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget buildContent(BuildContext context, ComicDetails data) {
|
Widget buildContent(BuildContext context, ComicDetails data) {
|
||||||
return SmoothCustomScrollView(
|
return Scaffold(
|
||||||
|
floatingActionButton: showFAB
|
||||||
|
? FloatingActionButton(
|
||||||
|
onPressed: () {
|
||||||
|
scrollController.animateTo(0,
|
||||||
|
duration: const Duration(milliseconds: 200),
|
||||||
|
curve: Curves.ease);
|
||||||
|
},
|
||||||
|
child: const Icon(Icons.arrow_upward),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
body: SmoothCustomScrollView(
|
||||||
controller: scrollController,
|
controller: scrollController,
|
||||||
slivers: [
|
slivers: [
|
||||||
...buildTitle(),
|
...buildTitle(),
|
||||||
@@ -144,8 +165,11 @@ class _ComicPageState extends LoadingState<ComicPage, ComicDetails>
|
|||||||
buildComments(),
|
buildComments(),
|
||||||
buildThumbnails(),
|
buildThumbnails(),
|
||||||
buildRecommend(),
|
buildRecommend(),
|
||||||
SliverPadding(padding: EdgeInsets.only(bottom: context.padding.bottom)),
|
SliverPadding(
|
||||||
|
padding: EdgeInsets.only(bottom: context.padding.bottom + 80), // Add additional padding for FAB
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user