Make little fixes: add scrollbar to thread list and fix scroll position reset in thread list when trying to load more threads

This commit is contained in:
ChronosX88 2022-04-18 00:10:13 +03:00
parent 839f91d735
commit 650461a883
Signed by: ChronosXYZ
GPG Key ID: 085A69A82C8C511A
2 changed files with 28 additions and 24 deletions

View File

@ -40,6 +40,7 @@ class NewsgroupListViewState extends State<NewsgroupListView> {
Widget _newsgroupListView(List<GroupInfo> data) {
return ListView.builder(
controller: ScrollController(),
itemCount: data.length,
itemBuilder: (context, index) {
return ListTile(

View File

@ -56,30 +56,33 @@ class ThreadListViewState extends State<ThreadListView> {
Widget _threadView() {
return _items.isNotEmpty
? ListView.builder(
itemCount: _items.length,
itemBuilder: (context, index) {
if (_items[index].number == -100500) {
return Container(
height: 100,
padding: EdgeInsets.all(20),
child: TextButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all<Color>(Colors.blue),
),
onPressed: () {
setState(() {
_pageNum += 1;
_items.removeLast();
});
},
child: Text('Load more'),
),
);
} else
return ThreadListItemView(item: _items[index]);
})
? Scrollbar(
child: ListView.builder(
key: PageStorageKey("threadList"),
itemCount: _items.length,
itemBuilder: (context, index) {
if (_items[index].number == -100500) {
return Container(
height: 100,
padding: EdgeInsets.all(20),
child: TextButton(
style: ButtonStyle(
foregroundColor:
MaterialStateProperty.all<Color>(Colors.blue),
),
onPressed: () {
setState(() {
_pageNum += 1;
_items.removeLast();
});
},
child: Text('Load more'),
),
);
} else
return ThreadListItemView(item: _items[index]);
}),
)
: Center(
child: Text("This newsgroup is empty",
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16)));