Skip to content

Commit

Permalink
Fixed #44 - not able to scroll till the last song & Fixed piped custo…
Browse files Browse the repository at this point in the history
…m instance
  • Loading branch information
anandnet committed Aug 19, 2023
1 parent 007117f commit 9480262
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 130 deletions.
3 changes: 2 additions & 1 deletion lib/services/music_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ class MusicServices extends getx.GetxService {
} else {
return _sendRequest(action, data, additionalParams: additionalParams);
}
} on DioError {
} on DioError catch (e) {
printINFO("Error $e");
throw NetworkError();
}
}
Expand Down
14 changes: 12 additions & 2 deletions lib/ui/widgets/link_piped.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,15 @@ class PipedLinkedController extends GetxController {
}
if (userName.isEmpty ||
password.isEmpty ||
(instApiUrlInputController.text.isEmpty)) {
// ignore: invalid_use_of_protected_member
(instApiUrlInputController.hasListeners &&
instApiUrlInputController.text.isEmpty)) {
errorText.value = "All fields required";
return;
}
_pipedServices
.login(
instApiUrlInputController.text.isNotEmpty
instApiUrlInputController.text == 'custom'
? instApiUrlInputController.text
: selectedInst.toString(),
userName,
Expand All @@ -177,4 +179,12 @@ class PipedLinkedController extends GetxController {
}
});
}

@override
void onClose() {
instApiUrlInputController.dispose();
usernameInputController.dispose();
passwordInputController.dispose();
super.onClose();
}
}
267 changes: 140 additions & 127 deletions lib/ui/widgets/list_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,192 +64,205 @@ class ListWidget extends StatelessWidget {
Widget listViewSongVid(List<dynamic> items,
{bool isPlaylist = false, Playlist? playlist, ScrollController? sc}) {
final playerController = Get.find<PlayerController>();
return ListView.builder(
addRepaintBoundaries: false,
addAutomaticKeepAlives: false,
controller: sc,
return Obx(
() => ListView.builder(
padding: EdgeInsets.only(
top: 0,
bottom: Get.find<PlayerController>().isPlayerpanelTopVisible.isTrue
? 80
: 0,
top: 0,
),
addRepaintBoundaries: false,
addAutomaticKeepAlives: false,
controller: sc,
itemCount: items.length,
physics: isCompleteList
? const BouncingScrollPhysics()
: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => ListTile(
onTap: () {
isPlaylist
? playerController.playPlayListSong(
List<MediaItem>.from(items), index)
: playerController
.pushSongToQueue(items[index] as MediaItem);
},
onLongPress: () async {
showModalBottomSheet(
isScrollControlled: true,
context:
playerController.homeScaffoldkey.currentState!.context,
//constraints: BoxConstraints(maxHeight:Get.height),
barrierColor: Colors.transparent.withAlpha(100),
builder: (context) => SongInfoBottomSheet(
items[index] as MediaItem,
playlist: playlist,
),
).whenComplete(() => Get.delete<SongInfoController>());
},
contentPadding: const EdgeInsets.only(top: 0, left: 5, right: 30),
leading: ImageWidget(
size: 55,
song: items[index],
onTap: () {
isPlaylist
? playerController.playPlayListSong(
List<MediaItem>.from(items), index)
: playerController.pushSongToQueue(items[index] as MediaItem);
},
onLongPress: () async {
showModalBottomSheet(
isScrollControlled: true,
context: playerController.homeScaffoldkey.currentState!.context,
//constraints: BoxConstraints(maxHeight:Get.height),
barrierColor: Colors.transparent.withAlpha(100),
builder: (context) => SongInfoBottomSheet(
items[index] as MediaItem,
playlist: playlist,
),
title:MarqueeWidget(
child:Text(
items[index].title.length>50?items[index].title.substring(0,50): items[index].title,
maxLines: 1,
style: Theme.of(context).textTheme.titleMedium,
),),
subtitle: Text(
"${items[index].artist}",
maxLines: 1,
style: Theme.of(context).textTheme.titleSmall,
),
trailing: Text(
items[index].extras!['length'] ?? "",
style: Theme.of(context).textTheme.titleSmall,
),
));
).whenComplete(() => Get.delete<SongInfoController>());
},
contentPadding: const EdgeInsets.only(top: 0, left: 5, right: 30),
leading: ImageWidget(
size: 55,
song: items[index],
),
title: MarqueeWidget(
child: Text(
items[index].title.length > 50
? items[index].title.substring(0, 50)
: items[index].title,
maxLines: 1,
style: Theme.of(context).textTheme.titleMedium,
),
),
subtitle: Text(
"${items[index].artist}",
maxLines: 1,
style: Theme.of(context).textTheme.titleSmall,
),
trailing: Text(
items[index].extras!['length'] ?? "",
style: Theme.of(context).textTheme.titleSmall,
),
),
),
);
}

Widget listViewPlaylists(List<dynamic> playlists, {ScrollController? sc}) {
return Expanded(
child: ListView.builder(
controller: sc,
child: Obx(
() => ListView.builder(
padding: EdgeInsets.only(
top: 0,
bottom: Get.find<PlayerController>().isPlayerpanelTopVisible.isTrue
? 80
: 0,
top: 0,
),
controller: sc,
itemCount: playlists.length,
itemExtent: 100,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, index) => ListTile(
visualDensity: const VisualDensity(vertical: 4.0),
isThreeLine: true,
onTap: () {
Get.toNamed(ScreenNavigationSetup.playlistNAlbumScreen,
id: ScreenNavigationSetup.id,
arguments: [false, playlists[index], false]);
},
contentPadding:
const EdgeInsets.only(top: 0, bottom: 0, left: 10),
leading: ImageWidget(
size: 100,
playlist: playlists[index],
),
title: Text(
playlists[index].title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Text(
playlists[index].description,
maxLines: 2,
style: Theme.of(context).textTheme.titleSmall,
),
)),
);
}

Widget listViewAlbums(List<dynamic> albums, {ScrollController? sc}) {
return Expanded(
child: ListView.builder(
controller: sc,
padding: EdgeInsets.only(
top: 0,
bottom: Get.find<PlayerController>().isPlayerpanelTopVisible.isTrue
? 80
: 0,
),
itemCount: albums.length,
itemExtent: 100,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, index) {
String artistName = "";
for (dynamic items in (albums[index].artists).sublist(1)) {
artistName = "${artistName + items['name']},";
}
artistName =
artistName.length > 16 ? artistName.substring(0, 16) : artistName;
return ListTile(
visualDensity: const VisualDensity(vertical: 4.0),
isThreeLine: true,
onTap: () {
Get.toNamed(ScreenNavigationSetup.playlistNAlbumScreen,
id: ScreenNavigationSetup.id,
arguments: [true, albums[index], false]);
arguments: [false, playlists[index], false]);
},
contentPadding: const EdgeInsets.only(top: 0, bottom: 0, left: 10),
leading: ImageWidget(
size: 100,
album: albums[index],
playlist: playlists[index],
),
title: Text(
albums[index].title,
playlists[index].title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Text(
"$artistName\n${(albums[index].artists[0]['name'])} • ${albums[index].year}",
playlists[index].description,
maxLines: 2,
style: Theme.of(context).textTheme.titleSmall,
),
);
},
),
),
),
);
}

