initial commit (migrated)

This commit is contained in:
fiatcode 2025-10-20 16:43:59 +07:00
commit b594facb51
143 changed files with 11057 additions and 0 deletions

View file

@ -0,0 +1,49 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:kuwot/features/quote/data/models/image_model.dart';
part 'background_image.freezed.dart';
@freezed
abstract class BackgroundImage with _$BackgroundImage {
const BackgroundImage._();
const factory BackgroundImage({
required String id,
required String description,
required String color,
required String blurHash,
required String url,
required String originUrl,
required String authorName,
required String authorProfileImageUrl,
required String authorUrl,
required String authorBio,
required String authorLocation,
required int authorTotalLikes,
required int authorTotalPhotos,
required bool authorIsForHire,
}) = _BackgroundImage;
static List<BackgroundImage> fromModels(List<ImageModel> images) {
return images
.map(
(e) => BackgroundImage(
id: e.id,
description: e.description,
color: e.color,
blurHash: e.blurHash,
url: e.url,
originUrl: e.originUrl,
authorUrl: e.authorUrl,
authorName: e.authorName,
authorProfileImageUrl: e.authorProfileImageUrl,
authorBio: e.authorBio,
authorLocation: e.authorLocation,
authorTotalLikes: e.authorTotalLikes,
authorTotalPhotos: e.authorTotalPhotos,
authorIsForHire: e.authorIsForHire,
),
)
.toList();
}
}

View file

