From 1e6100008c39491220e81b07c3b7267ee31e8108 Mon Sep 17 00:00:00 2001 From: Hemant KArya <65885023+HemantKArya@users.noreply.github.com> Date: Fri, 30 Aug 2024 01:16:57 +0530 Subject: [PATCH] safearea fixes --- lib/screens/screen/chart/chart_view.dart | 100 +-- .../screen/common_views/album_view.dart | 465 ++++++------ .../screen/common_views/artist_view.dart | 610 +++++++-------- .../screen/common_views/playlist_view.dart | 460 ++++++------ lib/screens/screen/explore_screen.dart | 232 +++--- .../screen/home_views/recents_view.dart | 118 +-- lib/screens/screen/library_screen.dart | 58 +- lib/screens/screen/offline_screen.dart | 98 +-- lib/screens/screen/search_screen.dart | 703 +++++++++--------- 9 files changed, 1448 insertions(+), 1396 deletions(-) diff --git a/lib/screens/screen/chart/chart_view.dart b/lib/screens/screen/chart/chart_view.dart index abb3730..c883a52 100644 --- a/lib/screens/screen/chart/chart_view.dart +++ b/lib/screens/screen/chart/chart_view.dart @@ -32,57 +32,59 @@ class _ChartScreenState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: FutureBuilder( - future: chartModel, - builder: (context, state) { - if (state.connectionState == ConnectionState.waiting || - state.data == null) { - return const Center( - child: SizedBox( - height: 50, - width: 50, - child: CircularProgressIndicator( - color: Default_Theme.accentColor2, - )), - ); - } else if (state.data!.chartItems!.isEmpty) { - return Center( - child: Text("Error: No Item in Chart", - style: Default_Theme.secondoryTextStyleMedium.merge( - const TextStyle( - fontSize: 24, - color: Color.fromARGB(255, 255, 235, 251)))), - ); - } else { - return CustomScrollView( - physics: const BouncingScrollPhysics(), - slivers: [ - customDiscoverBar(context, state.data!), //AppBar - SliverList( - delegate: SliverChildListDelegate([ - ListView.builder( - shrinkWrap: true, - padding: const EdgeInsets.only( - top: 5, + return SafeArea( + child: Scaffold( + body: FutureBuilder( + future: chartModel, + builder: (context, state) { + if (state.connectionState == ConnectionState.waiting || + state.data == null) { + return const Center( + child: SizedBox( + height: 50, + width: 50, + child: CircularProgressIndicator( + color: Default_Theme.accentColor2, + )), + ); + } else if (state.data!.chartItems!.isEmpty) { + return Center( + child: Text("Error: No Item in Chart", + style: Default_Theme.secondoryTextStyleMedium.merge( + const TextStyle( + fontSize: 24, + color: Color.fromARGB(255, 255, 235, 251)))), + ); + } else { + return CustomScrollView( + physics: const BouncingScrollPhysics(), + slivers: [ + customDiscoverBar(context, state.data!), //AppBar + SliverList( + delegate: SliverChildListDelegate([ + ListView.builder( + shrinkWrap: true, + padding: const EdgeInsets.only( + top: 5, + ), + physics: const NeverScrollableScrollPhysics(), + itemCount: state.data!.chartItems!.length, + itemBuilder: (context, index) { + return ChartListTile( + title: state.data!.chartItems![index].name!, + subtitle: state.data!.chartItems![index].subtitle!, + imgUrl: state.data!.chartItems![index].imageUrl!, + ); + }, ), - physics: const NeverScrollableScrollPhysics(), - itemCount: state.data!.chartItems!.length, - itemBuilder: (context, index) { - return ChartListTile( - title: state.data!.chartItems![index].name!, - subtitle: state.data!.chartItems![index].subtitle!, - imgUrl: state.data!.chartItems![index].imageUrl!, - ); - }, - ), - ])) - ], - ); - } - }, + ])) + ], + ); + } + }, + ), + backgroundColor: Default_Theme.themeColor, ), - backgroundColor: Default_Theme.themeColor, ); } diff --git a/lib/screens/screen/common_views/album_view.dart b/lib/screens/screen/common_views/album_view.dart index 46e5994..467668b 100644 --- a/lib/screens/screen/common_views/album_view.dart +++ b/lib/screens/screen/common_views/album_view.dart @@ -37,268 +37,275 @@ class _AlbumViewState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: BlocBuilder( - bloc: albumCubit, - builder: (context, state) { - return CustomScrollView( - slivers: [ - SliverAppBar( - expandedHeight: - ResponsiveBreakpoints.of(context).isMobile ? 220 : 250, - flexibleSpace: LayoutBuilder(builder: (context, constraints) { - String subtitle = widget.album.year; - if (widget.album.genre != null && - widget.album.genre != "Unknown") { - subtitle += ' - ${widget.album.genre!}'; - } - if (widget.album.language != null) { - subtitle += ' - ${widget.album.language!}'; - } + return SafeArea( + child: Scaffold( + body: BlocBuilder( + bloc: albumCubit, + builder: (context, state) { + return CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: + ResponsiveBreakpoints.of(context).isMobile ? 220 : 250, + flexibleSpace: LayoutBuilder(builder: (context, constraints) { + String subtitle = widget.album.year; + if (widget.album.genre != null && + widget.album.genre != "Unknown") { + subtitle += ' - ${widget.album.genre!}'; + } + if (widget.album.language != null) { + subtitle += ' - ${widget.album.language!}'; + } - return FlexibleSpaceBar( - background: Padding( - padding: const EdgeInsets.only( - left: 8, - right: 8, - top: 34, - bottom: 8, - ), - child: ConstrainedBox( - constraints: BoxConstraints( - maxHeight: constraints.maxHeight, - minWidth: 350, + return FlexibleSpaceBar( + background: Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + top: 34, + bottom: 8, ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - ConstrainedBox( - constraints: BoxConstraints( - maxWidth: - MediaQuery.of(context).size.width * 0.4, - ), - child: Padding( - padding: const EdgeInsets.only( - left: 8, - right: 8, - top: 8, - bottom: 8, + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: constraints.maxHeight, + minWidth: 350, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ConstrainedBox( + constraints: BoxConstraints( + maxWidth: + MediaQuery.of(context).size.width * 0.4, + ), + child: Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + top: 8, + bottom: 8, + ), + child: Hero( + tag: widget.album.sourceId, + child: LoadImageCached( + imageUrl: formatImgURL( + widget.album.imageURL, + ImageQuality.medium), + )), ), - child: Hero( - tag: widget.album.sourceId, - child: LoadImageCached( - imageUrl: formatImgURL( - widget.album.imageURL, - ImageQuality.medium), - )), ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Album by", - style: Default_Theme - .secondoryTextStyleMedium - .merge( - TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 14, - color: Default_Theme.primaryColor1 - .withOpacity(0.4), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Album by", + style: Default_Theme + .secondoryTextStyleMedium + .merge( + TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 14, + color: Default_Theme.primaryColor1 + .withOpacity(0.4), + ), ), ), - ), - Text( - widget.album.artists, - maxLines: 3, - style: Default_Theme - .secondoryTextStyleMedium - .merge( - TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 14, - color: Default_Theme.primaryColor1 - .withOpacity(0.9), + Text( + widget.album.artists, + maxLines: 3, + style: Default_Theme + .secondoryTextStyleMedium + .merge( + TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 14, + color: Default_Theme.primaryColor1 + .withOpacity(0.9), + ), ), ), - ), - Text( - subtitle, - style: Default_Theme.secondoryTextStyle - .merge( - TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 13, - color: Default_Theme.primaryColor1 - .withOpacity(0.5), + Text( + subtitle, + style: Default_Theme.secondoryTextStyle + .merge( + TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 13, + color: Default_Theme.primaryColor1 + .withOpacity(0.5), + ), ), ), - ), - FittedBox( - fit: BoxFit.scaleDown, - child: Padding( - padding: const EdgeInsets.only(top: 8), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - OutlinedButton.icon( - style: OutlinedButton.styleFrom( - side: const BorderSide( - width: 2, - color: Default_Theme - .accentColor2, + FittedBox( + fit: BoxFit.scaleDown, + child: Padding( + padding: + const EdgeInsets.only(top: 8), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + OutlinedButton.icon( + style: OutlinedButton.styleFrom( + side: const BorderSide( + width: 2, + color: Default_Theme + .accentColor2, + ), ), - ), - onPressed: () { - if (context + onPressed: () { + if (context + .read< + BloomeePlayerCubit>() + .bloomeePlayer + .queueTitle + .value != + widget.album.name) { + context .read< BloomeePlayerCubit>() .bloomeePlayer - .queueTitle - .value != - widget.album.name) { - context - .read< - BloomeePlayerCubit>() - .bloomeePlayer - .loadPlaylist( - state.album.playlist, - doPlay: true, - idx: 0); - } else if (!context - .read() - .bloomeePlayer - .audioPlayer - .playing) { - context + .loadPlaylist( + state + .album.playlist, + doPlay: true, + idx: 0); + } else if (!context .read< BloomeePlayerCubit>() .bloomeePlayer - .play(); - } - }, - label: const Text( - "Play", - style: Default_Theme - .secondoryTextStyleMedium, - ), - icon: const Icon( - MingCute.play_fill, - size: 20, - ), - ), - Padding( - padding: const EdgeInsets.only( - left: 5, + .audioPlayer + .playing) { + context + .read< + BloomeePlayerCubit>() + .bloomeePlayer + .play(); + } + }, + label: const Text( + "Play", + style: Default_Theme + .secondoryTextStyleMedium, + ), + icon: const Icon( + MingCute.play_fill, + size: 20, + ), ), - child: Tooltip( - message: "Open Original Link", - child: IconButton( - onPressed: () { - SnackbarService.showMessage( - "Opening original album page."); - launchUrl( - Uri.parse(state - .album.sourceURL), - mode: LaunchMode - .externalApplication); - }, - icon: const Icon( - MingCute.external_link_line, - size: 25, + Padding( + padding: const EdgeInsets.only( + left: 5, + ), + child: Tooltip( + message: "Open Original Link", + child: IconButton( + onPressed: () { + SnackbarService.showMessage( + "Opening original album page."); + launchUrl( + Uri.parse(state + .album.sourceURL), + mode: LaunchMode + .externalApplication); + }, + icon: const Icon( + MingCute + .external_link_line, + size: 25, + ), ), ), ), - ), - ], + ], + ), ), - ), - ) - ], + ) + ], + ), ), - ), - ) - ], + ) + ], + ), ), ), + ); + }), + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.only( + left: 16, + right: 16, + bottom: 8, ), - ); - }), - ), - SliverToBoxAdapter( - child: Padding( - padding: const EdgeInsets.only( - left: 16, - right: 16, - bottom: 8, - ), - child: Text( - widget.album.name, - maxLines: 3, - textAlign: TextAlign.center, - style: Default_Theme.secondoryTextStyleMedium.merge( - TextStyle( - fontSize: 20, - color: Default_Theme.primaryColor1.withOpacity(0.8), + child: Text( + widget.album.name, + maxLines: 3, + textAlign: TextAlign.center, + style: Default_Theme.secondoryTextStyleMedium.merge( + TextStyle( + fontSize: 20, + color: Default_Theme.primaryColor1.withOpacity(0.8), + ), ), ), ), ), - ), - (state is AlbumLoaded) - ? SliverList.builder( - itemBuilder: (context, index) { - return SongCardWidget( - song: state.album.songs[index], - onOptionsTap: () { - showMoreBottomSheet( - context, state.album.songs[index], - showDelete: false); - }, - onTap: () { - if (context - .read() - .bloomeePlayer - .queueTitle - .value != - widget.album.name || + (state is AlbumLoaded) + ? SliverList.builder( + itemBuilder: (context, index) { + return SongCardWidget( + song: state.album.songs[index], + onOptionsTap: () { + showMoreBottomSheet( + context, state.album.songs[index], + showDelete: false); + }, + onTap: () { + if (context + .read() + .bloomeePlayer + .queueTitle + .value != + widget.album.name || + context + .read() + .bloomeePlayer + .currentMedia != + state.album.songs[index]) { context - .read() - .bloomeePlayer - .currentMedia != - state.album.songs[index]) { - context + .read() + .bloomeePlayer + .loadPlaylist(state.album.playlist, + doPlay: true, idx: index); + } else if (!context .read() .bloomeePlayer - .loadPlaylist(state.album.playlist, - doPlay: true, idx: index); - } else if (!context - .read() - .bloomeePlayer - .audioPlayer - .playing) { - context - .read() - .bloomeePlayer - .play(); - } - }, - ); - }, - itemCount: state.album.songs.length) - : const SliverFillRemaining( - hasScrollBody: false, - child: Center( - child: CircularProgressIndicator(), - )), - ], - ); - }, + .audioPlayer + .playing) { + context + .read() + .bloomeePlayer + .play(); + } + }, + ); + }, + itemCount: state.album.songs.length) + : const SliverFillRemaining( + hasScrollBody: false, + child: Center( + child: CircularProgressIndicator(), + )), + ], + ); + }, + ), ), ); } diff --git a/lib/screens/screen/common_views/artist_view.dart b/lib/screens/screen/common_views/artist_view.dart index cd13cfb..adc4e1a 100644 --- a/lib/screens/screen/common_views/artist_view.dart +++ b/lib/screens/screen/common_views/artist_view.dart @@ -39,341 +39,353 @@ class _ArtistViewState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: BlocBuilder( - bloc: artistCubit, - builder: (context, state) { - return DefaultTabController( - length: 2, - child: NestedScrollView( - headerSliverBuilder: (context, innerBoxIsScrolled) => [ - SliverAppBar( - expandedHeight: - ResponsiveBreakpoints.of(context).isMobile ? 220 : 250, - flexibleSpace: LayoutBuilder(builder: (context, constraints) { - return FlexibleSpaceBar( - background: Padding( - padding: const EdgeInsets.only( - left: 8, - right: 8, - top: 34, - bottom: 8, - ), - child: ConstrainedBox( - constraints: BoxConstraints( - maxHeight: constraints.maxHeight, - minWidth: 350, + return SafeArea( + child: Scaffold( + body: BlocBuilder( + bloc: artistCubit, + builder: (context, state) { + return DefaultTabController( + length: 2, + child: NestedScrollView( + headerSliverBuilder: (context, innerBoxIsScrolled) => [ + SliverAppBar( + expandedHeight: + ResponsiveBreakpoints.of(context).isMobile ? 220 : 250, + flexibleSpace: + LayoutBuilder(builder: (context, constraints) { + return FlexibleSpaceBar( + background: Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + top: 34, + bottom: 8, ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - ConstrainedBox( - constraints: BoxConstraints( - maxWidth: - MediaQuery.of(context).size.width * 0.4, - ), - child: Padding( - padding: const EdgeInsets.only( - left: 8, - right: 8, - top: 8, - bottom: 8, + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: constraints.maxHeight, + minWidth: 350, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ConstrainedBox( + constraints: BoxConstraints( + maxWidth: + MediaQuery.of(context).size.width * 0.4, + ), + child: Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + top: 8, + bottom: 8, + ), + child: Hero( + tag: widget.artist.sourceId, + child: ClipOval( + child: LoadImageCached( + imageUrl: formatImgURL( + widget.artist.imageUrl, + ImageQuality.medium), + fit: BoxFit.fitWidth, + ), + )), ), - child: Hero( - tag: widget.artist.sourceId, - child: ClipOval( - child: LoadImageCached( - imageUrl: formatImgURL( - widget.artist.imageUrl, - ImageQuality.medium), - fit: BoxFit.fitWidth, - ), - )), ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - widget.artist.name, - maxLines: 3, - style: Default_Theme - .secondoryTextStyleMedium - .merge( - TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 18, - color: Default_Theme.primaryColor1 - .withOpacity(0.8), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: + MainAxisAlignment.center, + children: [ + Text( + widget.artist.name, + maxLines: 3, + style: Default_Theme + .secondoryTextStyleMedium + .merge( + TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 18, + color: Default_Theme.primaryColor1 + .withOpacity(0.8), + ), ), ), - ), - state.artist.description != null && - state.artist.description != '' - ? Text( - state.artist.description ?? "", - style: Default_Theme - .secondoryTextStyle - .merge( - TextStyle( - overflow: - TextOverflow.ellipsis, - fontSize: 13, - color: Default_Theme - .primaryColor1 - .withOpacity(0.5), - ), - ), - ) - : const SizedBox.shrink(), - FittedBox( - fit: BoxFit.scaleDown, - child: Padding( - padding: const EdgeInsets.only( - top: 5, - ), - child: Row( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: - CrossAxisAlignment.center, - children: [ - OutlinedButton.icon( - style: OutlinedButton.styleFrom( - side: const BorderSide( - width: 2, + state.artist.description != null && + state.artist.description != '' + ? Text( + state.artist.description ?? "", + style: Default_Theme + .secondoryTextStyle + .merge( + TextStyle( + overflow: + TextOverflow.ellipsis, + fontSize: 13, color: Default_Theme - .accentColor2, + .primaryColor1 + .withOpacity(0.5), ), ), - onPressed: () { - if (context + ) + : const SizedBox.shrink(), + FittedBox( + fit: BoxFit.scaleDown, + child: Padding( + padding: const EdgeInsets.only( + top: 5, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: + CrossAxisAlignment.center, + children: [ + OutlinedButton.icon( + style: + OutlinedButton.styleFrom( + side: const BorderSide( + width: 2, + color: Default_Theme + .accentColor2, + ), + ), + onPressed: () { + if (context + .read< + BloomeePlayerCubit>() + .bloomeePlayer + .queueTitle + .value != + widget.artist.name) { + context .read< BloomeePlayerCubit>() .bloomeePlayer - .queueTitle - .value != - widget.artist.name) { - context - .read< - BloomeePlayerCubit>() - .bloomeePlayer - .loadPlaylist( - state.artist - .playlist, - doPlay: true, - idx: 0); - } else if (!context - .read< - BloomeePlayerCubit>() - .bloomeePlayer - .audioPlayer - .playing) { - context + .loadPlaylist( + state.artist + .playlist, + doPlay: true, + idx: 0); + } else if (!context .read< BloomeePlayerCubit>() .bloomeePlayer - .play(); - } - }, - label: const Text( - "Play", - style: Default_Theme - .secondoryTextStyleMedium, - ), - icon: const Icon( - MingCute.play_fill, - size: 20, - ), - ), - Padding( - padding: const EdgeInsets.only( - left: 5, + .audioPlayer + .playing) { + context + .read< + BloomeePlayerCubit>() + .bloomeePlayer + .play(); + } + }, + label: const Text( + "Play", + style: Default_Theme + .secondoryTextStyleMedium, + ), + icon: const Icon( + MingCute.play_fill, + size: 20, + ), ), - child: Tooltip( - message: "Open Original Link", - child: IconButton( - onPressed: () { - SnackbarService.showMessage( - "Opening original artist page."); - launchUrl( - Uri.parse(state.artist - .sourceURL), - mode: LaunchMode - .externalApplication); - }, - icon: const Icon( - MingCute - .external_link_line, - size: 25, + Padding( + padding: + const EdgeInsets.only( + left: 5, + ), + child: Tooltip( + message: + "Open Original Link", + child: IconButton( + onPressed: () { + SnackbarService.showMessage( + "Opening original artist page."); + launchUrl( + Uri.parse(state + .artist + .sourceURL), + mode: LaunchMode + .externalApplication); + }, + icon: const Icon( + MingCute + .external_link_line, + size: 25, + ), ), ), ), - ), - ], + ], + ), ), - ), - ) - ], + ) + ], + ), ), - ), - ) - ], + ) + ], + ), ), ), + ); + }), + ), + SliverToBoxAdapter( + child: TabBar( + labelColor: Default_Theme.primaryColor1, + labelStyle: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.bold, + fontFamily: 'Unageo', ), - ); - }), - ), - SliverToBoxAdapter( - child: TabBar( - labelColor: Default_Theme.primaryColor1, - labelStyle: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.bold, - fontFamily: 'Unageo', + dividerColor: Colors.transparent, + unselectedLabelColor: + Default_Theme.primaryColor1.withOpacity(0.5), + indicatorColor: Default_Theme.primaryColor1, + tabs: const [ + Tab( + text: "Top Songs", + ), + Tab( + text: "Top Albums", + ), + ], ), - dividerColor: Colors.transparent, - unselectedLabelColor: - Default_Theme.primaryColor1.withOpacity(0.5), - indicatorColor: Default_Theme.primaryColor1, - tabs: const [ - Tab( - text: "Top Songs", - ), - Tab( - text: "Top Albums", - ), - ], ), - ), - ], - body: (state is ArtistLoaded) - ? TabBarView( - children: [ - state.artist.songs.isEmpty - ? const SignBoardWidget( - message: "No song found!", - icon: MingCute.unhappy_fill, - ) - : ListView.builder( - itemCount: state.artist.songs.length, - itemBuilder: (context, index) { - return SongCardWidget( - song: state.artist.songs[index], - onOptionsTap: () { - showMoreBottomSheet( - context, state.artist.songs[index], - showDelete: false); - }, - onTap: () { - if (context - .read() - .bloomeePlayer - .queueTitle - .value != - widget.artist.name || + ], + body: (state is ArtistLoaded) + ? TabBarView( + children: [ + state.artist.songs.isEmpty + ? const SignBoardWidget( + message: "No song found!", + icon: MingCute.unhappy_fill, + ) + : ListView.builder( + itemCount: state.artist.songs.length, + itemBuilder: (context, index) { + return SongCardWidget( + song: state.artist.songs[index], + onOptionsTap: () { + showMoreBottomSheet( + context, state.artist.songs[index], + showDelete: false); + }, + onTap: () { + if (context + .read() + .bloomeePlayer + .queueTitle + .value != + widget.artist.name || + context + .read() + .bloomeePlayer + .currentMedia != + state.artist.songs[index]) { context - .read() - .bloomeePlayer - .currentMedia != - state.artist.songs[index]) { - context - .read() - .bloomeePlayer - .loadPlaylist(state.artist.playlist, - doPlay: true, idx: index); - } else if (!context - .read() - .bloomeePlayer - .audioPlayer - .playing) { - context + .read() + .bloomeePlayer + .loadPlaylist( + state.artist.playlist, + doPlay: true, + idx: index); + } else if (!context .read() .bloomeePlayer - .play(); - } - }, - ); - }, - ), - state.artist.albums.isEmpty - ? const SignBoardWidget( - message: "No album found!", - icon: MingCute.unhappy_fill, - ) - : ListView.builder( - itemBuilder: (context, index) { - return Padding( - padding: const EdgeInsets.only( - left: 8, - right: 8, - top: 2, - bottom: 2, - ), - child: ListTile( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => AlbumView( - album: state.artist.albums[index], + .audioPlayer + .playing) { + context + .read() + .bloomeePlayer + .play(); + } + }, + ); + }, + ), + state.artist.albums.isEmpty + ? const SignBoardWidget( + message: "No album found!", + icon: MingCute.unhappy_fill, + ) + : ListView.builder( + itemBuilder: (context, index) { + return Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + top: 2, + bottom: 2, + ), + child: ListTile( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => AlbumView( + album: + state.artist.albums[index], + ), ), + ); + }, + leading: Hero( + tag: state + .artist.albums[index].sourceId, + child: LoadImageCached( + imageUrl: state + .artist.albums[index].imageURL, ), - ); - }, - leading: Hero( - tag: - state.artist.albums[index].sourceId, - child: LoadImageCached( - imageUrl: state - .artist.albums[index].imageURL, ), - ), - title: Text( - maxLines: 1, - state.artist.albums[index].name, - style: Default_Theme - .secondoryTextStyleMedium - .merge( - TextStyle( - fontSize: 14, - overflow: TextOverflow.ellipsis, - color: Default_Theme.primaryColor1 - .withOpacity(0.8), + title: Text( + maxLines: 1, + state.artist.albums[index].name, + style: Default_Theme + .secondoryTextStyleMedium + .merge( + TextStyle( + fontSize: 14, + overflow: TextOverflow.ellipsis, + color: Default_Theme.primaryColor1 + .withOpacity(0.8), + ), ), ), - ), - subtitle: Text( - state.artist.albums[index].artists, - maxLines: 1, - style: Default_Theme.secondoryTextStyle - .merge( - TextStyle( - fontSize: 12, - color: Default_Theme.primaryColor1 - .withOpacity(0.5), - overflow: TextOverflow.ellipsis, + subtitle: Text( + state.artist.albums[index].artists, + maxLines: 1, + style: Default_Theme + .secondoryTextStyle + .merge( + TextStyle( + fontSize: 12, + color: Default_Theme.primaryColor1 + .withOpacity(0.5), + overflow: TextOverflow.ellipsis, + ), ), ), ), - ), - ); - }, - itemCount: state.artist.albums.length, - ) - ], - ) - : const Center( - child: CircularProgressIndicator(), - ), - ), - ); - }, + ); + }, + itemCount: state.artist.albums.length, + ) + ], + ) + : const Center( + child: CircularProgressIndicator(), + ), + ), + ); + }, + ), ), ); } diff --git a/lib/screens/screen/common_views/playlist_view.dart b/lib/screens/screen/common_views/playlist_view.dart index 905cf80..b12d672 100644 --- a/lib/screens/screen/common_views/playlist_view.dart +++ b/lib/screens/screen/common_views/playlist_view.dart @@ -37,266 +37,274 @@ class _OnlPlaylistViewState extends State { @override Widget build(BuildContext context) { - return Scaffold( - body: BlocBuilder( - bloc: onlPlaylistCubit, - builder: (context, state) { - return CustomScrollView( - slivers: [ - SliverAppBar( - expandedHeight: - ResponsiveBreakpoints.of(context).isMobile ? 220 : 250, - flexibleSpace: LayoutBuilder(builder: (context, constraints) { - return FlexibleSpaceBar( - background: Padding( - padding: const EdgeInsets.only( - left: 8, - right: 8, - top: 34, - bottom: 8, - ), - child: ConstrainedBox( - constraints: BoxConstraints( - maxHeight: constraints.maxHeight, - minWidth: 350, + return SafeArea( + child: Scaffold( + body: BlocBuilder( + bloc: onlPlaylistCubit, + builder: (context, state) { + return CustomScrollView( + slivers: [ + SliverAppBar( + expandedHeight: + ResponsiveBreakpoints.of(context).isMobile ? 220 : 250, + flexibleSpace: LayoutBuilder(builder: (context, constraints) { + return FlexibleSpaceBar( + background: Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + top: 34, + bottom: 8, ), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - ConstrainedBox( - constraints: BoxConstraints( - maxWidth: - MediaQuery.of(context).size.width * 0.4, - ), - child: Padding( - padding: const EdgeInsets.only( - left: 8, - right: 8, - top: 8, - bottom: 8, + child: ConstrainedBox( + constraints: BoxConstraints( + maxHeight: constraints.maxHeight, + minWidth: 350, + ), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ConstrainedBox( + constraints: BoxConstraints( + maxWidth: + MediaQuery.of(context).size.width * 0.4, ), - child: Hero( - tag: widget.playlist.sourceId, - child: LoadImageCached( - imageUrl: formatImgURL( - widget.playlist.imageURL, - ImageQuality.high), - fit: BoxFit.fitWidth, + child: Padding( + padding: const EdgeInsets.only( + left: 8, + right: 8, + top: 8, + bottom: 8, + ), + child: Hero( + tag: widget.playlist.sourceId, + child: LoadImageCached( + imageUrl: formatImgURL( + widget.playlist.imageURL, + ImageQuality.high), + fit: BoxFit.fitWidth, + ), ), ), ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Playlist by", - style: Default_Theme - .secondoryTextStyleMedium - .merge( - TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 14, - color: Default_Theme.primaryColor1 - .withOpacity(0.4), + Expanded( + child: Padding( + padding: const EdgeInsets.all(8.0), + child: Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + "Playlist by", + style: Default_Theme + .secondoryTextStyleMedium + .merge( + TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 14, + color: Default_Theme.primaryColor1 + .withOpacity(0.4), + ), ), ), - ), - Text( - widget.playlist.artists, - maxLines: 3, - style: Default_Theme - .secondoryTextStyleMedium - .merge( - TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 14, - color: Default_Theme.primaryColor1 - .withOpacity(0.9), + Text( + widget.playlist.artists, + maxLines: 3, + style: Default_Theme + .secondoryTextStyleMedium + .merge( + TextStyle( + overflow: TextOverflow.ellipsis, + fontSize: 14, + color: Default_Theme.primaryColor1 + .withOpacity(0.9), + ), ), ), - ), - state.playlist.description != null - ? Text( - state.playlist.description ?? "", - style: Default_Theme - .secondoryTextStyle - .merge( - TextStyle( - overflow: TextOverflow.ellipsis, - fontSize: 13, - color: Default_Theme - .primaryColor1 - .withOpacity(0.5), - ), - ), - ) - : const SizedBox.shrink(), - FittedBox( - fit: BoxFit.scaleDown, - child: Padding( - padding: const EdgeInsets.only(top: 8), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - OutlinedButton.icon( - style: OutlinedButton.styleFrom( - side: const BorderSide( - width: 2, + state.playlist.description != null + ? Text( + state.playlist.description ?? "", + style: Default_Theme + .secondoryTextStyle + .merge( + TextStyle( + overflow: + TextOverflow.ellipsis, + fontSize: 13, color: Default_Theme - .accentColor2, + .primaryColor1 + .withOpacity(0.5), ), ), - onPressed: () { - if (context + ) + : const SizedBox.shrink(), + FittedBox( + fit: BoxFit.scaleDown, + child: Padding( + padding: + const EdgeInsets.only(top: 8), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + OutlinedButton.icon( + style: OutlinedButton.styleFrom( + side: const BorderSide( + width: 2, + color: Default_Theme + .accentColor2, + ), + ), + onPressed: () { + if (context + .read< + BloomeePlayerCubit>() + .bloomeePlayer + .queueTitle + .value != + widget.playlist.name) { + context .read< BloomeePlayerCubit>() .bloomeePlayer - .queueTitle - .value != - widget.playlist.name) { - context - .read< - BloomeePlayerCubit>() - .bloomeePlayer - .loadPlaylist( - state.playlist - .playlist, - doPlay: true, - idx: 0); - } else if (!context - .read() - .bloomeePlayer - .audioPlayer - .playing) { - context + .loadPlaylist( + state.playlist + .playlist, + doPlay: true, + idx: 0); + } else if (!context .read< BloomeePlayerCubit>() .bloomeePlayer - .play(); - } - }, - label: const Text( - "Play", - style: Default_Theme - .secondoryTextStyleMedium, - ), - icon: const Icon( - MingCute.play_fill, - size: 20, - ), - ), - Padding( - padding: const EdgeInsets.only( - left: 5, + .audioPlayer + .playing) { + context + .read< + BloomeePlayerCubit>() + .bloomeePlayer + .play(); + } + }, + label: const Text( + "Play", + style: Default_Theme + .secondoryTextStyleMedium, + ), + icon: const Icon( + MingCute.play_fill, + size: 20, + ), ), - child: Tooltip( - message: "Open Original Link", - child: IconButton( - onPressed: () { - SnackbarService.showMessage( - "Opening original album page."); - launchUrl( - Uri.parse(state.playlist - .sourceURL), - mode: LaunchMode - .externalApplication); - }, - icon: const Icon( - MingCute.external_link_line, - size: 25, + Padding( + padding: const EdgeInsets.only( + left: 5, + ), + child: Tooltip( + message: "Open Original Link", + child: IconButton( + onPressed: () { + SnackbarService.showMessage( + "Opening original album page."); + launchUrl( + Uri.parse(state + .playlist + .sourceURL), + mode: LaunchMode + .externalApplication); + }, + icon: const Icon( + MingCute + .external_link_line, + size: 25, + ), ), ), ), - ), - ], + ], + ), ), - ), - ) - ], + ) + ], + ), ), - ), - ) - ], + ) + ], + ), ), ), + ); + }), + ), + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.only( + left: 16, + right: 16, + bottom: 8, ), - ); - }), - ), - SliverToBoxAdapter( - child: Padding( - padding: const EdgeInsets.only( - left: 16, - right: 16, - bottom: 8, - ), - child: Text( - widget.playlist.name, - maxLines: 3, - textAlign: TextAlign.center, - style: Default_Theme.secondoryTextStyleMedium.merge( - TextStyle( - fontSize: 20, - color: Default_Theme.primaryColor1.withOpacity(0.8), + child: Text( + widget.playlist.name, + maxLines: 3, + textAlign: TextAlign.center, + style: Default_Theme.secondoryTextStyleMedium.merge( + TextStyle( + fontSize: 20, + color: Default_Theme.primaryColor1.withOpacity(0.8), + ), ), ), ), ), - ), - (state is OnlPlaylistLoaded) - ? SliverList.builder( - itemBuilder: (context, index) { - return SongCardWidget( - song: state.playlist.songs[index], - onOptionsTap: () { - showMoreBottomSheet( - context, state.playlist.songs[index], - showDelete: false); - }, - onTap: () { - if (context - .read() - .bloomeePlayer - .queueTitle - .value != - widget.playlist.name || + (state is OnlPlaylistLoaded) + ? SliverList.builder( + itemBuilder: (context, index) { + return SongCardWidget( + song: state.playlist.songs[index], + onOptionsTap: () { + showMoreBottomSheet( + context, state.playlist.songs[index], + showDelete: false); + }, + onTap: () { + if (context + .read() + .bloomeePlayer + .queueTitle + .value != + widget.playlist.name || + context + .read() + .bloomeePlayer + .currentMedia != + state.playlist.songs[index]) { context - .read() - .bloomeePlayer - .currentMedia != - state.playlist.songs[index]) { - context + .read() + .bloomeePlayer + .loadPlaylist(state.playlist.playlist, + doPlay: true, idx: index); + } else if (!context .read() .bloomeePlayer - .loadPlaylist(state.playlist.playlist, - doPlay: true, idx: index); - } else if (!context - .read() - .bloomeePlayer - .audioPlayer - .playing) { - context - .read() - .bloomeePlayer - .play(); - } - }, - ); - }, - itemCount: state.playlist.songs.length) - : const SliverFillRemaining( - hasScrollBody: false, - child: Center( - child: CircularProgressIndicator(), - )), - ], - ); - }, + .audioPlayer + .playing) { + context + .read() + .bloomeePlayer + .play(); + } + }, + ); + }, + itemCount: state.playlist.songs.length) + : const SliverFillRemaining( + hasScrollBody: false, + child: Center( + child: CircularProgressIndicator(), + )), + ], + ); + }, + ), ), ); } diff --git a/lib/screens/screen/explore_screen.dart b/lib/screens/screen/explore_screen.dart index 2bf9da0..f75155b 100644 --- a/lib/screens/screen/explore_screen.dart +++ b/lib/screens/screen/explore_screen.dart @@ -49,125 +49,129 @@ class _ExploreScreenState extends State { @override Widget build(BuildContext context) { - return MultiBlocProvider( - providers: [ - BlocProvider( - create: (context) => RecentlyCubit(), - lazy: false, - ), - BlocProvider( - create: (context) => yTMusicCubit, - lazy: false, - ), - BlocProvider( - create: (context) => FetchChartCubit(), - lazy: false, - ), - ], - child: Scaffold( - body: RefreshIndicator( - onRefresh: () async { - await yTMusicCubit.fetchYTMusic(); - log("Refreshed"); - }, - child: CustomScrollView( - shrinkWrap: true, - physics: const ClampingScrollPhysics(), - slivers: [ - customDiscoverBar(context), //AppBar - SliverList( - delegate: SliverChildListDelegate( - [ - CaraouselWidget(), - Padding( - padding: const EdgeInsets.only(top: 15.0), - child: SizedBox( - child: BlocBuilder( - builder: (context, state) { - return AnimatedSwitcher( - duration: const Duration(milliseconds: 1000), - child: state is RecentlyCubitInitial - ? const Center( - child: SizedBox( - height: 60, - width: 60, - child: CircularProgressIndicator( - color: Default_Theme.accentColor2, - )), - ) - : ((state.mediaPlaylist.mediaItems.isNotEmpty) - ? InkWell( - onTap: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => - const HistoryView())); - }, - child: TabSongListWidget( - list: state.mediaPlaylist.mediaItems - .map((e) { - return SongCardWidget( - song: e, - onTap: () { - context - .read< - BloomeePlayerCubit>() - .bloomeePlayer - .addQueueItem( - e, - doPlay: true, - ); + return SafeArea( + child: MultiBlocProvider( + providers: [ + BlocProvider( + create: (context) => RecentlyCubit(), + lazy: false, + ), + BlocProvider( + create: (context) => yTMusicCubit, + lazy: false, + ), + BlocProvider( + create: (context) => FetchChartCubit(), + lazy: false, + ), + ], + child: Scaffold( + body: RefreshIndicator( + onRefresh: () async { + await yTMusicCubit.fetchYTMusic(); + log("Refreshed"); + }, + child: CustomScrollView( + shrinkWrap: true, + physics: const ClampingScrollPhysics(), + slivers: [ + customDiscoverBar(context), //AppBar + SliverList( + delegate: SliverChildListDelegate( + [ + CaraouselWidget(), + Padding( + padding: const EdgeInsets.only(top: 15.0), + child: SizedBox( + child: BlocBuilder( + builder: (context, state) { + return AnimatedSwitcher( + duration: const Duration(milliseconds: 1000), + child: state is RecentlyCubitInitial + ? const Center( + child: SizedBox( + height: 60, + width: 60, + child: CircularProgressIndicator( + color: Default_Theme.accentColor2, + )), + ) + : ((state.mediaPlaylist.mediaItems + .isNotEmpty) + ? InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => + const HistoryView())); + }, + child: TabSongListWidget( + list: state + .mediaPlaylist.mediaItems + .map((e) { + return SongCardWidget( + song: e, + onTap: () { + context + .read< + BloomeePlayerCubit>() + .bloomeePlayer + .addQueueItem( + e, + doPlay: true, + ); - // context - // .read() - // .downloadSong(e); - }, - onOptionsTap: () => - showMoreBottomSheet( - context, e), - ); - }).toList(), - category: "Recently", - columnSize: 3, - ), - ) - : const SizedBox()), - ); - }, + // context + // .read() + // .downloadSong(e); + }, + onOptionsTap: () => + showMoreBottomSheet( + context, e), + ); + }).toList(), + category: "Recently", + columnSize: 3, + ), + ) + : const SizedBox()), + ); + }, + ), ), ), - ), - BlocBuilder( - builder: (context, state) { - return AnimatedSwitcher( - duration: const Duration(milliseconds: 400), - child: state is YTMusicCubitInitial - ? BlocBuilder( - builder: (context, state2) { - if ((state2 == - ConnectivityState.disconnected)) { - return const SignBoardWidget( - message: "No Internet Connection!", - icon: MingCute.wifi_off_line, - ); - } else { - return const SizedBox(); - } - }, - ) - : ytSection(state.ytmData), - ); - }, - ), - ], - ), - ) - ], + BlocBuilder( + builder: (context, state) { + return AnimatedSwitcher( + duration: const Duration(milliseconds: 400), + child: state is YTMusicCubitInitial + ? BlocBuilder( + builder: (context, state2) { + if ((state2 == + ConnectivityState.disconnected)) { + return const SignBoardWidget( + message: "No Internet Connection!", + icon: MingCute.wifi_off_line, + ); + } else { + return const SizedBox(); + } + }, + ) + : ytSection(state.ytmData), + ); + }, + ), + ], + ), + ) + ], + ), ), + backgroundColor: Default_Theme.themeColor, ), - backgroundColor: Default_Theme.themeColor, ), ); } diff --git a/lib/screens/screen/home_views/recents_view.dart b/lib/screens/screen/home_views/recents_view.dart index 86310ee..f9dde10 100644 --- a/lib/screens/screen/home_views/recents_view.dart +++ b/lib/screens/screen/home_views/recents_view.dart @@ -14,67 +14,69 @@ class HistoryView extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Default_Theme.themeColor, - appBar: AppBar( - centerTitle: true, - actions: [ - IconButton( - icon: const Icon( - MingCute.settings_1_line, - color: Default_Theme.primaryColor1, + return SafeArea( + child: Scaffold( + backgroundColor: Default_Theme.themeColor, + appBar: AppBar( + centerTitle: true, + actions: [ + IconButton( + icon: const Icon( + MingCute.settings_1_line, + color: Default_Theme.primaryColor1, + ), + onPressed: () { + Navigator.push( + context, + MaterialPageRoute( + builder: (context) => const BackupSettings(), + ), + ); + }, ), - onPressed: () { - Navigator.push( - context, - MaterialPageRoute( - builder: (context) => const BackupSettings(), - ), - ); - }, + ], + backgroundColor: Default_Theme.themeColor, + surfaceTintColor: Default_Theme.themeColor, + foregroundColor: Default_Theme.primaryColor1, + title: Text( + 'History', + style: const TextStyle( + color: Default_Theme.primaryColor1, + fontSize: 20, + fontWeight: FontWeight.bold) + .merge(Default_Theme.secondoryTextStyle), ), - ], - backgroundColor: Default_Theme.themeColor, - surfaceTintColor: Default_Theme.themeColor, - foregroundColor: Default_Theme.primaryColor1, - title: Text( - 'History', - style: const TextStyle( - color: Default_Theme.primaryColor1, - fontSize: 20, - fontWeight: FontWeight.bold) - .merge(Default_Theme.secondoryTextStyle), ), - ), - body: BlocProvider( - create: (context) => HistoryCubit(), - child: BlocBuilder( - builder: (context, state) { - return (state is HistoryInitial) - ? const Center( - child: CircularProgressIndicator(), - ) - : ListView.builder( - itemCount: state.mediaPlaylist.mediaItems.length, - shrinkWrap: true, - physics: const BouncingScrollPhysics(), - itemBuilder: (context, index) { - return SongCardWidget( - song: state.mediaPlaylist.mediaItems[index], - onTap: () { - context - .read() - .bloomeePlayer - .addQueueItem( - state.mediaPlaylist.mediaItems[index], - ); - }, - onOptionsTap: () => showMoreBottomSheet( - context, state.mediaPlaylist.mediaItems[index]), - ); - }, - ); - }, + body: BlocProvider( + create: (context) => HistoryCubit(), + child: BlocBuilder( + builder: (context, state) { + return (state is HistoryInitial) + ? const Center( + child: CircularProgressIndicator(), + ) + : ListView.builder( + itemCount: state.mediaPlaylist.mediaItems.length, + shrinkWrap: true, + physics: const BouncingScrollPhysics(), + itemBuilder: (context, index) { + return SongCardWidget( + song: state.mediaPlaylist.mediaItems[index], + onTap: () { + context + .read() + .bloomeePlayer + .addQueueItem( + state.mediaPlaylist.mediaItems[index], + ); + }, + onOptionsTap: () => showMoreBottomSheet( + context, state.mediaPlaylist.mediaItems[index]), + ); + }, + ); + }, + ), ), ), ); diff --git a/lib/screens/screen/library_screen.dart b/lib/screens/screen/library_screen.dart index 7423804..f964e74 100644 --- a/lib/screens/screen/library_screen.dart +++ b/lib/screens/screen/library_screen.dart @@ -17,36 +17,38 @@ class LibraryScreen extends StatelessWidget { const LibraryScreen({super.key}); @override Widget build(BuildContext context) { - return Scaffold( - body: CustomScrollView( - physics: const BouncingScrollPhysics(), - slivers: [ - customDiscoverBar(context), //AppBar - BlocBuilder( - builder: (context, state) { - if (state is LibraryItemsInitial) { - return const SliverToBoxAdapter( - child: Center( - child: CircularProgressIndicator(), - ), - ); - } else if (state is! LibraryItemsInitial) { - return ListOfPlaylists(state: state); - } else { - return const SliverToBoxAdapter( - child: Center( - child: SignBoardWidget( - message: "No Playlists Found!", - icon: MingCute.playlist_fill, + return SafeArea( + child: Scaffold( + body: CustomScrollView( + physics: const BouncingScrollPhysics(), + slivers: [ + customDiscoverBar(context), //AppBar + BlocBuilder( + builder: (context, state) { + if (state is LibraryItemsInitial) { + return const SliverToBoxAdapter( + child: Center( + child: CircularProgressIndicator(), ), - ), - ); - } - }, - ), - ], + ); + } else if (state is! LibraryItemsInitial) { + return ListOfPlaylists(state: state); + } else { + return const SliverToBoxAdapter( + child: Center( + child: SignBoardWidget( + message: "No Playlists Found!", + icon: MingCute.playlist_fill, + ), + ), + ); + } + }, + ), + ], + ), + backgroundColor: Default_Theme.themeColor, ), - backgroundColor: Default_Theme.themeColor, ); } diff --git a/lib/screens/screen/offline_screen.dart b/lib/screens/screen/offline_screen.dart index 0118761..440da4c 100644 --- a/lib/screens/screen/offline_screen.dart +++ b/lib/screens/screen/offline_screen.dart @@ -14,55 +14,57 @@ class OfflineScreen extends StatelessWidget { const OfflineScreen({super.key}); @override Widget build(BuildContext context) { - return BlocProvider( - create: (context) => - OfflineCubit(libraryItemsCubit: context.read()), - child: Scaffold( - body: CustomScrollView( - slivers: [ - customDiscoverBar(context), //AppBar - SliverList( - delegate: SliverChildListDelegate([ - BlocBuilder( - builder: (context, state) { - if (state is OfflineInitial) { - return const CircularProgressIndicator(); - } else if (state is OfflineEmpty) { - return const SignBoardWidget( - message: "No Downloads", - icon: FontAwesome.download_solid, - ); - } else { - return Column( - children: state.songs - .map((e) => SongCardWidget( - song: e, - showOptions: true, - delDownBtn: true, - onTap: () { - context - .read() - .bloomeePlayer - .loadPlaylist( - MediaPlaylist( - mediaItems: state.songs, - playlistName: "Offline"), - idx: state.songs.indexOf(e), - doPlay: true); - }, - onOptionsTap: () { - showMoreBottomSheet(context, e, - showDelete: false); - }, - )) - .toList(), - ); - } - }) - ])) - ], + return SafeArea( + child: BlocProvider( + create: (context) => + OfflineCubit(libraryItemsCubit: context.read()), + child: Scaffold( + body: CustomScrollView( + slivers: [ + customDiscoverBar(context), //AppBar + SliverList( + delegate: SliverChildListDelegate([ + BlocBuilder( + builder: (context, state) { + if (state is OfflineInitial) { + return const CircularProgressIndicator(); + } else if (state is OfflineEmpty) { + return const SignBoardWidget( + message: "No Downloads", + icon: FontAwesome.download_solid, + ); + } else { + return Column( + children: state.songs + .map((e) => SongCardWidget( + song: e, + showOptions: true, + delDownBtn: true, + onTap: () { + context + .read() + .bloomeePlayer + .loadPlaylist( + MediaPlaylist( + mediaItems: state.songs, + playlistName: "Offline"), + idx: state.songs.indexOf(e), + doPlay: true); + }, + onOptionsTap: () { + showMoreBottomSheet(context, e, + showDelete: false); + }, + )) + .toList(), + ); + } + }) + ])) + ], + ), + backgroundColor: Default_Theme.themeColor, ), - backgroundColor: Default_Theme.themeColor, ), ); } diff --git a/lib/screens/screen/search_screen.dart b/lib/screens/screen/search_screen.dart index de106a5..80daa80 100644 --- a/lib/screens/screen/search_screen.dart +++ b/lib/screens/screen/search_screen.dart @@ -128,374 +128,387 @@ class _SearchScreenState extends State { @override Widget build(BuildContext context) { - return GestureDetector( - onTap: () => FocusManager.instance.primaryFocus?.unfocus(), - onVerticalDragEnd: (DragEndDetails details) => - FocusManager.instance.primaryFocus?.unfocus(), - child: Scaffold( - appBar: AppBar( - shadowColor: Colors.black, - surfaceTintColor: Default_Theme.themeColor, - title: SizedBox( - height: 50.0, - child: Padding( - padding: const EdgeInsets.only( - top: 10, - ), - child: InkWell( - borderRadius: BorderRadius.circular(20), - onTap: () { - showSearch( - context: context, - delegate: SearchPageDelegate( - _sourceEngine, resultType.value), - query: _textEditingController.text) - .then((value) { - if (value != null) { - _textEditingController.text = value.toString(); - } - }); - }, - child: TextField( - controller: _textEditingController, - enabled: false, - textAlign: TextAlign.center, - style: TextStyle( - color: Default_Theme.primaryColor1.withOpacity(0.55)), - textInputAction: TextInputAction.search, - decoration: InputDecoration( - filled: true, - suffixIcon: Icon( - MingCute.search_2_fill, - color: Default_Theme.primaryColor1.withOpacity(0.4), - ), - fillColor: Default_Theme.primaryColor2.withOpacity(0.07), - contentPadding: - const EdgeInsets.only(top: 20, left: 15, right: 5), - hintText: "Find your next song obsession...", - hintStyle: TextStyle( - color: Default_Theme.primaryColor1.withOpacity(0.3), - fontFamily: "Unageo", - fontWeight: FontWeight.normal, - ), - disabledBorder: OutlineInputBorder( - borderSide: const BorderSide(style: BorderStyle.none), - borderRadius: BorderRadius.circular(50)), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide( - color: - Default_Theme.primaryColor1.withOpacity(0.7)), - borderRadius: BorderRadius.circular(50))), + return SafeArea( + child: GestureDetector( + onTap: () => FocusManager.instance.primaryFocus?.unfocus(), + onVerticalDragEnd: (DragEndDetails details) => + FocusManager.instance.primaryFocus?.unfocus(), + child: Scaffold( + appBar: AppBar( + shadowColor: Colors.black, + surfaceTintColor: Default_Theme.themeColor, + title: SizedBox( + height: 50.0, + child: Padding( + padding: const EdgeInsets.only( + top: 10, + ), + child: InkWell( + borderRadius: BorderRadius.circular(20), + onTap: () { + showSearch( + context: context, + delegate: SearchPageDelegate( + _sourceEngine, resultType.value), + query: _textEditingController.text) + .then((value) { + if (value != null) { + _textEditingController.text = value.toString(); + } + }); + }, + child: TextField( + controller: _textEditingController, + enabled: false, + textAlign: TextAlign.center, + style: TextStyle( + color: Default_Theme.primaryColor1.withOpacity(0.55)), + textInputAction: TextInputAction.search, + decoration: InputDecoration( + filled: true, + suffixIcon: Icon( + MingCute.search_2_fill, + color: Default_Theme.primaryColor1.withOpacity(0.4), + ), + fillColor: + Default_Theme.primaryColor2.withOpacity(0.07), + contentPadding: + const EdgeInsets.only(top: 20, left: 15, right: 5), + hintText: "Find your next song obsession...", + hintStyle: TextStyle( + color: Default_Theme.primaryColor1.withOpacity(0.3), + fontFamily: "Unageo", + fontWeight: FontWeight.normal, + ), + disabledBorder: OutlineInputBorder( + borderSide: + const BorderSide(style: BorderStyle.none), + borderRadius: BorderRadius.circular(50)), + focusedBorder: OutlineInputBorder( + borderSide: BorderSide( + color: Default_Theme.primaryColor1 + .withOpacity(0.7)), + borderRadius: BorderRadius.circular(50))), + ), ), ), ), + backgroundColor: Default_Theme.themeColor, ), backgroundColor: Default_Theme.themeColor, - ), - backgroundColor: Default_Theme.themeColor, - body: NestedScrollView( - headerSliverBuilder: (context, innerBoxIsScrolled) => [ - SliverToBoxAdapter( - child: Padding( - padding: const EdgeInsets.only( - left: 18, right: 18, top: 5, bottom: 5), - child: FutureBuilder( - future: availableSourceEngines(), - builder: (context, snapshot) { - return snapshot.hasData || snapshot.data != null - ? Wrap( - direction: Axis.horizontal, - runSpacing: 8, - alignment: WrapAlignment.start, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - SizedBox( - height: 30, - width: 100, - child: Padding( - padding: const EdgeInsets.only(right: 8), - child: ValueListenableBuilder( - valueListenable: resultType, - builder: (context, value, child) { - return DropdownButtonFormField( - key: UniqueKey(), - isExpanded: false, - isDense: true, - alignment: Alignment.center, - borderRadius: - BorderRadius.circular(20), - padding: const EdgeInsets.all(0), - focusColor: Colors.transparent, - dropdownColor: - const Color.fromARGB( - 255, 15, 15, 15), - decoration: InputDecoration( - filled: false, - fillColor: Default_Theme - .primaryColor2 - .withOpacity(0.07), - contentPadding: - const EdgeInsets.all(0), - focusColor: - Default_Theme.accentColor2, - border: OutlineInputBorder( - borderSide: - const BorderSide( - style: BorderStyle - .none), - borderRadius: - BorderRadius.circular( - 20)), - enabledBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - style: - BorderStyle - .none), - borderRadius: - BorderRadius - .circular(20)), - focusedBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - style: - BorderStyle - .none), - borderRadius: - BorderRadius - .circular(20)), - disabledBorder: - OutlineInputBorder( - borderSide: - const BorderSide( - style: - BorderStyle - .none), - borderRadius: - BorderRadius - .circular(20)), + body: NestedScrollView( + headerSliverBuilder: (context, innerBoxIsScrolled) => [ + SliverToBoxAdapter( + child: Padding( + padding: const EdgeInsets.only( + left: 18, right: 18, top: 5, bottom: 5), + child: FutureBuilder( + future: availableSourceEngines(), + builder: (context, snapshot) { + return snapshot.hasData || snapshot.data != null + ? Wrap( + direction: Axis.horizontal, + runSpacing: 8, + alignment: WrapAlignment.start, + crossAxisAlignment: WrapCrossAlignment.center, + children: [ + SizedBox( + height: 30, + width: 100, + child: Padding( + padding: + const EdgeInsets.only(right: 8), + child: ValueListenableBuilder( + valueListenable: resultType, + builder: (context, value, child) { + return DropdownButtonFormField( + key: UniqueKey(), + isExpanded: false, isDense: true, - ), - value: resultType.value.index, - items: ResultTypes.values - .map((e) => DropdownMenuItem( - value: e.index, - child: SizedBox( - height: 32, - child: Padding( - padding: - const EdgeInsets - .only( - left: 8, - top: 2, - bottom: 4, - ), - child: Text( - e.val, - style: Default_Theme - .secondoryTextStyleMedium - .merge( - const TextStyle( - color: Default_Theme - .primaryColor1, - fontSize: 13.5, - )), - ), - ), - ), - )) - .toList(), - onChanged: (value) { - resultType.value = - ResultTypes.values[value!]; - context - .read< - FetchSearchResultsCubit>() - .checkAndRefreshSearch( - query: - _textEditingController - .text - .toString(), - sE: _sourceEngine, - rT: resultType.value, - ); - }, - ); - }), + alignment: Alignment.center, + borderRadius: + BorderRadius.circular(20), + padding: + const EdgeInsets.all(0), + focusColor: Colors.transparent, + dropdownColor: + const Color.fromARGB( + 255, 15, 15, 15), + decoration: InputDecoration( + filled: false, + fillColor: Default_Theme + .primaryColor2 + .withOpacity(0.07), + contentPadding: + const EdgeInsets.all(0), + focusColor: Default_Theme + .accentColor2, + border: OutlineInputBorder( + borderSide: + const BorderSide( + style: BorderStyle + .none), + borderRadius: + BorderRadius.circular( + 20)), + enabledBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + style: + BorderStyle + .none), + borderRadius: + BorderRadius + .circular( + 20)), + focusedBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + style: + BorderStyle + .none), + borderRadius: + BorderRadius + .circular( + 20)), + disabledBorder: + OutlineInputBorder( + borderSide: + const BorderSide( + style: + BorderStyle + .none), + borderRadius: + BorderRadius + .circular( + 20)), + isDense: true, + ), + value: resultType.value.index, + items: ResultTypes.values + .map( + (e) => DropdownMenuItem( + value: e.index, + child: SizedBox( + height: 32, + child: Padding( + padding: + const EdgeInsets + .only( + left: 8, + top: 2, + bottom: 4, + ), + child: Text( + e.val, + style: Default_Theme + .secondoryTextStyleMedium + .merge( + const TextStyle( + color: Default_Theme + .primaryColor1, + fontSize: + 13.5, + )), + ), + ), + ), + )) + .toList(), + onChanged: (value) { + resultType.value = ResultTypes + .values[value!]; + context + .read< + FetchSearchResultsCubit>() + .checkAndRefreshSearch( + query: + _textEditingController + .text + .toString(), + sE: _sourceEngine, + rT: resultType.value, + ); + }, + ); + }), + ), ), - ), - for (var sourceEngine in availSourceEngines) - sourceEngineRadioButton(sourceEngine) - ]) - : const SizedBox(); - }), + for (var sourceEngine in availSourceEngines) + sourceEngineRadioButton(sourceEngine) + ]) + : const SizedBox(); + }), + ), ), - ), - ], - body: BlocBuilder( - builder: (context, state) { - return AnimatedSwitcher( - duration: const Duration(milliseconds: 600), - child: state == ConnectivityState.disconnected - ? const SignBoardWidget( - icon: MingCute.wifi_off_line, - message: "No internet connection!", - ) - : BlocConsumer( - builder: (context, state) { - if (state is FetchSearchResultsLoading) { - return const Center( - child: CircularProgressIndicator( - color: Default_Theme.accentColor2, - ), - ); - } else if (state.loadingState == - LoadingState.loaded) { - if (state.resultType == ResultTypes.songs && - state.mediaItems.isNotEmpty) { - log("Search Results: ${state.mediaItems.length}", - name: "SearchScreen"); - return ListView.builder( - controller: _scrollController, - itemCount: state.hasReachedMax - ? state.mediaItems.length - : state.mediaItems.length + 1, - itemBuilder: (context, index) { - if (index == state.mediaItems.length) { - return const Center( - child: SizedBox( - height: 30, - width: 30, - child: CircularProgressIndicator( - color: Default_Theme.accentColor2, + ], + body: BlocBuilder( + builder: (context, state) { + return AnimatedSwitcher( + duration: const Duration(milliseconds: 600), + child: state == ConnectivityState.disconnected + ? const SignBoardWidget( + icon: MingCute.wifi_off_line, + message: "No internet connection!", + ) + : BlocConsumer( + builder: (context, state) { + if (state is FetchSearchResultsLoading) { + return const Center( + child: CircularProgressIndicator( + color: Default_Theme.accentColor2, + ), + ); + } else if (state.loadingState == + LoadingState.loaded) { + if (state.resultType == ResultTypes.songs && + state.mediaItems.isNotEmpty) { + log("Search Results: ${state.mediaItems.length}", + name: "SearchScreen"); + return ListView.builder( + controller: _scrollController, + itemCount: state.hasReachedMax + ? state.mediaItems.length + : state.mediaItems.length + 1, + itemBuilder: (context, index) { + if (index == state.mediaItems.length) { + return const Center( + child: SizedBox( + height: 30, + width: 30, + child: CircularProgressIndicator( + color: Default_Theme.accentColor2, + ), ), - ), - ); - } - return Padding( - padding: const EdgeInsets.only(left: 4), - child: SongCardWidget( - song: state.mediaItems[index], - onTap: () { - if (!listEquals( + ); + } + return Padding( + padding: const EdgeInsets.only(left: 4), + child: SongCardWidget( + song: state.mediaItems[index], + onTap: () { + if (!listEquals( + context + .read() + .bloomeePlayer + .queue + .value, + state.mediaItems)) { context .read() .bloomeePlayer - .queue - .value, - state.mediaItems)) { - context - .read() - .bloomeePlayer - .loadPlaylist( - MediaPlaylist( - playlistName: "Search", - mediaItems: - state.mediaItems), - idx: index, - doPlay: true); - } else if (context + .loadPlaylist( + MediaPlaylist( + playlistName: + "Search", + mediaItems: + state.mediaItems), + idx: index, + doPlay: true); + } else if (context + .read() + .bloomeePlayer + .currentMedia != + state.mediaItems[index]) { + context .read() .bloomeePlayer - .currentMedia != - state.mediaItems[index]) { - context - .read() - .bloomeePlayer - .prepare4play( - idx: index, doPlay: true); - } + .prepare4play( + idx: index, doPlay: true); + } - context.push('/MusicPlayer'); - }, - onOptionsTap: () => showMoreBottomSheet( - context, state.mediaItems[index]), + context.push('/MusicPlayer'); + }, + onOptionsTap: () => + showMoreBottomSheet(context, + state.mediaItems[index]), + ), + ); + }, + ); + } else if (state.resultType == + ResultTypes.albums && + state.albumItems.isNotEmpty) { + return Align( + alignment: Alignment.topCenter, + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Wrap( + alignment: WrapAlignment.center, + runSpacing: 10, + children: [ + for (var album in state.albumItems) + AlbumCard(album: album) + ], ), - ); - }, - ); - } else if (state.resultType == - ResultTypes.albums && - state.albumItems.isNotEmpty) { - return Align( - alignment: Alignment.topCenter, - child: SingleChildScrollView( - physics: const BouncingScrollPhysics(), - child: Wrap( - alignment: WrapAlignment.center, - runSpacing: 10, - children: [ - for (var album in state.albumItems) - AlbumCard(album: album) - ], ), - ), - ); - } else if (state.resultType == - ResultTypes.artists && - state.artistItems.isNotEmpty) { - return Align( - alignment: Alignment.topCenter, - child: SingleChildScrollView( - physics: const BouncingScrollPhysics(), - child: Wrap( - alignment: WrapAlignment.center, - runSpacing: 10, - children: [ - for (var artist in state.artistItems) - ArtistCard(artist: artist) - ], + ); + } else if (state.resultType == + ResultTypes.artists && + state.artistItems.isNotEmpty) { + return Align( + alignment: Alignment.topCenter, + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Wrap( + alignment: WrapAlignment.center, + runSpacing: 10, + children: [ + for (var artist in state.artistItems) + ArtistCard(artist: artist) + ], + ), ), - ), - ); - } else if (state.resultType == - ResultTypes.playlists && - state.playlistItems.isNotEmpty) { - return Align( - alignment: Alignment.topCenter, - child: SingleChildScrollView( - physics: const BouncingScrollPhysics(), - child: Wrap( - alignment: WrapAlignment.center, - runSpacing: 10, - children: [ - for (var playlist - in state.playlistItems) - PlaylistCard( - playlist: playlist, - sourceEngine: _sourceEngine, - ) - ], + ); + } else if (state.resultType == + ResultTypes.playlists && + state.playlistItems.isNotEmpty) { + return Align( + alignment: Alignment.topCenter, + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Wrap( + alignment: WrapAlignment.center, + runSpacing: 10, + children: [ + for (var playlist + in state.playlistItems) + PlaylistCard( + playlist: playlist, + sourceEngine: _sourceEngine, + ) + ], + ), ), - ), - ); + ); + } else { + return const SignBoardWidget( + message: + "No results found!\nTry another keyword or source engine!", + icon: MingCute.sweats_line); + } } else { return const SignBoardWidget( message: - "No results found!\nTry another keyword or source engine!", - icon: MingCute.sweats_line); + "Search for your favorite songs\nand discover new ones!", + icon: MingCute.search_2_line); } - } else { - return const SignBoardWidget( - message: - "Search for your favorite songs\nand discover new ones!", - icon: MingCute.search_2_line); - } - }, - listener: (BuildContext context, - FetchSearchResultsState state) { - resultType.value = state.resultType; - if (state is! FetchSearchResultsLoaded && - state is! FetchSearchResultsInitial) { - _sourceEngine = - state.sourceEngine ?? _sourceEngine; - } - }, - )); - }, + }, + listener: (BuildContext context, + FetchSearchResultsState state) { + resultType.value = state.resultType; + if (state is! FetchSearchResultsLoaded && + state is! FetchSearchResultsInitial) { + _sourceEngine = + state.sourceEngine ?? _sourceEngine; + } + }, + )); + }, + ), ), ), ),