mirror of
https://github.com/KRTirtho/spotube.git
synced 2025-09-13 07:55: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:hotkey_manager/hotkey_manager.dart';
|
||||||
import 'package:just_audio/just_audio.dart';
|
import 'package:just_audio/just_audio.dart';
|
||||||
import 'package:spotify/spotify.dart';
|
import 'package:spotify/spotify.dart';
|
||||||
import 'package:spotube/components/Artist/ArtistProfile.dart';
|
|
||||||
import 'package:spotube/components/Shared/DownloadTrackButton.dart';
|
import 'package:spotube/components/Shared/DownloadTrackButton.dart';
|
||||||
import 'package:spotube/components/Player/PlayerControls.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/artists-to-clickable-artists.dart';
|
||||||
import 'package:spotube/helpers/image-to-url-string.dart';
|
import 'package:spotube/helpers/image-to-url-string.dart';
|
||||||
import 'package:spotube/helpers/search-youtube.dart';
|
import 'package:spotube/helpers/search-youtube.dart';
|
||||||
|
@ -20,6 +20,7 @@ class Search extends StatefulWidget {
|
|||||||
|
|
||||||
class _SearchState extends State<Search> {
|
class _SearchState extends State<Search> {
|
||||||
late TextEditingController _controller;
|
late TextEditingController _controller;
|
||||||
|
|
||||||
String searchTerm = "";
|
String searchTerm = "";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -43,6 +44,11 @@ class _SearchState extends State<Search> {
|
|||||||
child: TextField(
|
child: TextField(
|
||||||
decoration: const InputDecoration(hintText: "Search..."),
|
decoration: const InputDecoration(hintText: "Search..."),
|
||||||
controller: _controller,
|
controller: _controller,
|
||||||
|
onSubmitted: (value) {
|
||||||
|
setState(() {
|
||||||
|
searchTerm = _controller.value.text;
|
||||||
|
});
|
||||||
|
},
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 5),
|
const SizedBox(width: 5),
|
||||||
@ -64,7 +70,7 @@ class _SearchState extends State<Search> {
|
|||||||
),
|
),
|
||||||
FutureBuilder<List<Page>>(
|
FutureBuilder<List<Page>>(
|
||||||
future: searchTerm.isNotEmpty
|
future: searchTerm.isNotEmpty
|
||||||
? spotify.search.get(searchTerm).first(5)
|
? spotify.search.get(searchTerm).first(10)
|
||||||
: null,
|
: null,
|
||||||
builder: (context, snapshot) {
|
builder: (context, snapshot) {
|
||||||
if (!snapshot.hasData && searchTerm.isNotEmpty) {
|
if (!snapshot.hasData && searchTerm.isNotEmpty) {
|
||||||
@ -116,7 +122,27 @@ class _SearchState extends State<Search> {
|
|||||||
duration: duration,
|
duration: duration,
|
||||||
thumbnailUrl:
|
thumbnailUrl:
|
||||||
imageToUrlString(track.value.album?.images),
|
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)
|
if (albums.isNotEmpty)
|
||||||
@ -125,12 +151,14 @@ class _SearchState extends State<Search> {
|
|||||||
style: Theme.of(context).textTheme.headline5,
|
style: Theme.of(context).textTheme.headline5,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Wrap(
|
Center(
|
||||||
spacing: 20,
|
child: Wrap(
|
||||||
runSpacing: 20,
|
spacing: 20,
|
||||||
children: albums.map((album) {
|
runSpacing: 20,
|
||||||
return AlbumCard(simpleAlbumToAlbum(album));
|
children: albums.map((album) {
|
||||||
}).toList(),
|
return AlbumCard(simpleAlbumToAlbum(album));
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (artists.isNotEmpty)
|
if (artists.isNotEmpty)
|
||||||
@ -139,12 +167,14 @@ class _SearchState extends State<Search> {
|
|||||||
style: Theme.of(context).textTheme.headline5,
|
style: Theme.of(context).textTheme.headline5,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Wrap(
|
Center(
|
||||||
spacing: 20,
|
child: Wrap(
|
||||||
runSpacing: 20,
|
spacing: 20,
|
||||||
children: artists.map((artist) {
|
runSpacing: 20,
|
||||||
return ArtistCard(artist);
|
children: artists.map((artist) {
|
||||||
}).toList(),
|
return ArtistCard(artist);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
if (playlists.isNotEmpty)
|
if (playlists.isNotEmpty)
|
||||||
@ -153,12 +183,14 @@ class _SearchState extends State<Search> {
|
|||||||
style: Theme.of(context).textTheme.headline5,
|
style: Theme.of(context).textTheme.headline5,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Wrap(
|
Center(
|
||||||
spacing: 20,
|
child: Wrap(
|
||||||
runSpacing: 20,
|
spacing: 20,
|
||||||
children: playlists.map((playlist) {
|
runSpacing: 20,
|
||||||
return PlaylistCard(playlist);
|
children: playlists.map((playlist) {
|
||||||
}).toList(),
|
return PlaylistCard(playlist);
|
||||||
|
}).toList(),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -81,16 +81,12 @@ class TracksTableView extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Row(
|
child: LinkText(
|
||||||
children: [
|
track.value.album!.name!,
|
||||||
LinkText(
|
MaterialPageRoute(
|
||||||
track.value.album!.name!,
|
builder: (context) => AlbumView(track.value.album!),
|
||||||
MaterialPageRoute(
|
),
|
||||||
builder: (context) => AlbumView(track.value.album!),
|
overflow: TextOverflow.ellipsis,
|
||||||
),
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
|
Loading…
Reference in New Issue
Block a user