@ -0,0 +1,310 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'background_image.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$BackgroundImage {
String get id; String get description; String get color; String get blurHash; String get url; String get originUrl; String get authorName; String get authorProfileImageUrl; String get authorUrl; String get authorBio; String get authorLocation; int get authorTotalLikes; int get authorTotalPhotos; bool get authorIsForHire;
/// Create a copy of BackgroundImage
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$BackgroundImageCopyWith<BackgroundImage> get copyWith => _$BackgroundImageCopyWithImpl<BackgroundImage>(this as BackgroundImage, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is BackgroundImage&&(identical(other.id, id) || other.id == id)&&(identical(other.description, description) || other.description == description)&&(identical(other.color, color) || other.color == color)&&(identical(other.blurHash, blurHash) || other.blurHash == blurHash)&&(identical(other.url, url) || other.url == url)&&(identical(other.originUrl, originUrl) || other.originUrl == originUrl)&&(identical(other.authorName, authorName) || other.authorName == authorName)&&(identical(other.authorProfileImageUrl, authorProfileImageUrl) || other.authorProfileImageUrl == authorProfileImageUrl)&&(identical(other.authorUrl, authorUrl) || other.authorUrl == authorUrl)&&(identical(other.authorBio, authorBio) || other.authorBio == authorBio)&&(identical(other.authorLocation, authorLocation) || other.authorLocation == authorLocation)&&(identical(other.authorTotalLikes, authorTotalLikes) || other.authorTotalLikes == authorTotalLikes)&&(identical(other.authorTotalPhotos, authorTotalPhotos) || other.authorTotalPhotos == authorTotalPhotos)&&(identical(other.authorIsForHire, authorIsForHire) || other.authorIsForHire == authorIsForHire));
}
@override
int get hashCode => Object.hash(runtimeType,id,description,color,blurHash,url,originUrl,authorName,authorProfileImageUrl,authorUrl,authorBio,authorLocation,authorTotalLikes,authorTotalPhotos,authorIsForHire);
@override
String toString() {
return 'BackgroundImage(id: $id, description: $description, color: $color, blurHash: $blurHash, url: $url, originUrl: $originUrl, authorName: $authorName, authorProfileImageUrl: $authorProfileImageUrl, authorUrl: $authorUrl, authorBio: $authorBio, authorLocation: $authorLocation, authorTotalLikes: $authorTotalLikes, authorTotalPhotos: $authorTotalPhotos, authorIsForHire: $authorIsForHire)';
}
}
/// @nodoc
abstract mixin class $BackgroundImageCopyWith<$Res> {
factory $BackgroundImageCopyWith(BackgroundImage value, $Res Function(BackgroundImage) _then) = _$BackgroundImageCopyWithImpl;
@useResult
$Res call({
String id, String description, String color, String blurHash, String url, String originUrl, String authorName, String authorProfileImageUrl, String authorUrl, String authorBio, String authorLocation, int authorTotalLikes, int authorTotalPhotos, bool authorIsForHire
});
}
/// @nodoc
class _$BackgroundImageCopyWithImpl<$Res>
implements $BackgroundImageCopyWith<$Res> {
_$BackgroundImageCopyWithImpl(this._self, this._then);
final BackgroundImage _self;
final $Res Function(BackgroundImage) _then;
/// Create a copy of BackgroundImage
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? description = null,Object? color = null,Object? blurHash = null,Object? url = null,Object? originUrl = null,Object? authorName = null,Object? authorProfileImageUrl = null,Object? authorUrl = null,Object? authorBio = null,Object? authorLocation = null,Object? authorTotalLikes = null,Object? authorTotalPhotos = null,Object? authorIsForHire = null,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
as String,color: null == color ? _self.color : color // ignore: cast_nullable_to_non_nullable
as String,blurHash: null == blurHash ? _self.blurHash : blurHash // ignore: cast_nullable_to_non_nullable
as String,url: null == url ? _self.url : url // ignore: cast_nullable_to_non_nullable
as String,originUrl: null == originUrl ? _self.originUrl : originUrl // ignore: cast_nullable_to_non_nullable
as String,authorName: null == authorName ? _self.authorName : authorName // ignore: cast_nullable_to_non_nullable
as String,authorProfileImageUrl: null == authorProfileImageUrl ? _self.authorProfileImageUrl : authorProfileImageUrl // ignore: cast_nullable_to_non_nullable
as String,authorUrl: null == authorUrl ? _self.authorUrl : authorUrl // ignore: cast_nullable_to_non_nullable
as String,authorBio: null == authorBio ? _self.authorBio : authorBio // ignore: cast_nullable_to_non_nullable
as String,authorLocation: null == authorLocation ? _self.authorLocation : authorLocation // ignore: cast_nullable_to_non_nullable
as String,authorTotalLikes: null == authorTotalLikes ? _self.authorTotalLikes : authorTotalLikes // ignore: cast_nullable_to_non_nullable
as int,authorTotalPhotos: null == authorTotalPhotos ? _self.authorTotalPhotos : authorTotalPhotos // ignore: cast_nullable_to_non_nullable
as int,authorIsForHire: null == authorIsForHire ? _self.authorIsForHire : authorIsForHire // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
/// Adds pattern-matching-related methods to [BackgroundImage].
extension BackgroundImagePatterns on BackgroundImage {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BackgroundImage value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BackgroundImage value) $default,){
final _that = this;
switch (_that) {
case _BackgroundImage():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BackgroundImage value)? $default,){
final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String description, String color, String blurHash, String url, String originUrl, String authorName, String authorProfileImageUrl, String authorUrl, String authorBio, String authorLocation, int authorTotalLikes, int authorTotalPhotos, bool authorIsForHire)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that.id,_that.description,_that.color,_that.blurHash,_that.url,_that.originUrl,_that.authorName,_that.authorProfileImageUrl,_that.authorUrl,_that.authorBio,_that.authorLocation,_that.authorTotalLikes,_that.authorTotalPhotos,_that.authorIsForHire);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String description, String color, String blurHash, String url, String originUrl, String authorName, String authorProfileImageUrl, String authorUrl, String authorBio, String authorLocation, int authorTotalLikes, int authorTotalPhotos, bool authorIsForHire) $default,) {final _that = this;
switch (_that) {
case _BackgroundImage():
return $default(_that.id,_that.description,_that.color,_that.blurHash,_that.url,_that.originUrl,_that.authorName,_that.authorProfileImageUrl,_that.authorUrl,_that.authorBio,_that.authorLocation,_that.authorTotalLikes,_that.authorTotalPhotos,_that.authorIsForHire);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String description, String color, String blurHash, String url, String originUrl, String authorName, String authorProfileImageUrl, String authorUrl, String authorBio, String authorLocation, int authorTotalLikes, int authorTotalPhotos, bool authorIsForHire)? $default,) {final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that.id,_that.description,_that.color,_that.blurHash,_that.url,_that.originUrl,_that.authorName,_that.authorProfileImageUrl,_that.authorUrl,_that.authorBio,_that.authorLocation,_that.authorTotalLikes,_that.authorTotalPhotos,_that.authorIsForHire);case _:
return null;
}
}
}
/// @nodoc
class _BackgroundImage extends BackgroundImage {
const _BackgroundImage({required this.id, required this.description, required this.color, required this.blurHash, required this.url, required this.originUrl, required this.authorName, required this.authorProfileImageUrl, required this.authorUrl, required this.authorBio, required this.authorLocation, required this.authorTotalLikes, required this.authorTotalPhotos, required this.authorIsForHire}): super._();
@override final String id;
@override final String description;
@override final String color;
@override final String blurHash;
@override final String url;
@override final String originUrl;
@override final String authorName;
@override final String authorProfileImageUrl;
@override final String authorUrl;
@override final String authorBio;
@override final String authorLocation;
@override final int authorTotalLikes;
@override final int authorTotalPhotos;
@override final bool authorIsForHire;
/// Create a copy of BackgroundImage
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$BackgroundImageCopyWith<_BackgroundImage> get copyWith => __$BackgroundImageCopyWithImpl<_BackgroundImage>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BackgroundImage&&(identical(other.id, id) || other.id == id)&&(identical(other.description, description) || other.description == description)&&(identical(other.color, color) || other.color == color)&&(identical(other.blurHash, blurHash) || other.blurHash == blurHash)&&(identical(other.url, url) || other.url == url)&&(identical(other.originUrl, originUrl) || other.originUrl == originUrl)&&(identical(other.authorName, authorName) || other.authorName == authorName)&&(identical(other.authorProfileImageUrl, authorProfileImageUrl) || other.authorProfileImageUrl == authorProfileImageUrl)&&(identical(other.authorUrl, authorUrl) || other.authorUrl == authorUrl)&&(identical(other.authorBio, authorBio) || other.authorBio == authorBio)&&(identical(other.authorLocation, authorLocation) || other.authorLocation == authorLocation)&&(identical(other.authorTotalLikes, authorTotalLikes) || other.authorTotalLikes == authorTotalLikes)&&(identical(other.authorTotalPhotos, authorTotalPhotos) || other.authorTotalPhotos == authorTotalPhotos)&&(identical(other.authorIsForHire, authorIsForHire) || other.authorIsForHire == authorIsForHire));
}
@override
int get hashCode => Object.hash(runtimeType,id,description,color,blurHash,url,originUrl,authorName,authorProfileImageUrl,authorUrl,authorBio,authorLocation,authorTotalLikes,authorTotalPhotos,authorIsForHire);
@override
String toString() {
return 'BackgroundImage(id: $id, description: $description, color: $color, blurHash: $blurHash, url: $url, originUrl: $originUrl, authorName: $authorName, authorProfileImageUrl: $authorProfileImageUrl, authorUrl: $authorUrl, authorBio: $authorBio, authorLocation: $authorLocation, authorTotalLikes: $authorTotalLikes, authorTotalPhotos: $authorTotalPhotos, authorIsForHire: $authorIsForHire)';
}
}
/// @nodoc
abstract mixin class _$BackgroundImageCopyWith<$Res> implements $BackgroundImageCopyWith<$Res> {
factory _$BackgroundImageCopyWith(_BackgroundImage value, $Res Function(_BackgroundImage) _then) = __$BackgroundImageCopyWithImpl;
@override @useResult
$Res call({
String id, String description, String color, String blurHash, String url, String originUrl, String authorName, String authorProfileImageUrl, String authorUrl, String authorBio, String authorLocation, int authorTotalLikes, int authorTotalPhotos, bool authorIsForHire
});
}
/// @nodoc
class __$BackgroundImageCopyWithImpl<$Res>
implements _$BackgroundImageCopyWith<$Res> {
__$BackgroundImageCopyWithImpl(this._self, this._then);
final _BackgroundImage _self;
final $Res Function(_BackgroundImage) _then;
/// Create a copy of BackgroundImage
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? description = null,Object? color = null,Object? blurHash = null,Object? url = null,Object? originUrl = null,Object? authorName = null,Object? authorProfileImageUrl = null,Object? authorUrl = null,Object? authorBio = null,Object? authorLocation = null,Object? authorTotalLikes = null,Object? authorTotalPhotos = null,Object? authorIsForHire = null,}) {
return _then(_BackgroundImage(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
as String,color: null == color ? _self.color : color // ignore: cast_nullable_to_non_nullable
as String,blurHash: null == blurHash ? _self.blurHash : blurHash // ignore: cast_nullable_to_non_nullable
as String,url: null == url ? _self.url : url // ignore: cast_nullable_to_non_nullable
as String,originUrl: null == originUrl ? _self.originUrl : originUrl // ignore: cast_nullable_to_non_nullable
as String,authorName: null == authorName ? _self.authorName : authorName // ignore: cast_nullable_to_non_nullable
as String,authorProfileImageUrl: null == authorProfileImageUrl ? _self.authorProfileImageUrl : authorProfileImageUrl // ignore: cast_nullable_to_non_nullable
as String,authorUrl: null == authorUrl ? _self.authorUrl : authorUrl // ignore: cast_nullable_to_non_nullable
as String,authorBio: null == authorBio ? _self.authorBio : authorBio // ignore: cast_nullable_to_non_nullable
as String,authorLocation: null == authorLocation ? _self.authorLocation : authorLocation // ignore: cast_nullable_to_non_nullable
as String,authorTotalLikes: null == authorTotalLikes ? _self.authorTotalLikes : authorTotalLikes // ignore: cast_nullable_to_non_nullable
as int,authorTotalPhotos: null == authorTotalPhotos ? _self.authorTotalPhotos : authorTotalPhotos // ignore: cast_nullable_to_non_nullable
as int,authorIsForHire: null == authorIsForHire ? _self.authorIsForHire : authorIsForHire // ignore: cast_nullable_to_non_nullable
as bool,
));
}
}
// dart format on

