This commit is contained in:
austinried
2023-04-28 09:24:51 +09:00
parent 35b037f66c
commit f0f812e66a
402 changed files with 34368 additions and 62769 deletions

115
lib/models/music.dart Normal file
View File

@@ -0,0 +1,115 @@
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:flutter/foundation.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'music.freezed.dart';
abstract class SourceIdentifiable {
int get sourceId;
String get id;
}
abstract class SongList extends SourceIdentifiable {
String get name;
int get songCount;
}
@freezed
class SourceId with _$SourceId implements SourceIdentifiable {
const factory SourceId({
required int sourceId,
required String id,
}) = _SourceId;
factory SourceId.from(SourceIdentifiable item) {
return SourceId(sourceId: item.sourceId, id: item.id);
}
}
@freezed
class SourceIdSet with _$SourceIdSet {
const factory SourceIdSet({
required int sourceId,
required ISet<String> ids,
}) = _SourceIdSet;
}
@freezed
class Artist with _$Artist {
const factory Artist({
required int sourceId,
required String id,
required String name,
required int albumCount,
DateTime? starred,
// @Default(IListConst([])) IList<Album> albums,
}) = _Artist;
}
@freezed
class Album with _$Album implements SongList {
const factory Album({
required int sourceId,
required String id,
required String name,
String? artistId,
String? albumArtist,
required DateTime created,
String? coverArt,
int? year,
DateTime? starred,
// DateTime? synced,
String? genre,
required int songCount,
@Default(false) bool isDeleted,
// @Default(IListConst([])) IList<Song> songs,
int? frequentRank,
int? recentRank,
}) = _Album;
}
@freezed
class Playlist with _$Playlist implements SongList {
const factory Playlist({
required int sourceId,
required String id,
required String name,
String? comment,
String? coverArt,
required int songCount,
required DateTime created,
// DateTime? synced,
// @Default(IListConst([])) IList<Song> songs,
}) = _Playlist;
}
@freezed
class Song with _$Song implements SourceIdentifiable {
const factory Song({
required int sourceId,
required String id,
String? albumId,
String? artistId,
required String title,
String? artist,
String? album,
Duration? duration,
int? track,
int? disc,
DateTime? starred,
String? genre,
String? downloadTaskId,
String? downloadFilePath,
@Default(false) bool isDeleted,
}) = _Song;
}
@freezed
class SearchResults with _$SearchResults {
const factory SearchResults({
String? query,
@Default(IListConst([])) IList<Song> songs,
@Default(IListConst([])) IList<Album> albums,
@Default(IListConst([])) IList<Artist> artists,
}) = _SearchResults;
}

File diff suppressed because it is too large Load Diff

97
lib/models/query.dart Normal file
View File

@@ -0,0 +1,97 @@
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'query.freezed.dart';
part 'query.g.dart';
enum SortDirection {
asc('ASC'),
desc('DESC');
const SortDirection(this.value);
final String value;
}
@freezed
class Pagination with _$Pagination {
const factory Pagination({
required int limit,
@Default(0) int offset,
}) = _Pagination;
factory Pagination.fromJson(Map<String, dynamic> json) =>
_$PaginationFromJson(json);
}
@freezed
class SortBy with _$SortBy {
const factory SortBy({
required String column,
@Default(SortDirection.asc) SortDirection dir,
}) = _SortBy;
factory SortBy.fromJson(Map<String, dynamic> json) => _$SortByFromJson(json);
}
@freezed
class FilterWith with _$FilterWith {
const factory FilterWith.equals({
required String column,
required String value,
@Default(false) bool invert,
}) = _FilterWithEquals;
const factory FilterWith.greaterThan({
required String column,
required String value,
@Default(false) bool orEquals,
}) = _FilterWithGreaterThan;
const factory FilterWith.isNull({
required String column,
@Default(false) bool invert,
}) = _FilterWithIsNull;
const factory FilterWith.betweenInt({
required String column,
required int from,
required int to,
}) = _FilterWithBetweenInt;
const factory FilterWith.isIn({
required String column,
@Default(false) bool invert,
@Default(IListConst([])) IList<String> values,
}) = _FilterWithIsIn;
factory FilterWith.fromJson(Map<String, dynamic> json) =>
_$FilterWithFromJson(json);
}
@freezed
class ListQuery with _$ListQuery {
const factory ListQuery({
@Default(Pagination(limit: -1, offset: 0)) Pagination page,
SortBy? sort,
@Default(IListConst([])) IList<FilterWith> filters,
}) = _ListQuery;
factory ListQuery.fromJson(Map<String, dynamic> json) =>
_$ListQueryFromJson(json);
}
@freezed
class ListQueryOptions with _$ListQueryOptions {
const factory ListQueryOptions({
required IList<String> sortColumns,
required IList<String> filterColumns,
}) = _ListQueryOptions;
}
@freezed
class LibraryListQuery with _$LibraryListQuery {
const factory LibraryListQuery({
required ListQueryOptions options,
required ListQuery query,
}) = _LibraryListQuery;
}

File diff suppressed because it is too large Load Diff