Widget listViewArtists(List<dynamic> artists, {ScrollController? sc}) {
return ListView.builder(
controller: sc,
padding: EdgeInsets.only(
top: 5,
bottom: Get.find<PlayerController>().isPlayerpanelTopVisible.isTrue
? 80
: 0,
),
itemCount: artists.length,
itemExtent: 90,
physics: isCompleteList
? const BouncingScrollPhysics()
: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => ListTile(
visualDensity: const VisualDensity(horizontal: -2, vertical: 2),
Widget listViewAlbums(List<dynamic> albums, {ScrollController? sc}) {
return Expanded(
child: Obx(
() => ListView.builder(
padding: EdgeInsets.only(
bottom: Get.find<PlayerController>().isPlayerpanelTopVisible.isTrue
? 80
: 0,
top: 0,
),
controller: sc,
itemCount: albums.length,
itemExtent: 100,
physics: const BouncingScrollPhysics(),
itemBuilder: (context, index) {
String artistName = "";
for (dynamic items in (albums[index].artists).sublist(1)) {
artistName = "${artistName + items['name']},";
}
artistName = artistName.length > 16
? artistName.substring(0, 16)
: artistName;
return ListTile(
visualDensity: const VisualDensity(vertical: 4.0),
isThreeLine: true,
onTap: () {
Get.toNamed(ScreenNavigationSetup.artistScreen,
Get.toNamed(ScreenNavigationSetup.playlistNAlbumScreen,
id: ScreenNavigationSetup.id,
arguments: [false, artists[index]]);
arguments: [true, albums[index], false]);
},
contentPadding: const EdgeInsets.only(top: 0, bottom: 0, left: 5),
contentPadding:
const EdgeInsets.only(top: 0, bottom: 0, left: 10),
leading: ImageWidget(
size: 90,
artist: artists[index],
size: 100,
album: albums[index],
),
title: Text(
artists[index].name,
albums[index].title,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Text(
artists[index].subscribers,
"$artistName\n${(albums[index].artists[0]['name'])} • ${albums[index].year}",
maxLines: 2,
style: Theme.of(context).textTheme.titleSmall,
),
));
);
},
),
),
);
}

Widget listViewArtists(List<dynamic> artists, {ScrollController? sc}) {
return Obx(
() => ListView.builder(
padding: EdgeInsets.only(
bottom: Get.find<PlayerController>().isPlayerpanelTopVisible.isTrue
? 80
: 0,
top: 5,
),
controller: sc,
itemCount: artists.length,
itemExtent: 90,
physics: isCompleteList
? const BouncingScrollPhysics()
: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => ListTile(
visualDensity: const VisualDensity(horizontal: -2, vertical: 2),
onTap: () {
Get.toNamed(ScreenNavigationSetup.artistScreen,
id: ScreenNavigationSetup.id,
arguments: [false, artists[index]]);
},
contentPadding: const EdgeInsets.only(top: 0, bottom: 0, left: 5),
leading: ImageWidget(
size: 90,
artist: artists[index],
),
title: Text(
artists[index].name,
maxLines: 1,
style: Theme.of(context).textTheme.titleMedium,
),
subtitle: Text(
artists[index].subscribers,
maxLines: 2,
style: Theme.of(context).textTheme.titleSmall,
),
),
),
);
}
}

0 comments on commit 9480262

Please sign in to comment.