mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-12 23:45:18 +00:00
Overflow Album error fix
playtrack from found song in Search search on TexField submit
This commit is contained in:
parent
79ef853ac9
commit
4f14849502
@ -4,11 +4,8 @@ import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:hotkey_manager/hotkey_manager.dart';
|
||||
import 'package:just_audio/just_audio.dart';
|
||||
import 'package:spotify/spotify.dart';
|
||||
import 'package:spotube/components/Artist/ArtistProfile.dart';
|
||||
import 'package:spotube/components/Shared/DownloadTrackButton.dart';
|
||||
import 'package:spotube/components/Player/PlayerControls.dart';
|
||||
import 'package:spotube/components/Shared/LinkText.dart';
|
||||
import 'package:spotube/helpers/artist-to-string.dart';
|
||||
import 'package:spotube/helpers/artists-to-clickable-artists.dart';
|
||||
import 'package:spotube/helpers/image-to-url-string.dart';
|
||||
import 'package:spotube/helpers/search-youtube.dart';
|
||||
|
@ -20,6 +20,7 @@ class Search extends StatefulWidget {
|
||||
|
||||
class _SearchState extends State<Search> {
|
||||
late TextEditingController _controller;
|
||||
|
||||
String searchTerm = "";
|
||||
|
||||
@override
|
||||
@ -43,6 +44,11 @@ class _SearchState extends State<Search> {
|
||||
child: TextField(
|
||||
decoration: const InputDecoration(hintText: "Search..."),
|
||||
controller: _controller,
|
||||
onSubmitted: (value) {
|
||||
setState(() {
|
||||
searchTerm = _controller.value.text;
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 5),
|
||||
@ -64,7 +70,7 @@ class _SearchState extends State<Search> {
|
||||
),
|
||||
FutureBuilder<List<Page>>(
|
||||
future: searchTerm.isNotEmpty
|
||||
? spotify.search.get(searchTerm).first(5)
|
||||
? spotify.search.get(searchTerm).first(10)
|
||||
: null,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData && searchTerm.isNotEmpty) {
|
||||
@ -116,7 +122,27 @@ class _SearchState extends State<Search> {
|
||||
duration: duration,
|
||||
thumbnailUrl:
|
||||
imageToUrlString(track.value.album?.images),
|
||||
onTrackPlayButtonPressed: (currentTrack) {},
|
||||
onTrackPlayButtonPressed: (currentTrack) async {
|
||||
var isPlaylistPlaying =
|
||||
playback.currentPlaylist?.id != null &&
|
||||
playback.currentPlaylist?.id ==
|
||||
currentTrack.id;
|
||||
if (!isPlaylistPlaying) {
|
||||
playback.setCurrentPlaylist = CurrentPlaylist(
|
||||
tracks: [currentTrack],
|
||||
id: currentTrack.id!,
|
||||
name: currentTrack.name!,
|
||||
thumbnail: imageToUrlString(
|
||||
currentTrack.album?.images),
|
||||
);
|
||||
playback.setCurrentTrack = currentTrack;
|
||||
} else if (isPlaylistPlaying &&
|
||||
currentTrack.id != null &&
|
||||
currentTrack.id !=
|
||||
playback.currentTrack?.id) {
|
||||
playback.setCurrentTrack = currentTrack;
|
||||
}
|
||||
},
|
||||
);
|
||||
}),
|
||||
if (albums.isNotEmpty)
|
||||
@ -125,13 +151,15 @@ class _SearchState extends State<Search> {
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
Center(
|
||||
child: Wrap(
|
||||
spacing: 20,
|
||||
runSpacing: 20,
|
||||
children: albums.map((album) {
|
||||
return AlbumCard(simpleAlbumToAlbum(album));
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (artists.isNotEmpty)
|
||||
Text(
|
||||
@ -139,13 +167,15 @@ class _SearchState extends State<Search> {
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
Center(
|
||||
child: Wrap(
|
||||
spacing: 20,
|
||||
runSpacing: 20,
|
||||
children: artists.map((artist) {
|
||||
return ArtistCard(artist);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 20),
|
||||
if (playlists.isNotEmpty)
|
||||
Text(
|
||||
@ -153,13 +183,15 @@ class _SearchState extends State<Search> {
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
Wrap(
|
||||
Center(
|
||||
child: Wrap(
|
||||
spacing: 20,
|
||||
runSpacing: 20,
|
||||
children: playlists.map((playlist) {
|
||||
return PlaylistCard(playlist);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -81,17 +81,13 @@ class TracksTableView extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: Row(
|
||||
children: [
|
||||
LinkText(
|
||||
child: LinkText(
|
||||
track.value.album!.name!,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AlbumView(track.value.album!),
|
||||
),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
Text(duration),
|
||||
|
Loading…
Reference in New Issue
Block a user