View file

@ -0,0 +1,28 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:kuwot/features/quote/data/models/photo_list_model.dart';
part 'background_photos.freezed.dart';
@freezed
abstract class BackgroundPhotos with _$BackgroundPhotos {
const factory BackgroundPhotos({required List<Photo> photos}) =
_BackgroundPhotos;
static BackgroundPhotos fromModel(PhotoListModel model) => BackgroundPhotos(
photos: model.photos.map<Photo>((e) {
return Photo(
url: buildPortraitImageUrl(e.src.original),
avgColor: e.avgColor,
);
}).toList(),
);
static String buildPortraitImageUrl(String originalUrl) =>
'$originalUrl?auto=compress&cs=tinysrgb&fit=crop&h=2400&w=1200';
}
@freezed
abstract class Photo with _$Photo {
const factory Photo({required String url, required String avgColor}) =
_BackgroundImage;
}

View file

@ -0,0 +1,537 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'background_photos.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$BackgroundPhotos {
List<Photo> get photos;
/// Create a copy of BackgroundPhotos
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$BackgroundPhotosCopyWith<BackgroundPhotos> get copyWith => _$BackgroundPhotosCopyWithImpl<BackgroundPhotos>(this as BackgroundPhotos, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is BackgroundPhotos&&const DeepCollectionEquality().equals(other.photos, photos));
}
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(photos));
@override
String toString() {
return 'BackgroundPhotos(photos: $photos)';
}
}
/// @nodoc
abstract mixin class $BackgroundPhotosCopyWith<$Res> {
factory $BackgroundPhotosCopyWith(BackgroundPhotos value, $Res Function(BackgroundPhotos) _then) = _$BackgroundPhotosCopyWithImpl;
@useResult
$Res call({
List<Photo> photos
});
}
/// @nodoc
class _$BackgroundPhotosCopyWithImpl<$Res>
implements $BackgroundPhotosCopyWith<$Res> {
_$BackgroundPhotosCopyWithImpl(this._self, this._then);
final BackgroundPhotos _self;
final $Res Function(BackgroundPhotos) _then;
/// Create a copy of BackgroundPhotos
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? photos = null,}) {
return _then(_self.copyWith(
photos: null == photos ? _self.photos : photos // ignore: cast_nullable_to_non_nullable
as List<Photo>,
));
}
}
/// Adds pattern-matching-related methods to [BackgroundPhotos].
extension BackgroundPhotosPatterns on BackgroundPhotos {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BackgroundPhotos value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _BackgroundPhotos() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BackgroundPhotos value) $default,){
final _that = this;
switch (_that) {
case _BackgroundPhotos():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BackgroundPhotos value)? $default,){
final _that = this;
switch (_that) {
case _BackgroundPhotos() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( List<Photo> photos)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _BackgroundPhotos() when $default != null:
return $default(_that.photos);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( List<Photo> photos) $default,) {final _that = this;
switch (_that) {
case _BackgroundPhotos():
return $default(_that.photos);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( List<Photo> photos)? $default,) {final _that = this;
switch (_that) {
case _BackgroundPhotos() when $default != null:
return $default(_that.photos);case _:
return null;
}
}
}
/// @nodoc
class _BackgroundPhotos implements BackgroundPhotos {
const _BackgroundPhotos({required final List<Photo> photos}): _photos = photos;
final List<Photo> _photos;
@override List<Photo> get photos {
if (_photos is EqualUnmodifiableListView) return _photos;
// ignore: implicit_dynamic_type
return EqualUnmodifiableListView(_photos);
}
/// Create a copy of BackgroundPhotos
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$BackgroundPhotosCopyWith<_BackgroundPhotos> get copyWith => __$BackgroundPhotosCopyWithImpl<_BackgroundPhotos>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BackgroundPhotos&&const DeepCollectionEquality().equals(other._photos, _photos));
}
@override
int get hashCode => Object.hash(runtimeType,const DeepCollectionEquality().hash(_photos));
@override
String toString() {
return 'BackgroundPhotos(photos: $photos)';
}
}
/// @nodoc
abstract mixin class _$BackgroundPhotosCopyWith<$Res> implements $BackgroundPhotosCopyWith<$Res> {
factory _$BackgroundPhotosCopyWith(_BackgroundPhotos value, $Res Function(_BackgroundPhotos) _then) = __$BackgroundPhotosCopyWithImpl;
@override @useResult
$Res call({
List<Photo> photos
});
}
/// @nodoc
class __$BackgroundPhotosCopyWithImpl<$Res>
implements _$BackgroundPhotosCopyWith<$Res> {
__$BackgroundPhotosCopyWithImpl(this._self, this._then);
final _BackgroundPhotos _self;
final $Res Function(_BackgroundPhotos) _then;
/// Create a copy of BackgroundPhotos
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? photos = null,}) {
return _then(_BackgroundPhotos(
photos: null == photos ? _self._photos : photos // ignore: cast_nullable_to_non_nullable
as List<Photo>,
));
}
}
/// @nodoc
mixin _$Photo {
String get url; String get avgColor;
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$PhotoCopyWith<Photo> get copyWith => _$PhotoCopyWithImpl<Photo>(this as Photo, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Photo&&(identical(other.url, url) || other.url == url)&&(identical(other.avgColor, avgColor) || other.avgColor == avgColor));
}
@override
int get hashCode => Object.hash(runtimeType,url,avgColor);
@override
String toString() {
return 'Photo(url: $url, avgColor: $avgColor)';
}
}
/// @nodoc
abstract mixin class $PhotoCopyWith<$Res> {
factory $PhotoCopyWith(Photo value, $Res Function(Photo) _then) = _$PhotoCopyWithImpl;
@useResult
$Res call({
String url, String avgColor
});
}
/// @nodoc
class _$PhotoCopyWithImpl<$Res>
implements $PhotoCopyWith<$Res> {
_$PhotoCopyWithImpl(this._self, this._then);
final Photo _self;
final $Res Function(Photo) _then;
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? url = null,Object? avgColor = null,}) {
return _then(_self.copyWith(
url: null == url ? _self.url : url // ignore: cast_nullable_to_non_nullable
as String,avgColor: null == avgColor ? _self.avgColor : avgColor // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [Photo].
extension PhotoPatterns on Photo {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _BackgroundImage value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _BackgroundImage value) $default,){
final _that = this;
switch (_that) {
case _BackgroundImage():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _BackgroundImage value)? $default,){
final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String url, String avgColor)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that.url,_that.avgColor);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String url, String avgColor) $default,) {final _that = this;
switch (_that) {
case _BackgroundImage():
return $default(_that.url,_that.avgColor);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String url, String avgColor)? $default,) {final _that = this;
switch (_that) {
case _BackgroundImage() when $default != null:
return $default(_that.url,_that.avgColor);case _:
return null;
}
}
}
/// @nodoc
class _BackgroundImage implements Photo {
const _BackgroundImage({required this.url, required this.avgColor});
@override final String url;
@override final String avgColor;
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$BackgroundImageCopyWith<_BackgroundImage> get copyWith => __$BackgroundImageCopyWithImpl<_BackgroundImage>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _BackgroundImage&&(identical(other.url, url) || other.url == url)&&(identical(other.avgColor, avgColor) || other.avgColor == avgColor));
}
@override
int get hashCode => Object.hash(runtimeType,url,avgColor);
@override
String toString() {
return 'Photo(url: $url, avgColor: $avgColor)';
}
}
/// @nodoc
abstract mixin class _$BackgroundImageCopyWith<$Res> implements $PhotoCopyWith<$Res> {
factory _$BackgroundImageCopyWith(_BackgroundImage value, $Res Function(_BackgroundImage) _then) = __$BackgroundImageCopyWithImpl;
@override @useResult
$Res call({
String url, String avgColor
});
}
/// @nodoc
class __$BackgroundImageCopyWithImpl<$Res>
implements _$BackgroundImageCopyWith<$Res> {
__$BackgroundImageCopyWithImpl(this._self, this._then);
final _BackgroundImage _self;
final $Res Function(_BackgroundImage) _then;
/// Create a copy of Photo
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? url = null,Object? avgColor = null,}) {
return _then(_BackgroundImage(
url: null == url ? _self.url : url // ignore: cast_nullable_to_non_nullable
as String,avgColor: null == avgColor ? _self.avgColor : avgColor // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View file

@ -0,0 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:kuwot/features/quote/data/models/quote_model.dart';
part 'quote.freezed.dart';
@freezed
abstract class Quote with _$Quote {
const factory Quote({
required int id,
required String author,
required String body,
}) = _Quote;
static Quote fromModel(QuoteModel model) =>
Quote(id: model.id, author: model.author, body: model.text);
}

View file

@ -0,0 +1,277 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'quote.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$Quote {
int get id; String get author; String get body;
/// Create a copy of Quote
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$QuoteCopyWith<Quote> get copyWith => _$QuoteCopyWithImpl<Quote>(this as Quote, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Quote&&(identical(other.id, id) || other.id == id)&&(identical(other.author, author) || other.author == author)&&(identical(other.body, body) || other.body == body));
}
@override
int get hashCode => Object.hash(runtimeType,id,author,body);
@override
String toString() {
return 'Quote(id: $id, author: $author, body: $body)';
}
}
/// @nodoc
abstract mixin class $QuoteCopyWith<$Res> {
factory $QuoteCopyWith(Quote value, $Res Function(Quote) _then) = _$QuoteCopyWithImpl;
@useResult
$Res call({
int id, String author, String body
});
}
/// @nodoc
class _$QuoteCopyWithImpl<$Res>
implements $QuoteCopyWith<$Res> {
_$QuoteCopyWithImpl(this._self, this._then);
final Quote _self;
final $Res Function(Quote) _then;
/// Create a copy of Quote
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? author = null,Object? body = null,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as int,author: null == author ? _self.author : author // ignore: cast_nullable_to_non_nullable
as String,body: null == body ? _self.body : body // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [Quote].
extension QuotePatterns on Quote {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _Quote value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Quote() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _Quote value) $default,){
final _that = this;
switch (_that) {
case _Quote():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _Quote value)? $default,){
final _that = this;
switch (_that) {
case _Quote() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( int id, String author, String body)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Quote() when $default != null:
return $default(_that.id,_that.author,_that.body);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( int id, String author, String body) $default,) {final _that = this;
switch (_that) {
case _Quote():
return $default(_that.id,_that.author,_that.body);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( int id, String author, String body)? $default,) {final _that = this;
switch (_that) {
case _Quote() when $default != null:
return $default(_that.id,_that.author,_that.body);case _:
return null;
}
}
}
/// @nodoc
class _Quote implements Quote {
const _Quote({required this.id, required this.author, required this.body});
@override final int id;
@override final String author;
@override final String body;
/// Create a copy of Quote
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$QuoteCopyWith<_Quote> get copyWith => __$QuoteCopyWithImpl<_Quote>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Quote&&(identical(other.id, id) || other.id == id)&&(identical(other.author, author) || other.author == author)&&(identical(other.body, body) || other.body == body));
}
@override
int get hashCode => Object.hash(runtimeType,id,author,body);
@override
String toString() {
return 'Quote(id: $id, author: $author, body: $body)';
}
}
/// @nodoc
abstract mixin class _$QuoteCopyWith<$Res> implements $QuoteCopyWith<$Res> {
factory _$QuoteCopyWith(_Quote value, $Res Function(_Quote) _then) = __$QuoteCopyWithImpl;
@override @useResult
$Res call({
int id, String author, String body
});
}
/// @nodoc
class __$QuoteCopyWithImpl<$Res>
implements _$QuoteCopyWith<$Res> {
__$QuoteCopyWithImpl(this._self, this._then);
final _Quote _self;
final $Res Function(_Quote) _then;
/// Create a copy of Quote
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? author = null,Object? body = null,}) {
return _then(_Quote(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as int,author: null == author ? _self.author : author // ignore: cast_nullable_to_non_nullable
as String,body: null == body ? _self.body : body // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View file

@ -0,0 +1,14 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:kuwot/features/quote/data/models/translation_model.dart';
part 'translation.freezed.dart';
@freezed
abstract class Translation with _$Translation {
const factory Translation({required String id, required String language}) =
_Translation;
static Translation fromModel(TranslationModel model) {
return Translation(id: model.id, language: model.lang);
}
}

View file

@ -0,0 +1,274 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
// coverage:ignore-file
// 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 'translation.dart';
// **************************************************************************
// FreezedGenerator
// **************************************************************************
// dart format off
T _$identity<T>(T value) => value;
/// @nodoc
mixin _$Translation {
String get id; String get language;
/// Create a copy of Translation
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
$TranslationCopyWith<Translation> get copyWith => _$TranslationCopyWithImpl<Translation>(this as Translation, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is Translation&&(identical(other.id, id) || other.id == id)&&(identical(other.language, language) || other.language == language));
}
@override
int get hashCode => Object.hash(runtimeType,id,language);
@override
String toString() {
return 'Translation(id: $id, language: $language)';
}
}
/// @nodoc
abstract mixin class $TranslationCopyWith<$Res> {
factory $TranslationCopyWith(Translation value, $Res Function(Translation) _then) = _$TranslationCopyWithImpl;
@useResult
$Res call({
String id, String language
});
}
/// @nodoc
class _$TranslationCopyWithImpl<$Res>
implements $TranslationCopyWith<$Res> {
_$TranslationCopyWithImpl(this._self, this._then);
final Translation _self;
final $Res Function(Translation) _then;
/// Create a copy of Translation
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? id = null,Object? language = null,}) {
return _then(_self.copyWith(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
/// Adds pattern-matching-related methods to [Translation].
extension TranslationPatterns on Translation {
/// A variant of `map` that fallback to returning `orElse`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeMap<TResult extends Object?>(TResult Function( _Translation value)? $default,{required TResult orElse(),}){
final _that = this;
switch (_that) {
case _Translation() when $default != null:
return $default(_that);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// Callbacks receives the raw object, upcasted.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case final Subclass2 value:
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult map<TResult extends Object?>(TResult Function( _Translation value) $default,){
final _that = this;
switch (_that) {
case _Translation():
return $default(_that);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `map` that fallback to returning `null`.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case final Subclass value:
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? mapOrNull<TResult extends Object?>(TResult? Function( _Translation value)? $default,){
final _that = this;
switch (_that) {
case _Translation() when $default != null:
return $default(_that);case _:
return null;
}
}
/// A variant of `when` that fallback to an `orElse` callback.
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return orElse();
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function( String id, String language)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Translation() when $default != null:
return $default(_that.id,_that.language);case _:
return orElse();
}
}
/// A `switch`-like method, using callbacks.
///
/// As opposed to `map`, this offers destructuring.
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case Subclass2(:final field2):
/// return ...;
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function( String id, String language) $default,) {final _that = this;
switch (_that) {
case _Translation():
return $default(_that.id,_that.language);case _:
throw StateError('Unexpected subclass');
}
}
/// A variant of `when` that fallback to returning `null`
///
/// It is equivalent to doing:
/// ```dart
/// switch (sealedClass) {
/// case Subclass(:final field):
/// return ...;
/// case _:
/// return null;
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function( String id, String language)? $default,) {final _that = this;
switch (_that) {
case _Translation() when $default != null:
return $default(_that.id,_that.language);case _:
return null;
}
}
}
/// @nodoc
class _Translation implements Translation {
const _Translation({required this.id, required this.language});
@override final String id;
@override final String language;
/// Create a copy of Translation
/// with the given fields replaced by the non-null parameter values.
@override @JsonKey(includeFromJson: false, includeToJson: false)
@pragma('vm:prefer-inline')
_$TranslationCopyWith<_Translation> get copyWith => __$TranslationCopyWithImpl<_Translation>(this, _$identity);
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Translation&&(identical(other.id, id) || other.id == id)&&(identical(other.language, language) || other.language == language));
}
@override
int get hashCode => Object.hash(runtimeType,id,language);
@override
String toString() {
return 'Translation(id: $id, language: $language)';
}
}
/// @nodoc
abstract mixin class _$TranslationCopyWith<$Res> implements $TranslationCopyWith<$Res> {
factory _$TranslationCopyWith(_Translation value, $Res Function(_Translation) _then) = __$TranslationCopyWithImpl;
@override @useResult
$Res call({
String id, String language
});
}
/// @nodoc
class __$TranslationCopyWithImpl<$Res>
implements _$TranslationCopyWith<$Res> {
__$TranslationCopyWithImpl(this._self, this._then);
final _Translation _self;
final $Res Function(_Translation) _then;
/// Create a copy of Translation
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? id = null,Object? language = null,}) {
return _then(_Translation(
id: null == id ? _self.id : id // ignore: cast_nullable_to_non_nullable
as String,language: null == language ? _self.language : language // ignore: cast_nullable_to_non_nullable
as String,
));
}
}
// dart format on

View file

@ -0,0 +1,19 @@
import 'package:fpdart/fpdart.dart';
import 'package:kuwot/core/data/local/translation_target_config.dart';
import 'package:kuwot/core/error/failure.dart';
import 'package:kuwot/features/quote/domain/entities/background_image.dart';
import 'package:kuwot/features/quote/domain/entities/quote.dart';
import 'package:kuwot/features/quote/domain/entities/translation.dart';
abstract class QuoteRepository {
Future<Either<Failure, List<BackgroundImage>>> getBackgroundImages();
Future<Either<Failure, Quote>> getQuote(TranslationTarget? translationTarget);
Future<Either<Failure, Quote>> getTranslatedQuote(
int id,
TranslationTarget translationTarget,
);
Future<Either<Failure, List<Translation>>> getTranslations();
}

View file

@ -0,0 +1,17 @@
import 'package:fpdart/fpdart.dart';
import 'package:kuwot/core/domain/no_params.dart';
import 'package:kuwot/core/domain/use_case.dart';
import 'package:kuwot/core/error/failure.dart';
import 'package:kuwot/features/quote/domain/entities/background_image.dart';
import 'package:kuwot/features/quote/domain/repositories/quote_repository.dart';
class GetBackgroundImages extends UseCase<List<BackgroundImage>, NoParams> {
final QuoteRepository _repository;
GetBackgroundImages(QuoteRepository repository) : _repository = repository;
@override
Future<Either<Failure, List<BackgroundImage>>> call(NoParams params) async {
return await _repository.getBackgroundImages();
}
}

