fix(ui): Fix title overflow in details view
This commit is contained in:
parent
a436b60ce8
commit
b240870ebf
@ -6,7 +6,7 @@ part 'anime.g.dart';
|
||||
|
||||
/// Data about a tracked anime
|
||||
@freezed
|
||||
class AnimeTrackingData with _$AnimeTrackingData{
|
||||
class AnimeTrackingData with _$AnimeTrackingData, TrackingMedium {
|
||||
factory AnimeTrackingData(
|
||||
/// The ID of the anime
|
||||
String id,
|
||||
|
@ -6,7 +6,7 @@ part 'manga.g.dart';
|
||||
|
||||
/// Data about a tracked anime
|
||||
@freezed
|
||||
class MangaTrackingData with _$MangaTrackingData{
|
||||
class MangaTrackingData with _$MangaTrackingData, TrackingMedium {
|
||||
factory MangaTrackingData(
|
||||
/// The ID of the manga
|
||||
String id,
|
||||
|
@ -15,6 +15,18 @@ enum MediumTrackingState {
|
||||
all,
|
||||
}
|
||||
|
||||
/// Interface for the Anime and Manga data classes
|
||||
abstract class TrackingMedium {
|
||||
/// The title of the medium
|
||||
final String title = '';
|
||||
|
||||
/// The URL of the cover image.
|
||||
final String thumbnailUrl = '';
|
||||
|
||||
/// The tracking state
|
||||
final MediumTrackingState state = MediumTrackingState.planned;
|
||||
}
|
||||
|
||||
extension MediumStateExtension on MediumTrackingState {
|
||||
int toInteger() {
|
||||
assert(this != MediumTrackingState.all, 'MediumTrackingState.all must not be serialized');
|
||||
|
@ -16,7 +16,7 @@ final _privateConstructorUsedError = UnsupportedError(
|
||||
|
||||
/// @nodoc
|
||||
mixin _$DetailsState {
|
||||
dynamic get data => throw _privateConstructorUsedError;
|
||||
TrackingMedium? get data => throw _privateConstructorUsedError;
|
||||
TrackingMediumType get trackingType => throw _privateConstructorUsedError;
|
||||
|
||||
@JsonKey(ignore: true)
|
||||
@ -29,7 +29,7 @@ abstract class $DetailsStateCopyWith<$Res> {
|
||||
factory $DetailsStateCopyWith(
|
||||
DetailsState value, $Res Function(DetailsState) then) =
|
||||
_$DetailsStateCopyWithImpl<$Res>;
|
||||
$Res call({dynamic data, TrackingMediumType trackingType});
|
||||
$Res call({TrackingMedium? data, TrackingMediumType trackingType});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@ -49,7 +49,7 @@ class _$DetailsStateCopyWithImpl<$Res> implements $DetailsStateCopyWith<$Res> {
|
||||
data: data == freezed
|
||||
? _value.data
|
||||
: data // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
as TrackingMedium?,
|
||||
trackingType: trackingType == freezed
|
||||
? _value.trackingType
|
||||
: trackingType // ignore: cast_nullable_to_non_nullable
|
||||
@ -65,7 +65,7 @@ abstract class _$$_DetailsStateCopyWith<$Res>
|
||||
_$_DetailsState value, $Res Function(_$_DetailsState) then) =
|
||||
__$$_DetailsStateCopyWithImpl<$Res>;
|
||||
@override
|
||||
$Res call({dynamic data, TrackingMediumType trackingType});
|
||||
$Res call({TrackingMedium? data, TrackingMediumType trackingType});
|
||||
}
|
||||
|
||||
/// @nodoc
|
||||
@ -88,7 +88,7 @@ class __$$_DetailsStateCopyWithImpl<$Res>
|
||||
data: data == freezed
|
||||
? _value.data
|
||||
: data // ignore: cast_nullable_to_non_nullable
|
||||
as dynamic,
|
||||
as TrackingMedium?,
|
||||
trackingType: trackingType == freezed
|
||||
? _value.trackingType
|
||||
: trackingType // ignore: cast_nullable_to_non_nullable
|
||||
@ -103,7 +103,7 @@ class _$_DetailsState implements _DetailsState {
|
||||
_$_DetailsState({this.data, this.trackingType = TrackingMediumType.anime});
|
||||
|
||||
@override
|
||||
final dynamic data;
|
||||
final TrackingMedium? data;
|
||||
@override
|
||||
@JsonKey()
|
||||
final TrackingMediumType trackingType;
|
||||
@ -137,11 +137,11 @@ class _$_DetailsState implements _DetailsState {
|
||||
|
||||
abstract class _DetailsState implements DetailsState {
|
||||
factory _DetailsState(
|
||||
{final dynamic data,
|
||||
{final TrackingMedium? data,
|
||||
final TrackingMediumType trackingType}) = _$_DetailsState;
|
||||
|
||||
@override
|
||||
dynamic get data;
|
||||
TrackingMedium? get data;
|
||||
@override
|
||||
TrackingMediumType get trackingType;
|
||||
@override
|
||||
|
@ -3,7 +3,7 @@ part of 'details_bloc.dart';
|
||||
@freezed
|
||||
class DetailsState with _$DetailsState {
|
||||
factory DetailsState({
|
||||
dynamic data,
|
||||
TrackingMedium? data,
|
||||
@Default(TrackingMediumType.anime) TrackingMediumType trackingType,
|
||||
}) = _DetailsState;
|
||||
}
|
||||
|
@ -40,12 +40,11 @@ class DetailsPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AnimeCoverImage(
|
||||
url: state.trackingType == TrackingMediumType.anime ?
|
||||
(state.data as AnimeTrackingData).thumbnailUrl :
|
||||
(state.data as MangaTrackingData).thumbnailUrl,
|
||||
url: state.data!.thumbnailUrl,
|
||||
),
|
||||
|
||||
Padding(
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 8,
|
||||
),
|
||||
@ -54,9 +53,7 @@ class DetailsPage extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
state.trackingType == TrackingMediumType.anime ?
|
||||
(state.data as AnimeTrackingData).title :
|
||||
(state.data as MangaTrackingData).title,
|
||||
state.data!.title,
|
||||
textAlign: TextAlign.left,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
maxLines: 2,
|
||||
@ -66,6 +63,7 @@ class DetailsPage extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@ -114,9 +112,7 @@ class DetailsPage extends StatelessWidget {
|
||||
MediumTrackingState.dropped.toNameString(state.trackingType),
|
||||
),
|
||||
],
|
||||
initialValue: state.trackingType == TrackingMediumType.anime ?
|
||||
(state.data as AnimeTrackingData).state :
|
||||
(state.data as MangaTrackingData).state,
|
||||
initialValue: state.data!.state,
|
||||
),
|
||||
),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user