143
lib/models/query.g.dart Normal file
View File

@@ -0,0 +1,143 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'query.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$_Pagination _$$_PaginationFromJson(Map<String, dynamic> json) =>
_$_Pagination(
limit: json['limit'] as int,
offset: json['offset'] as int? ?? 0,
);
Map<String, dynamic> _$$_PaginationToJson(_$_Pagination instance) =>
<String, dynamic>{
'limit': instance.limit,
'offset': instance.offset,
};
_$_SortBy _$$_SortByFromJson(Map<String, dynamic> json) => _$_SortBy(
column: json['column'] as String,
dir: $enumDecodeNullable(_$SortDirectionEnumMap, json['dir']) ??
SortDirection.asc,
);
Map<String, dynamic> _$$_SortByToJson(_$_SortBy instance) => <String, dynamic>{
'column': instance.column,
'dir': _$SortDirectionEnumMap[instance.dir]!,
};
const _$SortDirectionEnumMap = {
SortDirection.asc: 'asc',
SortDirection.desc: 'desc',
};
_$_FilterWithEquals _$$_FilterWithEqualsFromJson(Map<String, dynamic> json) =>
_$_FilterWithEquals(
column: json['column'] as String,
value: json['value'] as String,
invert: json['invert'] as bool? ?? false,
$type: json['runtimeType'] as String?,
);
Map<String, dynamic> _$$_FilterWithEqualsToJson(_$_FilterWithEquals instance) =>
<String, dynamic>{
'column': instance.column,
'value': instance.value,
'invert': instance.invert,
'runtimeType': instance.$type,
};
_$_FilterWithGreaterThan _$$_FilterWithGreaterThanFromJson(
Map<String, dynamic> json) =>
_$_FilterWithGreaterThan(
column: json['column'] as String,
value: json['value'] as String,
orEquals: json['orEquals'] as bool? ?? false,
$type: json['runtimeType'] as String?,
);
Map<String, dynamic> _$$_FilterWithGreaterThanToJson(
_$_FilterWithGreaterThan instance) =>
<String, dynamic>{
'column': instance.column,
'value': instance.value,
'orEquals': instance.orEquals,
'runtimeType': instance.$type,
};
_$_FilterWithIsNull _$$_FilterWithIsNullFromJson(Map<String, dynamic> json) =>
_$_FilterWithIsNull(
column: json['column'] as String,
invert: json['invert'] as bool? ?? false,
$type: json['runtimeType'] as String?,
);
Map<String, dynamic> _$$_FilterWithIsNullToJson(_$_FilterWithIsNull instance) =>
<String, dynamic>{
'column': instance.column,
'invert': instance.invert,
'runtimeType': instance.$type,
};
_$_FilterWithBetweenInt _$$_FilterWithBetweenIntFromJson(
Map<String, dynamic> json) =>
_$_FilterWithBetweenInt(
column: json['column'] as String,
from: json['from'] as int,
to: json['to'] as int,
$type: json['runtimeType'] as String?,
);
Map<String, dynamic> _$$_FilterWithBetweenIntToJson(
_$_FilterWithBetweenInt instance) =>
<String, dynamic>{
'column': instance.column,
'from': instance.from,
'to': instance.to,
'runtimeType': instance.$type,
};
_$_FilterWithIsIn _$$_FilterWithIsInFromJson(Map<String, dynamic> json) =>
_$_FilterWithIsIn(
column: json['column'] as String,
invert: json['invert'] as bool? ?? false,
values: json['values'] == null
? const IListConst([])
: IList<String>.fromJson(json['values'], (value) => value as String),
$type: json['runtimeType'] as String?,
);
Map<String, dynamic> _$$_FilterWithIsInToJson(_$_FilterWithIsIn instance) =>
<String, dynamic>{
'column': instance.column,
'invert': instance.invert,
'values': instance.values.toJson(
(value) => value,
),
'runtimeType': instance.$type,
};
_$_ListQuery _$$_ListQueryFromJson(Map<String, dynamic> json) => _$_ListQuery(
page: json['page'] == null
? const Pagination(limit: -1, offset: 0)
: Pagination.fromJson(json['page'] as Map<String, dynamic>),
sort: json['sort'] == null
? null
: SortBy.fromJson(json['sort'] as Map<String, dynamic>),
filters: json['filters'] == null
? const IListConst([])
: IList<FilterWith>.fromJson(json['filters'],
(value) => FilterWith.fromJson(value as Map<String, dynamic>)),
);
Map<String, dynamic> _$$_ListQueryToJson(_$_ListQuery instance) =>
<String, dynamic>{
'page': instance.page,
'sort': instance.sort,
'filters': instance.filters.toJson(
(value) => value,
),
};

120
lib/models/settings.dart Normal file
View File