View file

@ -0,0 +1,27 @@
import 'package:equatable/equatable.dart';
import 'package:fpdart/fpdart.dart';
import 'package:kuwot/core/data/local/translation_target_config.dart';
import 'package:kuwot/core/domain/use_case.dart';
import 'package:kuwot/core/error/failure.dart';
import 'package:kuwot/features/quote/domain/entities/quote.dart';
import 'package:kuwot/features/quote/domain/repositories/quote_repository.dart';
class GetQuote extends UseCase<Quote, GetQuoteParams> {
final QuoteRepository _repository;
GetQuote(QuoteRepository repository) : _repository = repository;
@override
Future<Either<Failure, Quote>> call(GetQuoteParams params) {
return _repository.getQuote(params.translationTarget);
}
}
class GetQuoteParams extends Equatable {
final TranslationTarget? translationTarget;
const GetQuoteParams(this.translationTarget);
@override
List<Object?> get props => [translationTarget];
}

View file

@ -0,0 +1,34 @@
import 'package:equatable/equatable.dart';
import 'package:fpdart/fpdart.dart';
import 'package:kuwot/core/data/local/translation_target_config.dart';
import 'package:kuwot/core/domain/use_case.dart';
import 'package:kuwot/core/error/failure.dart';
import 'package:kuwot/features/quote/domain/entities/quote.dart';
import 'package:kuwot/features/quote/domain/repositories/quote_repository.dart';
class GetTranslatedQuote extends UseCase<Quote, GetTranslatedQuoteParams> {
final QuoteRepository _repository;
GetTranslatedQuote(QuoteRepository repository) : _repository = repository;
@override
Future<Either<Failure, Quote>> call(GetTranslatedQuoteParams params) async {
return await _repository.getTranslatedQuote(
params.id,
params.translationTarget,
);
}
}
class GetTranslatedQuoteParams extends Equatable {
final int id;
final TranslationTarget translationTarget;
const GetTranslatedQuoteParams({
required this.id,
required this.translationTarget,
});
@override
List<Object?> get props => [id, translationTarget];
}

View file

@ -0,0 +1,17 @@
import 'package:fpdart/fpdart.dart';
import 'package:kuwot/core/domain/no_params.dart';
import 'package:kuwot/core/domain/use_case.dart';
import 'package:kuwot/core/error/failure.dart';
import 'package:kuwot/features/quote/domain/entities/translation.dart';
import 'package:kuwot/features/quote/domain/repositories/quote_repository.dart';
class GetTranslations extends UseCase<List<Translation>, NoParams> {
final QuoteRepository _repository;
GetTranslations(QuoteRepository repository) : _repository = repository;
@override
Future<Either<Failure, List<Translation>>> call(NoParams params) {
return _repository.getTranslations();
}
}