0.6.3 - Playlist search, few other things i forgot
This commit is contained in:
parent
e9d97986b5
commit
e029c41b43
26 changed files with 520 additions and 62 deletions
|
@ -53,11 +53,14 @@ class Cache {
|
|||
@JsonKey(name: 'searchHistory2', toJson: _searchHistoryToJson, fromJson: _searchHistoryFromJson)
|
||||
List<SearchHistoryItem> searchHistory;
|
||||
|
||||
|
||||
//If download threads warning was shown
|
||||
@JsonKey(defaultValue: false)
|
||||
bool threadsWarning;
|
||||
|
||||
//Last time update check
|
||||
@JsonKey(defaultValue: 0)
|
||||
int lastUpdateCheck;
|
||||
|
||||
Cache({this.libraryTracks});
|
||||
|
||||
//Wrapper to test if track is favorite against cache
|
||||
|
|
|
@ -33,7 +33,8 @@ Cache _$CacheFromJson(Map<String, dynamic> json) {
|
|||
SortType.DEFAULT
|
||||
..searchHistory =
|
||||
Cache._searchHistoryFromJson(json['searchHistory2'] as List)
|
||||
..threadsWarning = json['threadsWarning'] as bool ?? false;
|
||||
..threadsWarning = json['threadsWarning'] as bool ?? false
|
||||
..lastUpdateCheck = json['lastUpdateCheck'] as int ?? 0;
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$CacheToJson(Cache instance) => <String, dynamic>{
|
||||
|
@ -48,6 +49,7 @@ Map<String, dynamic> _$CacheToJson(Cache instance) => <String, dynamic>{
|
|||
'trackSort': _$SortTypeEnumMap[instance.trackSort],
|
||||
'searchHistory2': Cache._searchHistoryToJson(instance.searchHistory),
|
||||
'threadsWarning': instance.threadsWarning,
|
||||
'lastUpdateCheck': instance.lastUpdateCheck,
|
||||
};
|
||||
|
||||
T _$enumDecode<T>(
|
||||
|
@ -94,6 +96,7 @@ const _$AlbumSortTypeEnumMap = {
|
|||
AlbumSortType.REVERSE: 'REVERSE',
|
||||
AlbumSortType.ALPHABETIC: 'ALPHABETIC',
|
||||
AlbumSortType.ARTIST: 'ARTIST',
|
||||
AlbumSortType.DATE: 'DATE',
|
||||
};
|
||||
|
||||
const _$ArtistSortTypeEnumMap = {
|
||||
|
|
|
@ -168,7 +168,8 @@ class DeezerAPI {
|
|||
return Artist.fromPrivateJson(
|
||||
data['results']['DATA'],
|
||||
topJson: data['results']['TOP'],
|
||||
albumsJson: data['results']['ALBUMS']
|
||||
albumsJson: data['results']['ALBUMS'],
|
||||
highlight: data['results']['HIGHLIGHT']
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ class Track {
|
|||
'favorite': (favorite??0)?1:0,
|
||||
'diskNumber': diskNumber,
|
||||
'explicit': explicit?1:0,
|
||||
'favoriteDate': favoriteDate
|
||||
// 'favoriteDate': favoriteDate
|
||||
};
|
||||
factory Track.fromSQL(Map<String, dynamic> data) => Track(
|
||||
id: data['trackId']??data['id'], //If loading from downloads table
|
||||
|
@ -174,7 +174,7 @@ class Track {
|
|||
favorite: (data['favorite'] == 1) ? true:false,
|
||||
diskNumber: data['diskNumber'],
|
||||
explicit: (data['explicit'] == 1) ? true:false,
|
||||
favoriteDate: data['favoriteDate']
|
||||
// favoriteDate: data['favoriteDate']
|
||||
);
|
||||
|
||||
factory Track.fromJson(Map<String, dynamic> json) => _$TrackFromJson(json);
|
||||
|
@ -238,7 +238,7 @@ class Album {
|
|||
'library': (library??false)?1:0,
|
||||
'type': AlbumType.values.indexOf(type),
|
||||
'releaseDate': releaseDate,
|
||||
'favoriteDate': favoriteDate
|
||||
// 'favoriteDate': favoriteDate
|
||||
};
|
||||
factory Album.fromSQL(Map<String, dynamic> data) => Album(
|
||||
id: data['id'],
|
||||
|
@ -255,13 +255,39 @@ class Album {
|
|||
library: (data['library'] == 1) ? true:false,
|
||||
type: AlbumType.values[data['type']],
|
||||
releaseDate: data['releaseDate'],
|
||||
favoriteDate: data['favoriteDate']
|
||||
// favoriteDate: data['favoriteDate']
|
||||
);
|
||||
|
||||
factory Album.fromJson(Map<String, dynamic> json) => _$AlbumFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$AlbumToJson(this);
|
||||
}
|
||||
|
||||
enum ArtistHighlightType {
|
||||
ALBUM
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class ArtistHighlight {
|
||||
dynamic data;
|
||||
ArtistHighlightType type;
|
||||
String title;
|
||||
|
||||
ArtistHighlight({this.data, this.type, this.title});
|
||||
|
||||
factory ArtistHighlight.fromPrivateJson(Map<dynamic, dynamic> json) {
|
||||
if (json == null || json['ITEM'] == null) return null;
|
||||
switch (json['TYPE']) {
|
||||
case 'album':
|
||||
return ArtistHighlight(data: Album.fromPrivateJson(json['ITEM']), type: ArtistHighlightType.ALBUM, title: json['TITLE']);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//JSON
|
||||
factory ArtistHighlight.fromJson(Map<String, dynamic> json) => _$ArtistHighlightFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$ArtistHighlightToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class Artist {
|
||||
String id;
|
||||
|
@ -275,8 +301,9 @@ class Artist {
|
|||
bool library;
|
||||
bool radio;
|
||||
String favoriteDate;
|
||||
ArtistHighlight highlight;
|
||||
|
||||
Artist({this.id, this.name, this.albums, this.albumCount, this.topTracks, this.picture, this.fans, this.offline, this.library, this.radio, this.favoriteDate});
|
||||
Artist({this.id, this.name, this.albums, this.albumCount, this.topTracks, this.picture, this.fans, this.offline, this.library, this.radio, this.favoriteDate, this.highlight});
|
||||
|
||||
String get fansString => NumberFormat.compact().format(fans);
|
||||
|
||||
|
@ -285,6 +312,7 @@ class Artist {
|
|||
Map<dynamic, dynamic> json, {
|
||||
Map<dynamic, dynamic> albumsJson = const {},
|
||||
Map<dynamic, dynamic> topJson = const {},
|
||||
Map<dynamic, dynamic> highlight = null,
|
||||
bool library = false
|
||||
}) {
|
||||
//Get wether radio is available
|
||||
|
@ -301,7 +329,8 @@ class Artist {
|
|||
topTracks: (topJson['data']??[]).map<Track>((dynamic data) => Track.fromPrivateJson(data)).toList(),
|
||||
library: library,
|
||||
radio: _radio,
|
||||
favoriteDate: json['DATE_FAVORITE']
|
||||
favoriteDate: json['DATE_FAVORITE'],
|
||||
highlight: ArtistHighlight.fromPrivateJson(highlight)
|
||||
);
|
||||
}
|
||||
Map<String, dynamic> toSQL({off = false}) => {
|
||||
|
@ -315,7 +344,7 @@ class Artist {
|
|||
'offline': off?1:0,
|
||||
'library': (library??false)?1:0,
|
||||
'radio': radio?1:0,
|
||||
'favoriteDate': favoriteDate
|
||||
// 'favoriteDate': favoriteDate
|
||||
};
|
||||
factory Artist.fromSQL(Map<String, dynamic> data) => Artist(
|
||||
id: data['id'],
|
||||
|
@ -332,7 +361,7 @@ class Artist {
|
|||
offline: (data['offline'] == 1)?true:false,
|
||||
library: (data['library'] == 1)?true:false,
|
||||
radio: (data['radio'] == 1)?true:false,
|
||||
favoriteDate: data['favoriteDate']
|
||||
// favoriteDate: data['favoriteDate']
|
||||
);
|
||||
|
||||
factory Artist.fromJson(Map<String, dynamic> json) => _$ArtistFromJson(json);
|
||||
|
|
|
@ -129,6 +129,25 @@ const _$AlbumTypeEnumMap = {
|
|||
AlbumType.FEATURED: 'FEATURED',
|
||||
};
|
||||
|
||||
ArtistHighlight _$ArtistHighlightFromJson(Map<String, dynamic> json) {
|
||||
return ArtistHighlight(
|
||||
data: json['data'],
|
||||
type: _$enumDecodeNullable(_$ArtistHighlightTypeEnumMap, json['type']),
|
||||
title: json['title'] as String,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> _$ArtistHighlightToJson(ArtistHighlight instance) =>
|
||||
<String, dynamic>{
|
||||
'data': instance.data,
|
||||
'type': _$ArtistHighlightTypeEnumMap[instance.type],
|
||||
'title': instance.title,
|
||||
};
|
||||
|
||||
const _$ArtistHighlightTypeEnumMap = {
|
||||
ArtistHighlightType.ALBUM: 'ALBUM',
|
||||
};
|
||||
|
||||
Artist _$ArtistFromJson(Map<String, dynamic> json) {
|
||||
return Artist(
|
||||
id: json['id'] as String,
|
||||
|
@ -150,6 +169,9 @@ Artist _$ArtistFromJson(Map<String, dynamic> json) {
|
|||
library: json['library'] as bool,
|
||||
radio: json['radio'] as bool,
|
||||
favoriteDate: json['favoriteDate'] as String,
|
||||
highlight: json['highlight'] == null
|
||||
? null
|
||||
: ArtistHighlight.fromJson(json['highlight'] as Map<String, dynamic>),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -165,6 +187,7 @@ Map<String, dynamic> _$ArtistToJson(Artist instance) => <String, dynamic>{
|
|||
'library': instance.library,
|
||||
'radio': instance.radio,
|
||||
'favoriteDate': instance.favoriteDate,
|
||||
'highlight': instance.highlight,
|
||||
};
|
||||
|
||||
Playlist _$PlaylistFromJson(Map<String, dynamic> json) {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:disk_space/disk_space.dart';
|
||||
import 'package:filesize/filesize.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue