From e68c775fca040a078e1c38e6ec39bdbf2f6e28fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maty=C3=A1=C5=A1=20Caras?= Date: Fri, 21 Jun 2024 12:58:40 +0200 Subject: [PATCH] feat: no overlap with player controls plus beta scrollbar --- lib/views/home_view.dart | 67 ++++++++++++++++++++++------------------ pubspec.lock | 8 +++++ pubspec.yaml | 1 + 3 files changed, 46 insertions(+), 30 deletions(-) diff --git a/lib/views/home_view.dart b/lib/views/home_view.dart index c95416c..422ec23 100644 --- a/lib/views/home_view.dart +++ b/lib/views/home_view.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flexible_scrollbar/flexible_scrollbar.dart'; import 'package:flutter/material.dart'; import 'package:grouped_list/grouped_list.dart'; import 'package:ocarina/api/audio/audioplayer_service.dart'; @@ -28,6 +29,7 @@ class _HomeViewState extends State { var _loading = true; final _artists = []; + final _scrollController = ScrollController(); Future authenticate() async { if (!(await LoginManager.hasSavedLogin)) { @@ -80,10 +82,11 @@ class _HomeViewState extends State { appBar: AppBar( title: Text("Home"), ), - body: Center( + body: Align( + alignment: Alignment.topCenter, child: SingleChildScrollView( child: SizedBox( - height: 100.h, + height: 77.h, width: 95.w, child: _loading ? const Column( @@ -92,36 +95,40 @@ class _HomeViewState extends State { CircularProgressIndicator.adaptive(), ], ) - : GroupedListView( - elements: _artists, - groupBy: (a) => a.index, - groupHeaderBuilder: (index) => Text( - index.index, - style: TextStyle( - color: Theme.of(context).colorScheme.primary, + : FlexibleScrollbar( + controller: _scrollController, + child: GroupedListView( + controller: _scrollController, + elements: _artists, + groupBy: (a) => a.index, + groupHeaderBuilder: (index) => Text( + index.index, + style: TextStyle( + color: Theme.of(context).colorScheme.primary, + ), ), - ), - itemBuilder: (c, index) => Wrap( - alignment: (index.artists.length > 1) - ? WrapAlignment.spaceBetween - : WrapAlignment.start, - children: List.generate( - index.artists.length, - (n) => InkWell( - onTap: () async { - await Navigator.of(context).push( - MaterialPageRoute( - builder: (c) => ArtistView( - artist: index.artists[n], + itemBuilder: (c, index) => Wrap( + alignment: (index.artists.length > 1) + ? WrapAlignment.spaceBetween + : WrapAlignment.start, + children: List.generate( + index.artists.length, + (n) => InkWell( + onTap: () async { + await Navigator.of(context).push( + MaterialPageRoute( + builder: (c) => ArtistView( + artist: index.artists[n], + ), ), - ), - ); - }, - child: ImageCover( - cacheKey: index.artists[n].coverArtId, - imageUrl: index.artists[n].coverArtUrl, - title: index.artists[n].name, - heroTag: index.artists[n].name, + ); + }, + child: ImageCover( + cacheKey: index.artists[n].coverArtId, + imageUrl: index.artists[n].coverArtUrl, + title: index.artists[n].name, + heroTag: index.artists[n].name, + ), ), ), ), diff --git a/pubspec.lock b/pubspec.lock index ae0a19c..d1fb534 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -302,6 +302,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + flexible_scrollbar: + dependency: "direct main" + description: + name: flexible_scrollbar + sha256: f5b808009624c49929b9a9c19c41c36fefeac7d8f36cb84558fd26614158d6e9 + url: "https://pub.dev" + source: hosted + version: "0.1.3" flutter: dependency: "direct main" description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index d154ab9..443f1ad 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -56,6 +56,7 @@ dependencies: dynamic_color: ^1.7.0 cached_network_image: ^3.3.1 flutter_xlider: ^3.5.0 + flexible_scrollbar: ^0.1.3 dev_dependencies: build_runner: ^2.4.9