2020-08-13 17:39:22 +00:00
|
|
|
import 'package:connectivity/connectivity.dart';
|
2020-06-23 19:23:12 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-08-29 22:25:18 +00:00
|
|
|
import 'package:flutter/services.dart';
|
2020-11-28 21:32:17 +00:00
|
|
|
import 'package:flutter/widgets.dart';
|
|
|
|
import 'package:fluttericon/font_awesome5_icons.dart';
|
|
|
|
import 'package:fluttericon/typicons_icons.dart';
|
2020-10-16 18:54:04 +00:00
|
|
|
import 'package:freezer/api/cache.dart';
|
2020-06-23 19:23:12 +00:00
|
|
|
import 'package:freezer/api/download.dart';
|
|
|
|
import 'package:freezer/api/player.dart';
|
|
|
|
import 'package:freezer/ui/details_screens.dart';
|
2020-10-19 19:28:45 +00:00
|
|
|
import 'package:freezer/ui/elements.dart';
|
2020-11-28 21:32:17 +00:00
|
|
|
import 'package:freezer/ui/home_screen.dart';
|
2020-06-23 19:23:12 +00:00
|
|
|
import 'package:freezer/ui/menu.dart';
|
2020-09-18 17:36:41 +00:00
|
|
|
import 'package:freezer/translations.i18n.dart';
|
2020-06-23 19:23:12 +00:00
|
|
|
|
|
|
|
import 'tiles.dart';
|
|
|
|
import '../api/deezer.dart';
|
|
|
|
import '../api/definitions.dart';
|
|
|
|
import 'error.dart';
|
|
|
|
|
2020-10-09 18:52:45 +00:00
|
|
|
openScreenByURL(BuildContext context, String url) async {
|
2021-09-01 12:38:32 +00:00
|
|
|
DeezerLinkResponse? res = await deezerAPI.parseLink(url);
|
2020-10-09 18:52:45 +00:00
|
|
|
if (res == null) return;
|
|
|
|
|
|
|
|
switch (res.type) {
|
|
|
|
case DeezerLinkType.TRACK:
|
|
|
|
Track t = await deezerAPI.track(res.id);
|
|
|
|
MenuSheet(context).defaultTrackMenu(t);
|
|
|
|
break;
|
|
|
|
case DeezerLinkType.ALBUM:
|
|
|
|
Album a = await deezerAPI.album(res.id);
|
2021-08-29 22:25:18 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.push(MaterialPageRoute(builder: (context) => AlbumDetails(a)));
|
2020-10-09 18:52:45 +00:00
|
|
|
break;
|
|
|
|
case DeezerLinkType.ARTIST:
|
|
|
|
Artist a = await deezerAPI.artist(res.id);
|
2021-08-29 22:25:18 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.push(MaterialPageRoute(builder: (context) => ArtistDetails(a)));
|
2020-10-09 18:52:45 +00:00
|
|
|
break;
|
|
|
|
case DeezerLinkType.PLAYLIST:
|
|
|
|
Playlist p = await deezerAPI.playlist(res.id);
|
2021-08-29 22:25:18 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.push(MaterialPageRoute(builder: (context) => PlaylistDetails(p)));
|
2020-10-09 18:52:45 +00:00
|
|
|
break;
|
2021-09-01 12:38:32 +00:00
|
|
|
default:
|
|
|
|
return;
|
2020-10-09 18:52:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-23 19:23:12 +00:00
|
|
|
class SearchScreen extends StatefulWidget {
|
|
|
|
@override
|
|
|
|
_SearchScreenState createState() => _SearchScreenState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SearchScreenState extends State<SearchScreen> {
|
2021-09-01 12:38:32 +00:00
|
|
|
String? _query;
|
2020-08-13 17:39:22 +00:00
|
|
|
bool _offline = false;
|
2020-10-09 18:52:45 +00:00
|
|
|
bool _loading = false;
|
2020-08-16 20:17:22 +00:00
|
|
|
TextEditingController _controller = new TextEditingController();
|
2021-09-01 12:38:32 +00:00
|
|
|
List? _suggestions = [];
|
2020-10-19 19:28:45 +00:00
|
|
|
bool _cancel = false;
|
2020-11-28 21:32:17 +00:00
|
|
|
bool _showCards = true;
|
2021-04-04 22:58:39 +00:00
|
|
|
//FocusNode _focus = FocusNode();
|
2020-06-23 19:23:12 +00:00
|
|
|
|
2021-09-01 12:38:32 +00:00
|
|
|
void _submit(BuildContext context, {String? query}) async {
|
2020-06-23 19:23:12 +00:00
|
|
|
if (query != null) _query = query;
|
2020-10-09 18:52:45 +00:00
|
|
|
|
|
|
|
//URL
|
2021-09-01 12:38:32 +00:00
|
|
|
if (_query!.startsWith('http')) {
|
2020-10-09 18:52:45 +00:00
|
|
|
setState(() => _loading = true);
|
|
|
|
try {
|
2021-09-01 12:38:32 +00:00
|
|
|
await openScreenByURL(context, _query!);
|
2020-10-09 18:52:45 +00:00
|
|
|
} catch (e) {}
|
|
|
|
setState(() => _loading = false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
2021-08-29 22:25:18 +00:00
|
|
|
builder: (context) => SearchResultsScreen(
|
|
|
|
_query,
|
|
|
|
offline: _offline,
|
2021-11-01 16:41:25 +00:00
|
|
|
));
|
2020-06-23 19:23:12 +00:00
|
|
|
}
|
|
|
|
|
2020-08-13 17:39:22 +00:00
|
|
|
@override
|
|
|
|
void initState() {
|
2020-10-20 19:55:14 +00:00
|
|
|
_cancel = false;
|
2020-08-13 17:39:22 +00:00
|
|
|
//Check for connectivity and enable offline mode
|
|
|
|
Connectivity().checkConnectivity().then((res) {
|
2021-08-29 22:25:18 +00:00
|
|
|
if (res == ConnectivityResult.none)
|
|
|
|
setState(() {
|
|
|
|
_offline = true;
|
|
|
|
});
|
2020-08-13 17:39:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
}
|
|
|
|
|
2020-09-18 17:36:41 +00:00
|
|
|
//Load search suggestions
|
2021-04-04 22:58:39 +00:00
|
|
|
Future<void> _loadSuggestions() async {
|
2021-09-01 12:38:32 +00:00
|
|
|
if (_query == null || _query!.length < 2 || _query!.startsWith('http'))
|
2021-08-29 22:25:18 +00:00
|
|
|
return null;
|
2021-09-01 12:38:32 +00:00
|
|
|
String? q = _query;
|
2020-09-18 17:36:41 +00:00
|
|
|
await Future.delayed(Duration(milliseconds: 300));
|
|
|
|
if (q != _query) return null;
|
|
|
|
//Load
|
2021-09-01 12:38:32 +00:00
|
|
|
List? sugg;
|
2020-10-10 20:51:20 +00:00
|
|
|
try {
|
|
|
|
sugg = await deezerAPI.searchSuggestions(_query);
|
2021-08-29 22:25:18 +00:00
|
|
|
} catch (e) {
|
|
|
|
print(e);
|
|
|
|
}
|
2020-10-10 20:51:20 +00:00
|
|
|
|
2021-08-29 22:25:18 +00:00
|
|
|
if (sugg != null && !_cancel) setState(() => _suggestions = sugg);
|
2020-09-18 17:36:41 +00:00
|
|
|
}
|
|
|
|
|
2020-10-20 19:55:14 +00:00
|
|
|
Widget _removeHistoryItemWidget(int index) {
|
|
|
|
return IconButton(
|
2021-08-29 22:25:18 +00:00
|
|
|
icon: Icon(
|
|
|
|
Icons.close,
|
|
|
|
semanticLabel: "Remove".i18n,
|
|
|
|
),
|
|
|
|
onPressed: () async {
|
2021-09-01 12:38:32 +00:00
|
|
|
if (cache.searchHistory != null) cache.searchHistory!.removeAt(index);
|
2021-08-29 22:25:18 +00:00
|
|
|
setState(() {});
|
|
|
|
await cache.save();
|
|
|
|
});
|
2020-10-20 19:55:14 +00:00
|
|
|
}
|
|
|
|
|
2020-10-19 19:28:45 +00:00
|
|
|
@override
|
|
|
|
void dispose() {
|
|
|
|
_cancel = true;
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2020-06-23 19:23:12 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2020-10-31 21:04:27 +00:00
|
|
|
var textFielFocusNode = FocusNode();
|
2020-06-23 19:23:12 +00:00
|
|
|
return Scaffold(
|
2020-10-19 19:28:45 +00:00
|
|
|
appBar: FreezerAppBar('Search'.i18n),
|
2020-11-22 10:17:37 +00:00
|
|
|
body: FocusScope(
|
2021-08-29 22:25:18 +00:00
|
|
|
child: ListView(
|
2020-06-23 19:23:12 +00:00
|
|
|
children: <Widget>[
|
2020-10-19 19:28:45 +00:00
|
|
|
Container(height: 4.0),
|
2020-06-23 19:23:12 +00:00
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.0),
|
|
|
|
child: Row(
|
|
|
|
children: <Widget>[
|
|
|
|
Expanded(
|
2021-08-29 22:25:18 +00:00
|
|
|
child: Stack(
|
|
|
|
alignment: Alignment(1.0, 0.0),
|
|
|
|
children: [
|
|
|
|
RawKeyboardListener(
|
|
|
|
focusNode: FocusNode(),
|
|
|
|
onKey: (event) {
|
|
|
|
// For Android TV: quit search textfield
|
|
|
|
if (event.runtimeType.toString() == 'RawKeyUpEvent') {
|
|
|
|
LogicalKeyboardKey key = event.data.logicalKey;
|
|
|
|
if (key == LogicalKeyboardKey.arrowDown) {
|
|
|
|
textFielFocusNode.unfocus();
|
2020-10-31 21:04:27 +00:00
|
|
|
}
|
2021-08-29 22:25:18 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
child: TextField(
|
|
|
|
onChanged: (String s) {
|
|
|
|
setState(() => _query = s);
|
|
|
|
_loadSuggestions();
|
2020-10-31 21:04:27 +00:00
|
|
|
},
|
2021-08-29 22:25:18 +00:00
|
|
|
onTap: () {
|
|
|
|
setState(() => _showCards = false);
|
|
|
|
},
|
|
|
|
focusNode: textFielFocusNode,
|
|
|
|
decoration: InputDecoration(
|
|
|
|
labelText: 'Search or paste URL'.i18n,
|
|
|
|
fillColor: Theme.of(context).bottomAppBarColor,
|
|
|
|
filled: true,
|
|
|
|
focusedBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: Colors.grey)),
|
|
|
|
enabledBorder: OutlineInputBorder(
|
|
|
|
borderSide: BorderSide(color: Colors.grey)),
|
|
|
|
),
|
|
|
|
controller: _controller,
|
|
|
|
onSubmitted: (String s) => _submit(context, query: s),
|
|
|
|
)),
|
|
|
|
Focus(
|
|
|
|
canRequestFocus:
|
|
|
|
false, // Focus is moving to cross, and hangs out there,
|
|
|
|
descendantsAreFocusable:
|
|
|
|
false, // so we disable focusing on it at all
|
2020-11-22 10:17:37 +00:00
|
|
|
child: Row(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
Container(
|
|
|
|
width: 40.0,
|
|
|
|
child: IconButton(
|
|
|
|
splashRadius: 20.0,
|
2021-08-29 22:25:18 +00:00
|
|
|
icon: Icon(
|
|
|
|
Icons.clear,
|
|
|
|
semanticLabel: "Clear".i18n,
|
|
|
|
),
|
2020-11-22 10:17:37 +00:00
|
|
|
onPressed: () {
|
|
|
|
setState(() {
|
|
|
|
_suggestions = [];
|
|
|
|
_query = '';
|
|
|
|
});
|
|
|
|
_controller.clear();
|
|
|
|
},
|
|
|
|
),
|
2020-10-19 19:28:45 +00:00
|
|
|
),
|
2020-11-22 10:17:37 +00:00
|
|
|
],
|
2021-08-29 22:25:18 +00:00
|
|
|
))
|
|
|
|
],
|
|
|
|
)),
|
2020-06-23 19:23:12 +00:00
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
2020-10-19 19:28:45 +00:00
|
|
|
Container(height: 8.0),
|
2020-06-23 19:23:12 +00:00
|
|
|
ListTile(
|
2020-09-18 17:36:41 +00:00
|
|
|
title: Text('Offline search'.i18n),
|
2020-10-19 19:28:45 +00:00
|
|
|
leading: Icon(Icons.offline_pin),
|
|
|
|
trailing: Switch(
|
2020-06-23 19:23:12 +00:00
|
|
|
value: _offline,
|
|
|
|
onChanged: (v) {
|
2020-08-13 17:39:22 +00:00
|
|
|
setState(() => _offline = !_offline);
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
|
|
|
),
|
2020-09-18 17:36:41 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
if (_loading) LinearProgressIndicator(),
|
2020-10-19 19:28:45 +00:00
|
|
|
FreezerDivider(),
|
2020-10-16 18:54:04 +00:00
|
|
|
|
2020-11-28 21:32:17 +00:00
|
|
|
//"Browse" Cards
|
2021-08-29 22:25:18 +00:00
|
|
|
if (_showCards) ...[
|
|
|
|
Padding(
|
|
|
|
padding: EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
|
|
|
|
child: Text(
|
|
|
|
'Quick access',
|
|
|
|
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
|
2020-11-28 21:32:17 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
SearchBrowseCard(
|
|
|
|
color: Color(0xff11b192),
|
|
|
|
text: 'Flow'.i18n,
|
|
|
|
icon: Icon(Typicons.waves),
|
|
|
|
onTap: () async {
|
|
|
|
await playerHelper
|
|
|
|
.playFromSmartTrackList(SmartTrackList(id: 'flow'));
|
|
|
|
},
|
|
|
|
),
|
|
|
|
SearchBrowseCard(
|
|
|
|
color: Color(0xff7c42bb),
|
|
|
|
text: 'Shows'.i18n,
|
|
|
|
icon: Icon(FontAwesome5.podcast),
|
2021-11-01 16:41:25 +00:00
|
|
|
onTap: () => Navigator.of(context).pushRoute(
|
2021-08-29 22:25:18 +00:00
|
|
|
builder: (context) => Scaffold(
|
|
|
|
appBar: FreezerAppBar('Shows'.i18n),
|
|
|
|
body: SingleChildScrollView(
|
2020-11-28 21:32:17 +00:00
|
|
|
child: HomePageScreen(
|
2021-08-29 22:25:18 +00:00
|
|
|
channel: DeezerChannel(target: 'shows'))),
|
|
|
|
),
|
2021-11-01 16:41:25 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
Container(height: 4.0),
|
|
|
|
Row(
|
|
|
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
|
|
|
children: [
|
|
|
|
SearchBrowseCard(
|
|
|
|
color: Color(0xffff555d),
|
|
|
|
icon: Icon(FontAwesome5.chart_line),
|
|
|
|
text: 'Charts'.i18n,
|
2021-11-01 16:41:25 +00:00
|
|
|
onTap: () => Navigator.of(context).pushRoute(
|
2021-08-29 22:25:18 +00:00
|
|
|
builder: (context) => Scaffold(
|
|
|
|
appBar: FreezerAppBar('Charts'.i18n),
|
|
|
|
body: SingleChildScrollView(
|
2020-11-28 21:32:17 +00:00
|
|
|
child: HomePageScreen(
|
2021-08-29 22:25:18 +00:00
|
|
|
channel:
|
|
|
|
DeezerChannel(target: 'channels/charts'))),
|
|
|
|
),
|
2021-11-01 16:41:25 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
),
|
|
|
|
SearchBrowseCard(
|
|
|
|
color: Color(0xff2c4ea7),
|
|
|
|
text: 'Browse'.i18n,
|
|
|
|
icon: Image.asset('assets/browse_icon.png', width: 26.0),
|
2021-11-01 16:41:25 +00:00
|
|
|
onTap: () => Navigator.of(context).pushRoute(
|
2021-08-29 22:25:18 +00:00
|
|
|
builder: (context) => Scaffold(
|
|
|
|
appBar: FreezerAppBar('Browse'.i18n),
|
|
|
|
body: SingleChildScrollView(
|
2020-11-28 21:32:17 +00:00
|
|
|
child: HomePageScreen(
|
2021-08-29 22:25:18 +00:00
|
|
|
channel:
|
|
|
|
DeezerChannel(target: 'channels/explore'))),
|
|
|
|
),
|
2021-11-01 16:41:25 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
)
|
|
|
|
],
|
|
|
|
)
|
|
|
|
],
|
2020-11-28 21:32:17 +00:00
|
|
|
|
2020-10-16 18:54:04 +00:00
|
|
|
//History
|
2021-08-29 22:25:18 +00:00
|
|
|
if (!_showCards &&
|
|
|
|
cache.searchHistory != null &&
|
2021-09-01 12:38:32 +00:00
|
|
|
cache.searchHistory!.length > 0 &&
|
2021-08-29 22:25:18 +00:00
|
|
|
(_query ?? '').length < 2)
|
|
|
|
...List.generate(
|
2021-09-01 12:38:32 +00:00
|
|
|
cache.searchHistory!.length > 10
|
2021-08-29 22:25:18 +00:00
|
|
|
? 10
|
2021-09-01 12:38:32 +00:00
|
|
|
: cache.searchHistory!.length, (int i) {
|
|
|
|
dynamic data = cache.searchHistory![i].data;
|
|
|
|
switch (cache.searchHistory![i].type) {
|
2020-10-20 19:55:14 +00:00
|
|
|
case SearchHistoryItemType.TRACK:
|
|
|
|
return TrackTile(
|
|
|
|
data,
|
|
|
|
onTap: () {
|
2021-09-01 12:38:32 +00:00
|
|
|
List<Track?> queue = cache.searchHistory!
|
2021-08-29 22:25:18 +00:00
|
|
|
.where((h) => h.type == SearchHistoryItemType.TRACK)
|
2021-09-01 12:38:32 +00:00
|
|
|
.map<Track?>((t) => t.data)
|
2021-08-29 22:25:18 +00:00
|
|
|
.toList();
|
|
|
|
playerHelper.playFromTrackList(
|
|
|
|
queue,
|
|
|
|
data.id,
|
|
|
|
QueueSource(
|
|
|
|
text: 'Search history'.i18n,
|
|
|
|
source: 'searchhistory',
|
|
|
|
id: 'searchhistory'));
|
2020-10-20 19:55:14 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultTrackMenu(data);
|
|
|
|
},
|
|
|
|
trailing: _removeHistoryItemWidget(i),
|
|
|
|
);
|
|
|
|
case SearchHistoryItemType.ALBUM:
|
|
|
|
return AlbumTile(
|
|
|
|
data,
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushRoute(builder: (context) => AlbumDetails(data));
|
2020-10-20 19:55:14 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultAlbumMenu(data);
|
|
|
|
},
|
|
|
|
trailing: _removeHistoryItemWidget(i),
|
|
|
|
);
|
|
|
|
case SearchHistoryItemType.ARTIST:
|
|
|
|
return ArtistHorizontalTile(
|
|
|
|
data,
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushRoute(builder: (context) => ArtistDetails(data));
|
2020-10-20 19:55:14 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultArtistMenu(data);
|
|
|
|
},
|
|
|
|
trailing: _removeHistoryItemWidget(i),
|
|
|
|
);
|
|
|
|
case SearchHistoryItemType.PLAYLIST:
|
|
|
|
return PlaylistTile(
|
|
|
|
data,
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
|
|
|
builder: (context) => PlaylistDetails(data));
|
2020-10-20 19:55:14 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultPlaylistMenu(data);
|
|
|
|
},
|
|
|
|
trailing: _removeHistoryItemWidget(i),
|
|
|
|
);
|
2021-09-01 12:38:32 +00:00
|
|
|
default:
|
|
|
|
return const SizedBox();
|
2020-10-20 19:55:14 +00:00
|
|
|
}
|
2021-08-29 22:25:18 +00:00
|
|
|
}),
|
2020-10-20 19:55:14 +00:00
|
|
|
|
|
|
|
//Clear history
|
2021-09-01 12:38:32 +00:00
|
|
|
if (cache.searchHistory != null && cache.searchHistory!.length > 2)
|
2020-10-20 19:55:14 +00:00
|
|
|
ListTile(
|
|
|
|
title: Text('Clear search history'.i18n),
|
|
|
|
leading: Icon(Icons.clear_all),
|
2020-10-16 18:54:04 +00:00
|
|
|
onTap: () {
|
2020-10-20 19:55:14 +00:00
|
|
|
cache.searchHistory = [];
|
|
|
|
cache.save();
|
2021-08-29 22:25:18 +00:00
|
|
|
setState(() {});
|
2020-10-16 18:54:04 +00:00
|
|
|
},
|
2020-10-20 19:55:14 +00:00
|
|
|
),
|
2020-10-16 18:54:04 +00:00
|
|
|
|
|
|
|
//Suggestions
|
2021-08-29 22:25:18 +00:00
|
|
|
...List.generate(
|
|
|
|
(_suggestions ?? []).length,
|
|
|
|
(i) => ListTile(
|
2021-09-01 12:38:32 +00:00
|
|
|
title: Text(_suggestions![i]),
|
2021-08-29 22:25:18 +00:00
|
|
|
leading: Icon(Icons.search),
|
|
|
|
onTap: () {
|
2021-09-01 12:38:32 +00:00
|
|
|
setState(() => _query = _suggestions![i]);
|
2021-08-29 22:25:18 +00:00
|
|
|
_submit(context);
|
|
|
|
},
|
|
|
|
))
|
2020-06-23 19:23:12 +00:00
|
|
|
],
|
2021-08-29 22:25:18 +00:00
|
|
|
)),
|
2020-06-23 19:23:12 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-28 21:32:17 +00:00
|
|
|
class SearchBrowseCard extends StatelessWidget {
|
|
|
|
final Color color;
|
2021-09-01 12:38:32 +00:00
|
|
|
final Widget? icon;
|
2020-11-28 21:32:17 +00:00
|
|
|
final Function onTap;
|
|
|
|
final String text;
|
2021-08-29 22:25:18 +00:00
|
|
|
SearchBrowseCard(
|
2021-09-01 12:38:32 +00:00
|
|
|
{required this.color,
|
|
|
|
required this.onTap,
|
|
|
|
required this.text,
|
2021-08-29 22:25:18 +00:00
|
|
|
this.icon});
|
2020-11-28 21:32:17 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Card(
|
2021-08-29 22:25:18 +00:00
|
|
|
color: color,
|
|
|
|
child: InkWell(
|
2021-09-01 12:38:32 +00:00
|
|
|
onTap: this.onTap as void Function()?,
|
2021-08-29 22:25:18 +00:00
|
|
|
child: Container(
|
|
|
|
width: MediaQuery.of(context).size.width / 2 - 32,
|
|
|
|
height: 75,
|
|
|
|
child: Center(
|
|
|
|
child: Row(
|
2020-11-28 21:32:17 +00:00
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
2021-09-01 12:38:32 +00:00
|
|
|
if (icon != null) icon!,
|
2021-08-29 22:25:18 +00:00
|
|
|
if (icon != null) Container(width: 8.0),
|
2020-11-28 21:32:17 +00:00
|
|
|
Text(
|
|
|
|
text,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
maxLines: 2,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
style: TextStyle(
|
2021-08-29 22:25:18 +00:00
|
|
|
fontSize: 18.0,
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
color: (color.computeLuminance() > 0.5)
|
|
|
|
? Colors.black
|
|
|
|
: Colors.white),
|
2020-11-28 21:32:17 +00:00
|
|
|
),
|
|
|
|
],
|
2021-08-29 22:25:18 +00:00
|
|
|
)),
|
2020-11-28 21:32:17 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
));
|
2020-11-28 21:32:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-06-23 19:23:12 +00:00
|
|
|
|
|
|
|
class SearchResultsScreen extends StatelessWidget {
|
2021-09-01 12:38:32 +00:00
|
|
|
final String? query;
|
|
|
|
final bool? offline;
|
2020-06-23 19:23:12 +00:00
|
|
|
|
|
|
|
SearchResultsScreen(this.query, {this.offline});
|
|
|
|
|
|
|
|
Future _search() async {
|
2021-08-29 22:25:18 +00:00
|
|
|
if (offline ?? false) {
|
2020-06-23 19:23:12 +00:00
|
|
|
return await downloadManager.search(query);
|
|
|
|
}
|
|
|
|
return await deezerAPI.search(query);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2021-08-29 22:25:18 +00:00
|
|
|
appBar: FreezerAppBar('Search Results'.i18n),
|
|
|
|
body: FutureBuilder(
|
|
|
|
future: _search(),
|
|
|
|
builder: (BuildContext context, AsyncSnapshot snapshot) {
|
|
|
|
if (!snapshot.hasData)
|
|
|
|
return Center(
|
|
|
|
child: CircularProgressIndicator(),
|
|
|
|
);
|
|
|
|
if (snapshot.hasError) return ErrorScreen();
|
|
|
|
|
|
|
|
SearchResults results = snapshot.data;
|
|
|
|
|
|
|
|
if (results.empty)
|
|
|
|
return Center(
|
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: <Widget>[
|
|
|
|
Icon(
|
|
|
|
Icons.warning,
|
|
|
|
size: 64,
|
|
|
|
),
|
|
|
|
Text('No results!'.i18n)
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
2020-06-23 19:23:12 +00:00
|
|
|
|
2021-08-29 22:25:18 +00:00
|
|
|
//Tracks
|
|
|
|
List<Widget> tracks = [];
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.tracks != null && results.tracks!.length != 0) {
|
2021-08-29 22:25:18 +00:00
|
|
|
tracks = [
|
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
|
|
|
child: Text(
|
|
|
|
'Tracks'.i18n,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
|
2020-10-19 19:28:45 +00:00
|
|
|
),
|
2020-06-23 19:23:12 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
...List.generate(3, (i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.tracks!.length <= i)
|
2021-08-29 22:25:18 +00:00
|
|
|
return Container(
|
|
|
|
width: 0,
|
|
|
|
height: 0,
|
|
|
|
);
|
2021-09-01 12:38:32 +00:00
|
|
|
Track? t = results.tracks![i];
|
2021-08-29 22:25:18 +00:00
|
|
|
return TrackTile(
|
|
|
|
t,
|
|
|
|
onTap: () {
|
|
|
|
cache.addToSearchHistory(t);
|
|
|
|
playerHelper.playFromTrackList(
|
2021-09-01 12:38:32 +00:00
|
|
|
results.tracks!,
|
2021-08-29 22:25:18 +00:00
|
|
|
t.id,
|
|
|
|
QueueSource(
|
|
|
|
text: 'Search'.i18n,
|
|
|
|
id: query,
|
|
|
|
source: 'search'));
|
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultTrackMenu(t);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
ListTile(
|
|
|
|
title: Text('Show all tracks'.i18n),
|
2020-06-23 19:23:12 +00:00
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
2021-08-29 22:25:18 +00:00
|
|
|
builder: (context) => TrackListScreen(
|
|
|
|
results.tracks,
|
|
|
|
QueueSource(
|
|
|
|
id: query,
|
|
|
|
source: 'search',
|
2021-11-01 16:41:25 +00:00
|
|
|
text: 'Search'.i18n)));
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
2021-08-29 22:25:18 +00:00
|
|
|
),
|
|
|
|
FreezerDivider()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Albums
|
|
|
|
List<Widget> albums = [];
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.albums != null && results.albums!.length != 0) {
|
2021-08-29 22:25:18 +00:00
|
|
|
albums = [
|
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(horizontal: 16.0, vertical: 4.0),
|
|
|
|
child: Text(
|
|
|
|
'Albums'.i18n,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
|
2020-10-19 19:28:45 +00:00
|
|
|
),
|
2020-06-23 19:23:12 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
...List.generate(3, (i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.albums!.length <= i)
|
2021-08-29 22:25:18 +00:00
|
|
|
return Container(
|
|
|
|
height: 0,
|
|
|
|
width: 0,
|
2020-06-23 19:23:12 +00:00
|
|
|
);
|
2021-09-01 12:38:32 +00:00
|
|
|
Album? a = results.albums![i];
|
2021-08-29 22:25:18 +00:00
|
|
|
return AlbumTile(
|
|
|
|
a,
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultAlbumMenu(a);
|
|
|
|
},
|
|
|
|
onTap: () {
|
|
|
|
cache.addToSearchHistory(a);
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushRoute(builder: (context) => AlbumDetails(a));
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
2020-06-23 19:23:12 +00:00
|
|
|
);
|
2021-08-29 22:25:18 +00:00
|
|
|
}),
|
|
|
|
ListTile(
|
|
|
|
title: Text('Show all albums'.i18n),
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
|
|
|
builder: (context) => AlbumListScreen(results.albums));
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
FreezerDivider()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Artists
|
|
|
|
List<Widget> artists = [];
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.artists != null && results.artists!.length != 0) {
|
2021-08-29 22:25:18 +00:00
|
|
|
artists = [
|
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
|
|
|
child: Text(
|
|
|
|
'Artists'.i18n,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
|
2020-10-19 19:28:45 +00:00
|
|
|
),
|
2020-06-23 19:23:12 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
Container(height: 4),
|
|
|
|
SingleChildScrollView(
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
child: Row(
|
2021-09-01 12:38:32 +00:00
|
|
|
children: List.generate(results.artists!.length, (int i) {
|
|
|
|
Artist a = results.artists![i];
|
2021-08-29 22:25:18 +00:00
|
|
|
return ArtistTile(
|
|
|
|
a,
|
|
|
|
onTap: () {
|
|
|
|
cache.addToSearchHistory(a);
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
|
|
|
builder: (context) => ArtistDetails(a));
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultArtistMenu(a);
|
|
|
|
},
|
2020-06-23 19:23:12 +00:00
|
|
|
);
|
2021-08-29 22:25:18 +00:00
|
|
|
}),
|
|
|
|
)),
|
|
|
|
FreezerDivider()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Playlists
|
|
|
|
List<Widget> playlists = [];
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.playlists != null && results.playlists!.length != 0) {
|
2021-08-29 22:25:18 +00:00
|
|
|
playlists = [
|
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
|
|
|
child: Text(
|
|
|
|
'Playlists'.i18n,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
|
2020-10-19 19:28:45 +00:00
|
|
|
),
|
2020-06-23 19:23:12 +00:00
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
...List.generate(3, (i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.playlists!.length <= i)
|
2021-08-29 22:25:18 +00:00
|
|
|
return Container(
|
|
|
|
height: 0,
|
|
|
|
width: 0,
|
2020-06-23 19:23:12 +00:00
|
|
|
);
|
2021-09-01 12:38:32 +00:00
|
|
|
Playlist? p = results.playlists![i];
|
2021-08-29 22:25:18 +00:00
|
|
|
return PlaylistTile(
|
|
|
|
p,
|
|
|
|
onTap: () {
|
|
|
|
cache.addToSearchHistory(p);
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushRoute(builder: (context) => PlaylistDetails(p));
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
|
|
|
m.defaultPlaylistMenu(p);
|
|
|
|
},
|
2020-06-23 19:23:12 +00:00
|
|
|
);
|
2021-08-29 22:25:18 +00:00
|
|
|
}),
|
|
|
|
ListTile(
|
|
|
|
title: Text('Show all playlists'.i18n),
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
2021-08-29 22:25:18 +00:00
|
|
|
builder: (context) =>
|
2021-11-01 16:41:25 +00:00
|
|
|
SearchResultPlaylists(results.playlists));
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
FreezerDivider()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Shows
|
|
|
|
List<Widget> shows = [];
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.shows != null && results.shows!.length != 0) {
|
2021-08-29 22:25:18 +00:00
|
|
|
shows = [
|
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
|
|
|
child: Text(
|
|
|
|
'Shows'.i18n,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
|
2020-12-14 17:29:28 +00:00
|
|
|
),
|
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
...List.generate(3, (i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.shows!.length <= i)
|
2021-08-29 22:25:18 +00:00
|
|
|
return Container(
|
|
|
|
height: 0,
|
|
|
|
width: 0,
|
|
|
|
);
|
2021-09-01 12:38:32 +00:00
|
|
|
Show s = results.shows![i];
|
2021-08-29 22:25:18 +00:00
|
|
|
return ShowTile(
|
|
|
|
s,
|
|
|
|
onTap: () async {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushRoute(builder: (context) => ShowScreen(s));
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
ListTile(
|
|
|
|
title: Text('Show all shows'.i18n),
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
|
|
|
builder: (context) => ShowListScreen(results.shows));
|
2020-12-14 17:29:28 +00:00
|
|
|
},
|
2021-08-29 22:25:18 +00:00
|
|
|
),
|
|
|
|
FreezerDivider()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
//Episodes
|
|
|
|
List<Widget> episodes = [];
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.episodes != null && results.episodes!.length != 0) {
|
2021-08-29 22:25:18 +00:00
|
|
|
episodes = [
|
|
|
|
Padding(
|
|
|
|
padding:
|
|
|
|
EdgeInsets.symmetric(vertical: 4.0, horizontal: 16.0),
|
|
|
|
child: Text(
|
|
|
|
'Episodes'.i18n,
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
style:
|
|
|
|
TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
|
2020-12-14 17:29:28 +00:00
|
|
|
),
|
|
|
|
),
|
2021-08-29 22:25:18 +00:00
|
|
|
...List.generate(3, (i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
if (results.episodes!.length <= i)
|
2021-08-29 22:25:18 +00:00
|
|
|
return Container(
|
|
|
|
height: 0,
|
|
|
|
width: 0,
|
|
|
|
);
|
2021-09-01 12:38:32 +00:00
|
|
|
ShowEpisode e = results.episodes![i];
|
2021-08-29 22:25:18 +00:00
|
|
|
return ShowEpisodeTile(
|
|
|
|
e,
|
|
|
|
trailing: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
Icons.more_vert,
|
|
|
|
semanticLabel: "Options".i18n,
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
2021-09-01 12:38:32 +00:00
|
|
|
m.defaultShowEpisodeMenu(e.show!, e);
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
onTap: () async {
|
|
|
|
//Load entire show, then play
|
|
|
|
List<ShowEpisode> episodes =
|
2021-09-01 12:38:32 +00:00
|
|
|
(await deezerAPI.allShowEpisodes(e.show!.id))!;
|
|
|
|
await playerHelper.playShowEpisode(e.show!, episodes,
|
2021-08-29 22:25:18 +00:00
|
|
|
index: episodes.indexWhere((ep) => e.id == ep.id));
|
2020-12-14 17:29:28 +00:00
|
|
|
},
|
|
|
|
);
|
2021-08-29 22:25:18 +00:00
|
|
|
}),
|
|
|
|
ListTile(
|
|
|
|
title: Text('Show all episodes'.i18n),
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context).pushRoute(
|
2021-08-29 22:25:18 +00:00
|
|
|
builder: (context) =>
|
2021-11-01 16:41:25 +00:00
|
|
|
EpisodeListScreen(results.episodes));
|
2021-08-29 22:25:18 +00:00
|
|
|
})
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
return ListView(
|
|
|
|
children: <Widget>[
|
|
|
|
Container(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
...tracks,
|
|
|
|
Container(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
...albums,
|
|
|
|
Container(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
...artists,
|
|
|
|
Container(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
...playlists,
|
|
|
|
Container(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
...shows,
|
|
|
|
Container(
|
|
|
|
height: 8.0,
|
|
|
|
),
|
|
|
|
...episodes
|
|
|
|
],
|
|
|
|
);
|
|
|
|
},
|
|
|
|
));
|
2020-06-23 19:23:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//List all tracks
|
|
|
|
class TrackListScreen extends StatelessWidget {
|
|
|
|
final QueueSource queueSource;
|
2021-09-01 12:38:32 +00:00
|
|
|
final List<Track?>? tracks;
|
2020-06-23 19:23:12 +00:00
|
|
|
|
|
|
|
TrackListScreen(this.tracks, this.queueSource);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2020-10-19 19:28:45 +00:00
|
|
|
appBar: FreezerAppBar('Tracks'.i18n),
|
2020-06-23 19:23:12 +00:00
|
|
|
body: ListView.builder(
|
2021-09-01 12:38:32 +00:00
|
|
|
itemCount: tracks!.length,
|
2020-06-23 19:23:12 +00:00
|
|
|
itemBuilder: (BuildContext context, int i) {
|
2021-11-01 16:41:25 +00:00
|
|
|
Track t = tracks![i]!;
|
2020-06-23 19:23:12 +00:00
|
|
|
return TrackTile(
|
|
|
|
t,
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
playerHelper.playFromTrackList(tracks!, t.id, queueSource);
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
2021-11-01 16:41:25 +00:00
|
|
|
m.defaultTrackMenu(t);
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//List all albums
|
|
|
|
class AlbumListScreen extends StatelessWidget {
|
2021-09-01 12:38:32 +00:00
|
|
|
final List<Album?>? albums;
|
2020-06-23 19:23:12 +00:00
|
|
|
AlbumListScreen(this.albums);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2020-10-19 19:28:45 +00:00
|
|
|
appBar: FreezerAppBar('Albums'.i18n),
|
2020-06-23 19:23:12 +00:00
|
|
|
body: ListView.builder(
|
2021-09-01 12:38:32 +00:00
|
|
|
itemCount: albums!.length,
|
2020-06-23 19:23:12 +00:00
|
|
|
itemBuilder: (context, i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
Album? a = albums![i];
|
2020-06-23 19:23:12 +00:00
|
|
|
return AlbumTile(
|
|
|
|
a,
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushRoute(builder: (context) => AlbumDetails(a));
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
2021-09-01 12:38:32 +00:00
|
|
|
m.defaultAlbumMenu(a!);
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class SearchResultPlaylists extends StatelessWidget {
|
2021-09-01 12:38:32 +00:00
|
|
|
final List<Playlist?>? playlists;
|
2020-06-23 19:23:12 +00:00
|
|
|
SearchResultPlaylists(this.playlists);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2020-10-19 19:28:45 +00:00
|
|
|
appBar: FreezerAppBar('Playlists'.i18n),
|
2020-06-23 19:23:12 +00:00
|
|
|
body: ListView.builder(
|
2021-09-01 12:38:32 +00:00
|
|
|
itemCount: playlists!.length,
|
2020-06-23 19:23:12 +00:00
|
|
|
itemBuilder: (context, i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
Playlist? p = playlists![i];
|
2020-06-23 19:23:12 +00:00
|
|
|
return PlaylistTile(
|
|
|
|
p,
|
|
|
|
onTap: () {
|
2021-11-01 16:41:25 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.pushRoute(builder: (context) => PlaylistDetails(p));
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
|
|
|
onHold: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
2021-09-01 12:38:32 +00:00
|
|
|
m.defaultPlaylistMenu(p!);
|
2020-06-23 19:23:12 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2020-12-14 17:29:28 +00:00
|
|
|
|
|
|
|
class ShowListScreen extends StatelessWidget {
|
2021-09-01 12:38:32 +00:00
|
|
|
final List<Show>? shows;
|
2020-12-14 17:29:28 +00:00
|
|
|
ShowListScreen(this.shows);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
|
|
|
appBar: FreezerAppBar('Shows'.i18n),
|
|
|
|
body: ListView.builder(
|
2021-09-01 12:38:32 +00:00
|
|
|
itemCount: shows!.length,
|
2020-12-14 17:29:28 +00:00
|
|
|
itemBuilder: (context, i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
Show s = shows![i];
|
2020-12-14 17:29:28 +00:00
|
|
|
return ShowTile(
|
|
|
|
s,
|
|
|
|
onTap: () {
|
2021-08-29 22:25:18 +00:00
|
|
|
Navigator.of(context)
|
|
|
|
.push(MaterialPageRoute(builder: (context) => ShowScreen(s)));
|
2020-12-14 17:29:28 +00:00
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class EpisodeListScreen extends StatelessWidget {
|
2021-09-01 12:38:32 +00:00
|
|
|
final List<ShowEpisode>? episodes;
|
2020-12-14 17:29:28 +00:00
|
|
|
EpisodeListScreen(this.episodes);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2021-08-29 22:25:18 +00:00
|
|
|
appBar: FreezerAppBar('Episodes'.i18n),
|
|
|
|
body: ListView.builder(
|
2021-09-01 12:38:32 +00:00
|
|
|
itemCount: episodes!.length,
|
2021-08-29 22:25:18 +00:00
|
|
|
itemBuilder: (context, i) {
|
2021-09-01 12:38:32 +00:00
|
|
|
ShowEpisode e = episodes![i];
|
2021-08-29 22:25:18 +00:00
|
|
|
return ShowEpisodeTile(
|
|
|
|
e,
|
|
|
|
trailing: IconButton(
|
|
|
|
icon: Icon(
|
|
|
|
Icons.more_vert,
|
|
|
|
semanticLabel: "Options".i18n,
|
|
|
|
),
|
|
|
|
onPressed: () {
|
|
|
|
MenuSheet m = MenuSheet(context);
|
2021-09-01 12:38:32 +00:00
|
|
|
m.defaultShowEpisodeMenu(e.show!, e);
|
2021-08-29 22:25:18 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
onTap: () async {
|
|
|
|
//Load entire show, then play
|
|
|
|
List<ShowEpisode> episodes =
|
2021-09-01 12:38:32 +00:00
|
|
|
(await deezerAPI.allShowEpisodes(e.show!.id))!;
|
|
|
|
await playerHelper.playShowEpisode(e.show!, episodes,
|
2021-08-29 22:25:18 +00:00
|
|
|
index: episodes.indexWhere((ep) => e.id == ep.id));
|
2020-12-14 17:29:28 +00:00
|
|
|
},
|
2021-08-29 22:25:18 +00:00
|
|
|
);
|
|
|
|
},
|
|
|
|
));
|
2020-12-14 17:29:28 +00:00
|
|
|
}
|
2021-08-29 22:25:18 +00:00
|
|
|
}
|