@@ -0,0 +1,120 @@
import 'package:drift/drift.dart' show Value;
import 'package:fast_immutable_collections/fast_immutable_collections.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import '../database/database.dart';
part 'settings.freezed.dart';
@freezed
class Settings with _$Settings {
const factory Settings({
@Default(IListConst([])) IList<SourceSettings> sources,
SourceSettings? activeSource,
@Default(AppSettings()) AppSettings app,
}) = _Settings;
}
@freezed
class AppSettings with _$AppSettings {
const AppSettings._();
const factory AppSettings({
@Default(0) int maxBitrateWifi,
@Default(192) int maxBitrateMobile,
@Default('mp3') String? streamFormat,
}) = _AppSettings;
AppSettingsCompanion toCompanion() {
return AppSettingsCompanion.insert(
id: const Value(1),
maxBitrateWifi: maxBitrateWifi,
maxBitrateMobile: maxBitrateMobile,
streamFormat: Value(streamFormat),
);
}
}
class ParentChild<T> {
final T parent;
final T child;
ParentChild(this.parent, this.child);
}
abstract class SourceSettings {
const SourceSettings();
int get id;
String get name;
Uri get address;
bool? get isActive;
DateTime get createdAt;
}
enum SubsonicFeature {
emptyQuerySearch('emptyQuerySearch');
const SubsonicFeature(this.value);
final String value;
@override
String toString() => value;
}
@freezed
class SubsonicSettings with _$SubsonicSettings implements SourceSettings {
const SubsonicSettings._();
const factory SubsonicSettings({
required int id,
@Default(IListConst([])) IList<SubsonicFeature> features,
required String name,
required Uri address,
required bool? isActive,
required DateTime createdAt,
required String username,
required String password,
@Default(true) bool useTokenAuth,
}) = _SubsonicSettings;
SourcesCompanion toSourceInsertable() {
return SourcesCompanion(
id: Value(id),
name: Value(name),
address: Value(address),
createdAt: Value(createdAt),
);
}
SubsonicSourcesCompanion toSubsonicInsertable() {
return SubsonicSourcesCompanion(
sourceId: Value(id),
features: Value(features),
username: Value(username),
password: Value(password),
useTokenAuth: Value(useTokenAuth),
);
}
}
@freezed
class SubsonicSourceSettings with _$SubsonicSourceSettings {
const SubsonicSourceSettings._();
const factory SubsonicSourceSettings({
required SourceSettings source,
required SubsonicSettings subsonic,
}) = _SubsonicSourceSettings;
}
enum NetworkMode {
mobile('mobile'),
wifi('wifi');
const NetworkMode(this.value);
final String value;
@override
String toString() => value;
}

View File

