Clicking on home button when on that screen scrolls it to the top

codemagic-setup
Hank Grabowski 2023-04-07 08:55:37 -04:00
rodzic fe9a27be7c
commit 76da2ca390
5 zmienionych plików z 27 dodań i 6 usunięć

Wyświetl plik

@ -6,6 +6,7 @@
* The "copy text" action now copies the plain text not HTML version. So things like hashtags show up as "#hashtag"
not
the HTML code around it with the link reference etc.
* Clicking on the "Home" button if you already are on that screen scrolls to the top.
* Fixes
* New Features

Wyświetl plik

@ -120,6 +120,7 @@ wanted to lay out some expectations before getting into the small details
* Nitter replacement of Twitter links
* User configurable Server blocking
* Server-side searching tied into profiles, posts, hashtags
* Smarter hashtag and user account storage/searching
* Being able to ignore/unignore users
* Deleting images and entire galleries
* Events

Wyświetl plik

@ -17,8 +17,13 @@ enum NavBarButtons {
class AppBottomNavBar extends StatelessWidget {
static final _logger = Logger('$AppBottomNavBar');
final NavBarButtons currentButton;
final Function()? onHomeButtonReclick;
const AppBottomNavBar({super.key, required this.currentButton});
const AppBottomNavBar({
super.key,
required this.currentButton,
this.onHomeButtonReclick,
});
@override
Widget build(BuildContext context) {
@ -36,6 +41,10 @@ class AppBottomNavBar extends StatelessWidget {
onTap: (index) {
final newButton = _indexToButton(index);
if (newButton == currentButton) {
if (newButton == NavBarButtons.timelines &&
onHomeButtonReclick != null) {
onHomeButtonReclick!();
}
return;
}

Wyświetl plik

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:logging/logging.dart';
import 'package:provider/provider.dart';
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart';
import '../../models/TimelineIdentifiers.dart';
import '../../services/timeline_manager.dart';
@ -10,8 +11,9 @@ import 'post_control.dart';
class TimelinePanel extends StatelessWidget {
static final _logger = Logger('$TimelinePanel');
final TimelineIdentifiers timeline;
final controller = ItemScrollController();
const TimelinePanel({super.key, required this.timeline});
TimelinePanel({super.key, required this.timeline});
Future<void> update(TimelineManager manager) async {
await manager.updateTimeline(
@ -25,6 +27,10 @@ class TimelinePanel extends StatelessWidget {
);
}
void scrollToTop() {
controller.jumpTo(index: 0);
}
@override
Widget build(BuildContext context) {
_logger.finer('Build');
@ -50,7 +56,8 @@ class TimelinePanel extends StatelessWidget {
],
),
)
: ListView.builder(
: ScrollablePositionedList.builder(
itemScrollController: controller,
physics: const AlwaysScrollableScrollPhysics(),
itemBuilder: (context, index) {
if (index == 0) {

Wyświetl plik

@ -78,6 +78,8 @@ class _HomeScreenState extends State<HomeScreen> {
currentGroup = null;
}
final timeline = TimelinePanel(timeline: currentTimeline);
return Scaffold(
appBar: AppBar(
leading: accountService.loggedIn
@ -150,13 +152,14 @@ class _HomeScreenState extends State<HomeScreen> {
child: Column(
children: [
StandardLinearProgressIndicator(nss.timelineLoadingStatus),
Expanded(child: TimelinePanel(timeline: currentTimeline)),
Expanded(child: timeline),
],
),
),
drawer: StandardAppDrawer(),
bottomNavigationBar: const AppBottomNavBar(
drawer: const StandardAppDrawer(),
bottomNavigationBar: AppBottomNavBar(
currentButton: NavBarButtons.timelines,
onHomeButtonReclick: () => timeline.scrollToTop(),
),
floatingActionButton: FloatingActionButton.small(
onPressed: () {