@@ -0,0 +1,810 @@
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
part of 'settings.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
T _$identity<T>(T value) => value;
final _privateConstructorUsedError = UnsupportedError(
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
/// @nodoc
mixin _$Settings {
IList<SourceSettings> get sources => throw _privateConstructorUsedError;
SourceSettings? get activeSource => throw _privateConstructorUsedError;
AppSettings get app => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SettingsCopyWith<Settings> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SettingsCopyWith<$Res> {
factory $SettingsCopyWith(Settings value, $Res Function(Settings) then) =
_$SettingsCopyWithImpl<$Res, Settings>;
@useResult
$Res call(
{IList<SourceSettings> sources,
SourceSettings? activeSource,
AppSettings app});
$AppSettingsCopyWith<$Res> get app;
}
/// @nodoc
class _$SettingsCopyWithImpl<$Res, $Val extends Settings>
implements $SettingsCopyWith<$Res> {
_$SettingsCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? sources = null,
Object? activeSource = freezed,
Object? app = null,
}) {
return _then(_value.copyWith(
sources: null == sources
? _value.sources
: sources // ignore: cast_nullable_to_non_nullable
as IList<SourceSettings>,
activeSource: freezed == activeSource
? _value.activeSource
: activeSource // ignore: cast_nullable_to_non_nullable
as SourceSettings?,
app: null == app
? _value.app
: app // ignore: cast_nullable_to_non_nullable
as AppSettings,
) as $Val);
}
@override
@pragma('vm:prefer-inline')
$AppSettingsCopyWith<$Res> get app {
return $AppSettingsCopyWith<$Res>(_value.app, (value) {
return _then(_value.copyWith(app: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$_SettingsCopyWith<$Res> implements $SettingsCopyWith<$Res> {
factory _$$_SettingsCopyWith(
_$_Settings value, $Res Function(_$_Settings) then) =
__$$_SettingsCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{IList<SourceSettings> sources,
SourceSettings? activeSource,
AppSettings app});
@override
$AppSettingsCopyWith<$Res> get app;
}
/// @nodoc
class __$$_SettingsCopyWithImpl<$Res>
extends _$SettingsCopyWithImpl<$Res, _$_Settings>
implements _$$_SettingsCopyWith<$Res> {
__$$_SettingsCopyWithImpl(
_$_Settings _value, $Res Function(_$_Settings) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? sources = null,
Object? activeSource = freezed,
Object? app = null,
}) {
return _then(_$_Settings(
sources: null == sources
? _value.sources
: sources // ignore: cast_nullable_to_non_nullable
as IList<SourceSettings>,
activeSource: freezed == activeSource
? _value.activeSource
: activeSource // ignore: cast_nullable_to_non_nullable
as SourceSettings?,
app: null == app
? _value.app
: app // ignore: cast_nullable_to_non_nullable
as AppSettings,
));
}
}
/// @nodoc
class _$_Settings implements _Settings {
const _$_Settings(
{this.sources = const IListConst([]),
this.activeSource,
this.app = const AppSettings()});
@override
@JsonKey()
final IList<SourceSettings> sources;
@override
final SourceSettings? activeSource;
@override
@JsonKey()
final AppSettings app;
@override
String toString() {
return 'Settings(sources: $sources, activeSource: $activeSource, app: $app)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_Settings &&
const DeepCollectionEquality().equals(other.sources, sources) &&
(identical(other.activeSource, activeSource) ||
other.activeSource == activeSource) &&
(identical(other.app, app) || other.app == app));
}
@override
int get hashCode => Object.hash(runtimeType,
const DeepCollectionEquality().hash(sources), activeSource, app);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_SettingsCopyWith<_$_Settings> get copyWith =>
__$$_SettingsCopyWithImpl<_$_Settings>(this, _$identity);
}
abstract class _Settings implements Settings {
const factory _Settings(
{final IList<SourceSettings> sources,
final SourceSettings? activeSource,
final AppSettings app}) = _$_Settings;
@override
IList<SourceSettings> get sources;
@override
SourceSettings? get activeSource;
@override
AppSettings get app;
@override
@JsonKey(ignore: true)
_$$_SettingsCopyWith<_$_Settings> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$AppSettings {
int get maxBitrateWifi => throw _privateConstructorUsedError;
int get maxBitrateMobile => throw _privateConstructorUsedError;
String? get streamFormat => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$AppSettingsCopyWith<AppSettings> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $AppSettingsCopyWith<$Res> {
factory $AppSettingsCopyWith(
AppSettings value, $Res Function(AppSettings) then) =
_$AppSettingsCopyWithImpl<$Res, AppSettings>;
@useResult
$Res call({int maxBitrateWifi, int maxBitrateMobile, String? streamFormat});
}
/// @nodoc
class _$AppSettingsCopyWithImpl<$Res, $Val extends AppSettings>
implements $AppSettingsCopyWith<$Res> {
_$AppSettingsCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? maxBitrateWifi = null,
Object? maxBitrateMobile = null,
Object? streamFormat = freezed,
}) {
return _then(_value.copyWith(
maxBitrateWifi: null == maxBitrateWifi
? _value.maxBitrateWifi
: maxBitrateWifi // ignore: cast_nullable_to_non_nullable
as int,
maxBitrateMobile: null == maxBitrateMobile
? _value.maxBitrateMobile
: maxBitrateMobile // ignore: cast_nullable_to_non_nullable
as int,
streamFormat: freezed == streamFormat
? _value.streamFormat
: streamFormat // ignore: cast_nullable_to_non_nullable
as String?,
) as $Val);
}
}
/// @nodoc
abstract class _$$_AppSettingsCopyWith<$Res>
implements $AppSettingsCopyWith<$Res> {
factory _$$_AppSettingsCopyWith(
_$_AppSettings value, $Res Function(_$_AppSettings) then) =
__$$_AppSettingsCopyWithImpl<$Res>;
@override
@useResult
$Res call({int maxBitrateWifi, int maxBitrateMobile, String? streamFormat});
}
/// @nodoc
class __$$_AppSettingsCopyWithImpl<$Res>
extends _$AppSettingsCopyWithImpl<$Res, _$_AppSettings>
implements _$$_AppSettingsCopyWith<$Res> {
__$$_AppSettingsCopyWithImpl(
_$_AppSettings _value, $Res Function(_$_AppSettings) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? maxBitrateWifi = null,
Object? maxBitrateMobile = null,
Object? streamFormat = freezed,
}) {
return _then(_$_AppSettings(
maxBitrateWifi: null == maxBitrateWifi
? _value.maxBitrateWifi
: maxBitrateWifi // ignore: cast_nullable_to_non_nullable
as int,
maxBitrateMobile: null == maxBitrateMobile
? _value.maxBitrateMobile
: maxBitrateMobile // ignore: cast_nullable_to_non_nullable
as int,
streamFormat: freezed == streamFormat
? _value.streamFormat
: streamFormat // ignore: cast_nullable_to_non_nullable
as String?,
));
}
}
/// @nodoc
class _$_AppSettings extends _AppSettings {
const _$_AppSettings(
{this.maxBitrateWifi = 0,
this.maxBitrateMobile = 192,
this.streamFormat = 'mp3'})
: super._();
@override
@JsonKey()
final int maxBitrateWifi;
@override
@JsonKey()
final int maxBitrateMobile;
@override
@JsonKey()
final String? streamFormat;
@override
String toString() {
return 'AppSettings(maxBitrateWifi: $maxBitrateWifi, maxBitrateMobile: $maxBitrateMobile, streamFormat: $streamFormat)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_AppSettings &&
(identical(other.maxBitrateWifi, maxBitrateWifi) ||
other.maxBitrateWifi == maxBitrateWifi) &&
(identical(other.maxBitrateMobile, maxBitrateMobile) ||
other.maxBitrateMobile == maxBitrateMobile) &&
(identical(other.streamFormat, streamFormat) ||
other.streamFormat == streamFormat));
}
@override
int get hashCode =>
Object.hash(runtimeType, maxBitrateWifi, maxBitrateMobile, streamFormat);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_AppSettingsCopyWith<_$_AppSettings> get copyWith =>
__$$_AppSettingsCopyWithImpl<_$_AppSettings>(this, _$identity);
}
abstract class _AppSettings extends AppSettings {
const factory _AppSettings(
{final int maxBitrateWifi,
final int maxBitrateMobile,
final String? streamFormat}) = _$_AppSettings;
const _AppSettings._() : super._();
@override
int get maxBitrateWifi;
@override
int get maxBitrateMobile;
@override
String? get streamFormat;
@override
@JsonKey(ignore: true)
_$$_AppSettingsCopyWith<_$_AppSettings> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$SubsonicSettings {
int get id => throw _privateConstructorUsedError;
IList<SubsonicFeature> get features => throw _privateConstructorUsedError;
String get name => throw _privateConstructorUsedError;
Uri get address => throw _privateConstructorUsedError;
bool? get isActive => throw _privateConstructorUsedError;
DateTime get createdAt => throw _privateConstructorUsedError;
String get username => throw _privateConstructorUsedError;
String get password => throw _privateConstructorUsedError;
bool get useTokenAuth => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SubsonicSettingsCopyWith<SubsonicSettings> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SubsonicSettingsCopyWith<$Res> {
factory $SubsonicSettingsCopyWith(
SubsonicSettings value, $Res Function(SubsonicSettings) then) =
_$SubsonicSettingsCopyWithImpl<$Res, SubsonicSettings>;
@useResult
$Res call(
{int id,
IList<SubsonicFeature> features,
String name,
Uri address,
bool? isActive,
DateTime createdAt,
String username,
String password,
bool useTokenAuth});
}
/// @nodoc
class _$SubsonicSettingsCopyWithImpl<$Res, $Val extends SubsonicSettings>
implements $SubsonicSettingsCopyWith<$Res> {
_$SubsonicSettingsCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? features = null,
Object? name = null,
Object? address = null,
Object? isActive = freezed,
Object? createdAt = null,
Object? username = null,
Object? password = null,
Object? useTokenAuth = null,
}) {
return _then(_value.copyWith(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
features: null == features
? _value.features
: features // ignore: cast_nullable_to_non_nullable
as IList<SubsonicFeature>,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
address: null == address
? _value.address
: address // ignore: cast_nullable_to_non_nullable
as Uri,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
username: null == username
? _value.username
: username // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
useTokenAuth: null == useTokenAuth
? _value.useTokenAuth
: useTokenAuth // ignore: cast_nullable_to_non_nullable
as bool,
) as $Val);
}
}
/// @nodoc
abstract class _$$_SubsonicSettingsCopyWith<$Res>
implements $SubsonicSettingsCopyWith<$Res> {
factory _$$_SubsonicSettingsCopyWith(
_$_SubsonicSettings value, $Res Function(_$_SubsonicSettings) then) =
__$$_SubsonicSettingsCopyWithImpl<$Res>;
@override
@useResult
$Res call(
{int id,
IList<SubsonicFeature> features,
String name,
Uri address,
bool? isActive,
DateTime createdAt,
String username,
String password,
bool useTokenAuth});
}
/// @nodoc
class __$$_SubsonicSettingsCopyWithImpl<$Res>
extends _$SubsonicSettingsCopyWithImpl<$Res, _$_SubsonicSettings>
implements _$$_SubsonicSettingsCopyWith<$Res> {
__$$_SubsonicSettingsCopyWithImpl(
_$_SubsonicSettings _value, $Res Function(_$_SubsonicSettings) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? id = null,
Object? features = null,
Object? name = null,
Object? address = null,
Object? isActive = freezed,
Object? createdAt = null,
Object? username = null,
Object? password = null,
Object? useTokenAuth = null,
}) {
return _then(_$_SubsonicSettings(
id: null == id
? _value.id
: id // ignore: cast_nullable_to_non_nullable
as int,
features: null == features
? _value.features
: features // ignore: cast_nullable_to_non_nullable
as IList<SubsonicFeature>,
name: null == name
? _value.name
: name // ignore: cast_nullable_to_non_nullable
as String,
address: null == address
? _value.address
: address // ignore: cast_nullable_to_non_nullable
as Uri,
isActive: freezed == isActive
? _value.isActive
: isActive // ignore: cast_nullable_to_non_nullable
as bool?,
createdAt: null == createdAt
? _value.createdAt
: createdAt // ignore: cast_nullable_to_non_nullable
as DateTime,
username: null == username
? _value.username
: username // ignore: cast_nullable_to_non_nullable
as String,
password: null == password
? _value.password
: password // ignore: cast_nullable_to_non_nullable
as String,
useTokenAuth: null == useTokenAuth
? _value.useTokenAuth
: useTokenAuth // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// @nodoc
class _$_SubsonicSettings extends _SubsonicSettings {
const _$_SubsonicSettings(
{required this.id,
this.features = const IListConst([]),
required this.name,
required this.address,
required this.isActive,
required this.createdAt,
required this.username,
required this.password,
this.useTokenAuth = true})
: super._();
@override
final int id;
@override
@JsonKey()
final IList<SubsonicFeature> features;
@override
final String name;
@override
final Uri address;
@override
final bool? isActive;
@override
final DateTime createdAt;
@override
final String username;
@override
final String password;
@override
@JsonKey()
final bool useTokenAuth;
@override
String toString() {
return 'SubsonicSettings(id: $id, features: $features, name: $name, address: $address, isActive: $isActive, createdAt: $createdAt, username: $username, password: $password, useTokenAuth: $useTokenAuth)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_SubsonicSettings &&
(identical(other.id, id) || other.id == id) &&
const DeepCollectionEquality().equals(other.features, features) &&
(identical(other.name, name) || other.name == name) &&
(identical(other.address, address) || other.address == address) &&
(identical(other.isActive, isActive) ||
other.isActive == isActive) &&
(identical(other.createdAt, createdAt) ||
other.createdAt == createdAt) &&
(identical(other.username, username) ||
other.username == username) &&
(identical(other.password, password) ||
other.password == password) &&
(identical(other.useTokenAuth, useTokenAuth) ||
other.useTokenAuth == useTokenAuth));
}
@override
int get hashCode => Object.hash(
runtimeType,
id,
const DeepCollectionEquality().hash(features),
name,
address,
isActive,
createdAt,
username,
password,
useTokenAuth);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_SubsonicSettingsCopyWith<_$_SubsonicSettings> get copyWith =>
__$$_SubsonicSettingsCopyWithImpl<_$_SubsonicSettings>(this, _$identity);
}
abstract class _SubsonicSettings extends SubsonicSettings {
const factory _SubsonicSettings(
{required final int id,
final IList<SubsonicFeature> features,
required final String name,
required final Uri address,
required final bool? isActive,
required final DateTime createdAt,
required final String username,
required final String password,
final bool useTokenAuth}) = _$_SubsonicSettings;
const _SubsonicSettings._() : super._();
@override
int get id;
@override
IList<SubsonicFeature> get features;
@override
String get name;
@override
Uri get address;
@override
bool? get isActive;
@override
DateTime get createdAt;
@override
String get username;
@override
String get password;
@override
bool get useTokenAuth;
@override
@JsonKey(ignore: true)
_$$_SubsonicSettingsCopyWith<_$_SubsonicSettings> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
mixin _$SubsonicSourceSettings {
SourceSettings get source => throw _privateConstructorUsedError;
SubsonicSettings get subsonic => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
$SubsonicSourceSettingsCopyWith<SubsonicSourceSettings> get copyWith =>
throw _privateConstructorUsedError;
}
/// @nodoc
abstract class $SubsonicSourceSettingsCopyWith<$Res> {
factory $SubsonicSourceSettingsCopyWith(SubsonicSourceSettings value,
$Res Function(SubsonicSourceSettings) then) =
_$SubsonicSourceSettingsCopyWithImpl<$Res, SubsonicSourceSettings>;
@useResult
$Res call({SourceSettings source, SubsonicSettings subsonic});
$SubsonicSettingsCopyWith<$Res> get subsonic;
}
/// @nodoc
class _$SubsonicSourceSettingsCopyWithImpl<$Res,
$Val extends SubsonicSourceSettings>
implements $SubsonicSourceSettingsCopyWith<$Res> {
_$SubsonicSourceSettingsCopyWithImpl(this._value, this._then);
// ignore: unused_field
final $Val _value;
// ignore: unused_field
final $Res Function($Val) _then;
@pragma('vm:prefer-inline')
@override
$Res call({
Object? source = null,
Object? subsonic = null,
}) {
return _then(_value.copyWith(
source: null == source
? _value.source
: source // ignore: cast_nullable_to_non_nullable
as SourceSettings,
subsonic: null == subsonic
? _value.subsonic
: subsonic // ignore: cast_nullable_to_non_nullable
as SubsonicSettings,
) as $Val);
}
@override
@pragma('vm:prefer-inline')
$SubsonicSettingsCopyWith<$Res> get subsonic {
return $SubsonicSettingsCopyWith<$Res>(_value.subsonic, (value) {
return _then(_value.copyWith(subsonic: value) as $Val);
});
}
}
/// @nodoc
abstract class _$$_SubsonicSourceSettingsCopyWith<$Res>
implements $SubsonicSourceSettingsCopyWith<$Res> {
factory _$$_SubsonicSourceSettingsCopyWith(_$_SubsonicSourceSettings value,
$Res Function(_$_SubsonicSourceSettings) then) =
__$$_SubsonicSourceSettingsCopyWithImpl<$Res>;
@override
@useResult
$Res call({SourceSettings source, SubsonicSettings subsonic});
@override
$SubsonicSettingsCopyWith<$Res> get subsonic;
}
/// @nodoc
class __$$_SubsonicSourceSettingsCopyWithImpl<$Res>
extends _$SubsonicSourceSettingsCopyWithImpl<$Res,
_$_SubsonicSourceSettings>
implements _$$_SubsonicSourceSettingsCopyWith<$Res> {
__$$_SubsonicSourceSettingsCopyWithImpl(_$_SubsonicSourceSettings _value,
$Res Function(_$_SubsonicSourceSettings) _then)
: super(_value, _then);
@pragma('vm:prefer-inline')
@override
$Res call({
Object? source = null,
Object? subsonic = null,
}) {
return _then(_$_SubsonicSourceSettings(
source: null == source
? _value.source
: source // ignore: cast_nullable_to_non_nullable
as SourceSettings,
subsonic: null == subsonic
? _value.subsonic
: subsonic // ignore: cast_nullable_to_non_nullable
as SubsonicSettings,
));
}
}
/// @nodoc
class _$_SubsonicSourceSettings extends _SubsonicSourceSettings {
const _$_SubsonicSourceSettings(
{required this.source, required this.subsonic})
: super._();
@override
final SourceSettings source;
@override
final SubsonicSettings subsonic;
@override
String toString() {
return 'SubsonicSourceSettings(source: $source, subsonic: $subsonic)';
}
@override
bool operator ==(dynamic other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$_SubsonicSourceSettings &&
(identical(other.source, source) || other.source == source) &&
(identical(other.subsonic, subsonic) ||
other.subsonic == subsonic));
}
@override
int get hashCode => Object.hash(runtimeType, source, subsonic);
@JsonKey(ignore: true)
@override
@pragma('vm:prefer-inline')
_$$_SubsonicSourceSettingsCopyWith<_$_SubsonicSourceSettings> get copyWith =>
__$$_SubsonicSourceSettingsCopyWithImpl<_$_SubsonicSourceSettings>(
this, _$identity);
}
abstract class _SubsonicSourceSettings extends SubsonicSourceSettings {
const factory _SubsonicSourceSettings(
{required final SourceSettings source,
required final SubsonicSettings subsonic}) = _$_SubsonicSourceSettings;
const _SubsonicSourceSettings._() : super._();
@override
SourceSettings get source;
@override
SubsonicSettings get subsonic;
@override
@JsonKey(ignore: true)
_$$_SubsonicSourceSettingsCopyWith<_$_SubsonicSourceSettings> get copyWith =>
throw _privateConstructorUsedError;
}

186
lib/models/support.dart Normal file
View File

@@ -0,0 +1,186 @@
import 'package:audio_service/audio_service.dart' show MediaItem;
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:palette_generator/palette_generator.dart';
part 'support.freezed.dart';
part 'support.g.dart';
@freezed
class UriCacheInfo with _$UriCacheInfo {
const factory UriCacheInfo({
required Uri uri,
required String cacheKey,
required CacheManager cacheManager,
}) = _UriCacheInfo;
}
@freezed
class CacheInfo with _$CacheInfo {
const factory CacheInfo({
required String cacheKey,
required CacheManager cacheManager,
}) = _CacheInfo;
}
@freezed
class Palette with _$Palette {
const Palette._();
const factory Palette({
PaletteColor? vibrantColor,
PaletteColor? dominantColor,
PaletteColor? mutedColor,
PaletteColor? darkMutedColor,
PaletteColor? darkVibrantColor,
PaletteColor? lightMutedColor,
PaletteColor? lightVibrantColor,
}) = _Palette;
factory Palette.fromPaletteGenerator(PaletteGenerator generator) {
return Palette(
vibrantColor: generator.vibrantColor,
dominantColor: generator.dominantColor,
mutedColor: generator.mutedColor,
darkMutedColor: generator.darkMutedColor,
darkVibrantColor: generator.darkVibrantColor,
lightMutedColor: generator.lightMutedColor,
lightVibrantColor: generator.lightVibrantColor,
);
}
}
@freezed
class ColorTheme with _$ColorTheme {
const factory ColorTheme({
required ThemeData theme,
required Color gradientHigh,
required Color gradientLow,
required Color darkBackground,
required Color darkerBackground,
required Color onDarkerBackground,
}) = _ColorTheme;
}
enum QueueContextType {
song('song'),
album('album'),
playlist('playlist'),
library('library'),
genre('genre');
const QueueContextType(this.value);
final String value;
@override
String toString() => value;
}
enum QueueMode {
user('user'),
radio('radio');
const QueueMode(this.value);
final String value;
@override
String toString() => value;
}
enum RepeatMode {
none('none'),
all('all'),
one('one');
const RepeatMode(this.value);
final String value;
@override
String toString() => value;
}
@freezed
class QueueItemState with _$QueueItemState {
const factory QueueItemState({
required String id,
required QueueContextType contextType,
String? contextId,
String? contextTitle,
}) = _QueueItemState;
factory QueueItemState.fromJson(Map<String, dynamic> json) =>
_$QueueItemStateFromJson(json);
}
@freezed
class MediaItemData with _$MediaItemData {
const factory MediaItemData({
required int sourceId,
String? albumId,
@MediaItemArtCacheConverter() MediaItemArtCache? artCache,
required QueueContextType contextType,
String? contextId,
}) = _MediaItemData;
factory MediaItemData.fromJson(Map<String, dynamic> json) =>
_$MediaItemDataFromJson(json);
}
@freezed
class MediaItemArtCache with _$MediaItemArtCache {
const factory MediaItemArtCache({
required Uri fullArtUri,
required String fullArtCacheKey,
required Uri thumbnailArtUri,
required String thumbnailArtCacheKey,
}) = _MediaItemArtCache;
factory MediaItemArtCache.fromJson(Map<String, dynamic> json) =>
_$MediaItemArtCacheFromJson(json);
}
class MediaItemArtCacheConverter
implements JsonConverter<MediaItemArtCache, Map<String, dynamic>> {
const MediaItemArtCacheConverter();
@override
MediaItemArtCache fromJson(Map<String, dynamic> json) =>
MediaItemArtCache.fromJson(json);
@override
Map<String, dynamic> toJson(MediaItemArtCache object) => object.toJson();
}
extension MediaItemPlus on MediaItem {
MediaItemData get data => MediaItemData.fromJson(extras!['data']);
set data(MediaItemData data) {
extras!['data'] = data.toJson();
}
}
@freezed
class ListDownloadStatus with _$ListDownloadStatus {
const factory ListDownloadStatus({
required int total,
required int downloaded,
required int downloading,
}) = _ListDownloadStatus;
}
@freezed
class MultiChoiceOption with _$MultiChoiceOption {
const factory MultiChoiceOption({
required String title,
}) = _MultiChoiceOption;
factory MultiChoiceOption.int({
required String title,
required int option,
}) = _MultiChoiceOptionInt;
factory MultiChoiceOption.string({
required String title,
required String option,
}) = _MultiChoiceOptionString;
}

File diff suppressed because it is too large Load Diff

82
lib/models/support.g.dart Normal file
View File

@@ -0,0 +1,82 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'support.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
_$_QueueItemState _$$_QueueItemStateFromJson(Map<String, dynamic> json) =>
_$_QueueItemState(
id: json['id'] as String,
contextType: $enumDecode(_$QueueContextTypeEnumMap, json['contextType']),
contextId: json['contextId'] as String?,
contextTitle: json['contextTitle'] as String?,
);
Map<String, dynamic> _$$_QueueItemStateToJson(_$_QueueItemState instance) =>
<String, dynamic>{
'id': instance.id,
'contextType': _$QueueContextTypeEnumMap[instance.contextType]!,
'contextId': instance.contextId,
'contextTitle': instance.contextTitle,
};
const _$QueueContextTypeEnumMap = {
QueueContextType.song: 'song',
QueueContextType.album: 'album',
QueueContextType.playlist: 'playlist',
QueueContextType.library: 'library',
QueueContextType.genre: 'genre',
};
_$_MediaItemData _$$_MediaItemDataFromJson(Map<String, dynamic> json) =>
_$_MediaItemData(
sourceId: json['sourceId'] as int,
albumId: json['albumId'] as String?,
artCache:
_$JsonConverterFromJson<Map<String, dynamic>, MediaItemArtCache>(
json['artCache'], const MediaItemArtCacheConverter().fromJson),
contextType: $enumDecode(_$QueueContextTypeEnumMap, json['contextType']),
contextId: json['contextId'] as String?,
);
Map<String, dynamic> _$$_MediaItemDataToJson(_$_MediaItemData instance) =>
<String, dynamic>{
'sourceId': instance.sourceId,
'albumId': instance.albumId,
'artCache':
_$JsonConverterToJson<Map<String, dynamic>, MediaItemArtCache>(
instance.artCache, const MediaItemArtCacheConverter().toJson),
'contextType': _$QueueContextTypeEnumMap[instance.contextType]!,
'contextId': instance.contextId,
};
Value? _$JsonConverterFromJson<Json, Value>(
Object? json,
Value? Function(Json json) fromJson,
) =>
json == null ? null : fromJson(json as Json);
Json? _$JsonConverterToJson<Json, Value>(
Value? value,
Json? Function(Value value) toJson,
) =>
value == null ? null : toJson(value);
_$_MediaItemArtCache _$$_MediaItemArtCacheFromJson(Map<String, dynamic> json) =>
_$_MediaItemArtCache(
fullArtUri: Uri.parse(json['fullArtUri'] as String),
fullArtCacheKey: json['fullArtCacheKey'] as String,
thumbnailArtUri: Uri.parse(json['thumbnailArtUri'] as String),
thumbnailArtCacheKey: json['thumbnailArtCacheKey'] as String,
);
Map<String, dynamic> _$$_MediaItemArtCacheToJson(
_$_MediaItemArtCache instance) =>
<String, dynamic>{
'fullArtUri': instance.fullArtUri.toString(),
'fullArtCacheKey': instance.fullArtCacheKey,
'thumbnailArtUri': instance.thumbnailArtUri.toString(),
'thumbnailArtCacheKey': instance.thumbnailArtCacheKey,
};