chore(all): Format
This commit is contained in:
@@ -9,11 +9,11 @@ class AboutPage extends StatelessWidget {
|
||||
});
|
||||
|
||||
static MaterialPageRoute<dynamic> get route => MaterialPageRoute<dynamic>(
|
||||
builder: (_) => const AboutPage(),
|
||||
settings: const RouteSettings(
|
||||
name: aboutRoute,
|
||||
),
|
||||
);
|
||||
builder: (_) => const AboutPage(),
|
||||
settings: const RouteSettings(
|
||||
name: aboutRoute,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -34,7 +34,6 @@ class AboutPage extends StatelessWidget {
|
||||
'AniTrack',
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
await launchUrl(
|
||||
|
||||
@@ -16,11 +16,11 @@ class AnimeListPage extends StatefulWidget {
|
||||
});
|
||||
|
||||
static MaterialPageRoute<dynamic> get route => MaterialPageRoute<dynamic>(
|
||||
builder: (_) => AnimeListPage(),
|
||||
settings: const RouteSettings(
|
||||
name: animeListRoute,
|
||||
),
|
||||
);
|
||||
builder: (_) => const AnimeListPage(),
|
||||
settings: const RouteSettings(
|
||||
name: animeListRoute,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
AnimeListPageState createState() => AnimeListPageState();
|
||||
@@ -35,11 +35,12 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
super.initState();
|
||||
_animeScrollController.addListener(_onAnimeListScrolled);
|
||||
}
|
||||
|
||||
|
||||
void _onAnimeListScrolled() {
|
||||
//print(_animeScrollController.position.maxScrollExtent);
|
||||
final bloc = GetIt.I.get<AnimeListBloc>();
|
||||
if (_animeScrollController.offset + 20 >= _animeScrollController.position.maxScrollExtent) {
|
||||
if (_animeScrollController.offset + 20 >=
|
||||
_animeScrollController.position.maxScrollExtent) {
|
||||
if (bloc.state.buttonVisibility) {
|
||||
bloc.add(
|
||||
AddButtonVisibilitySetEvent(false),
|
||||
@@ -53,15 +54,19 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String _getPageTitle(TrackingMediumType type) {
|
||||
switch (type) {
|
||||
case TrackingMediumType.anime: return 'Anime';
|
||||
case TrackingMediumType.manga: return 'Manga';
|
||||
case TrackingMediumType.anime:
|
||||
return 'Anime';
|
||||
case TrackingMediumType.manga:
|
||||
return 'Manga';
|
||||
}
|
||||
}
|
||||
|
||||
List<PopupMenuItem<MediumTrackingState>> _getPopupButtonItems(TrackingMediumType type) {
|
||||
List<PopupMenuItem<MediumTrackingState>> _getPopupButtonItems(
|
||||
TrackingMediumType type,
|
||||
) {
|
||||
return [
|
||||
PopupMenuItem<MediumTrackingState>(
|
||||
value: MediumTrackingState.ongoing,
|
||||
@@ -85,7 +90,7 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Widget _getPopupButton(BuildContext context, AnimeListState state) {
|
||||
switch (state.trackingType) {
|
||||
case TrackingMediumType.anime:
|
||||
@@ -96,8 +101,8 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
initialValue: state.animeFilterState,
|
||||
onSelected: (filterState) {
|
||||
context.read<AnimeListBloc>().add(
|
||||
AnimeFilterChangedEvent(filterState),
|
||||
);
|
||||
AnimeFilterChangedEvent(filterState),
|
||||
);
|
||||
},
|
||||
itemBuilder: (_) => _getPopupButtonItems(TrackingMediumType.anime),
|
||||
);
|
||||
@@ -109,14 +114,14 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
initialValue: state.mangaFilterState,
|
||||
onSelected: (filterState) {
|
||||
context.read<AnimeListBloc>().add(
|
||||
MangaFilterChangedEvent(filterState),
|
||||
);
|
||||
MangaFilterChangedEvent(filterState),
|
||||
);
|
||||
},
|
||||
itemBuilder: (_) => _getPopupButtonItems(TrackingMediumType.manga),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AnimeListBloc, AnimeListState>(
|
||||
@@ -145,7 +150,6 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
ListTile(
|
||||
leading: const Icon(Icons.info),
|
||||
title: const Text('About'),
|
||||
@@ -178,37 +182,37 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
return GridItem(
|
||||
minusCallback: () {
|
||||
context.read<AnimeListBloc>().add(
|
||||
AnimeEpisodeDecrementedEvent(
|
||||
anime.id,
|
||||
),
|
||||
);
|
||||
AnimeEpisodeDecrementedEvent(
|
||||
anime.id,
|
||||
),
|
||||
);
|
||||
},
|
||||
plusCallback: () {
|
||||
context.read<AnimeListBloc>().add(
|
||||
AnimeEpisodeIncrementedEvent(
|
||||
anime.id,
|
||||
),
|
||||
);
|
||||
AnimeEpisodeIncrementedEvent(
|
||||
anime.id,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: AnimeCoverImage(
|
||||
url: anime.thumbnailUrl,
|
||||
hero: anime.id,
|
||||
onTap: () {
|
||||
context.read<DetailsBloc>().add(
|
||||
AnimeDetailsRequestedEvent(anime),
|
||||
);
|
||||
},
|
||||
extra: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Text(
|
||||
'${anime.episodesWatched}/${anime.episodesTotal ?? "???"}',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
url: anime.thumbnailUrl,
|
||||
hero: anime.id,
|
||||
onTap: () {
|
||||
context.read<DetailsBloc>().add(
|
||||
AnimeDetailsRequestedEvent(anime),
|
||||
);
|
||||
},
|
||||
extra: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Text(
|
||||
'${anime.episodesWatched}/${anime.episodesTotal ?? "???"}',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -228,37 +232,37 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
return GridItem(
|
||||
minusCallback: () {
|
||||
context.read<AnimeListBloc>().add(
|
||||
MangaChapterDecrementedEvent(
|
||||
manga.id,
|
||||
),
|
||||
);
|
||||
MangaChapterDecrementedEvent(
|
||||
manga.id,
|
||||
),
|
||||
);
|
||||
},
|
||||
plusCallback: () {
|
||||
context.read<AnimeListBloc>().add(
|
||||
MangaChapterIncrementedEvent(
|
||||
manga.id,
|
||||
),
|
||||
);
|
||||
MangaChapterIncrementedEvent(
|
||||
manga.id,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: AnimeCoverImage(
|
||||
hero: manga.id,
|
||||
url: manga.thumbnailUrl,
|
||||
onTap: () {
|
||||
context.read<DetailsBloc>().add(
|
||||
MangaDetailsRequestedEvent(manga),
|
||||
);
|
||||
},
|
||||
extra: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Text(
|
||||
'${manga.chaptersRead}/${manga.chaptersTotal ?? "???"}',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
url: manga.thumbnailUrl,
|
||||
onTap: () {
|
||||
context.read<DetailsBloc>().add(
|
||||
MangaDetailsRequestedEvent(manga),
|
||||
);
|
||||
},
|
||||
extra: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: Text(
|
||||
'${manga.chaptersRead}/${manga.chaptersTotal ?? "???"}',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
@@ -266,19 +270,18 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
],
|
||||
),
|
||||
floatingActionButton: BlocBuilder<AnimeListBloc, AnimeListState>(
|
||||
buildWhen: (prev, next) => prev.buttonVisibility != next.buttonVisibility,
|
||||
buildWhen: (prev, next) =>
|
||||
prev.buttonVisibility != next.buttonVisibility,
|
||||
builder: (context, state) {
|
||||
return AnimatedScale(
|
||||
duration: const Duration(milliseconds: 250),
|
||||
scale: state.buttonVisibility ?
|
||||
1 :
|
||||
0,
|
||||
scale: state.buttonVisibility ? 1 : 0,
|
||||
curve: Curves.easeInOutQuint,
|
||||
child: FloatingActionButton(
|
||||
onPressed: () {
|
||||
context.read<AnimeSearchBloc>().add(
|
||||
AnimeSearchRequestedEvent(state.trackingType),
|
||||
);
|
||||
AnimeSearchRequestedEvent(state.trackingType),
|
||||
);
|
||||
},
|
||||
tooltip: 'Add new item',
|
||||
child: const Icon(Icons.add),
|
||||
@@ -287,17 +290,16 @@ class AnimeListPageState extends State<AnimeListPage> {
|
||||
},
|
||||
),
|
||||
bottomNavigationBar: BottomBar(
|
||||
selectedIndex: state.trackingType == TrackingMediumType.anime ?
|
||||
0 :
|
||||
1,
|
||||
selectedIndex:
|
||||
state.trackingType == TrackingMediumType.anime ? 0 : 1,
|
||||
onTap: (int index) {
|
||||
context.read<AnimeListBloc>().add(
|
||||
AnimeTrackingTypeChanged(
|
||||
index == 0 ?
|
||||
TrackingMediumType.anime :
|
||||
TrackingMediumType.manga,
|
||||
),
|
||||
);
|
||||
AnimeTrackingTypeChanged(
|
||||
index == 0
|
||||
? TrackingMediumType.anime
|
||||
: TrackingMediumType.manga,
|
||||
),
|
||||
);
|
||||
|
||||
_controller.jumpToPage(index);
|
||||
},
|
||||
|
||||
@@ -11,12 +11,12 @@ class AnimeSearchPage extends StatelessWidget {
|
||||
});
|
||||
|
||||
static MaterialPageRoute<dynamic> get route => MaterialPageRoute<dynamic>(
|
||||
builder: (_) => const AnimeSearchPage(),
|
||||
settings: const RouteSettings(
|
||||
name: animeSearchRoute,
|
||||
),
|
||||
);
|
||||
|
||||
builder: (_) => const AnimeSearchPage(),
|
||||
settings: const RouteSettings(
|
||||
name: animeSearchRoute,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<AnimeSearchBloc, AnimeSearchState>(
|
||||
@@ -24,9 +24,9 @@ class AnimeSearchPage extends StatelessWidget {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(
|
||||
state.trackingType == TrackingMediumType.anime ?
|
||||
'Anime Search' :
|
||||
'Manga Search',
|
||||
state.trackingType == TrackingMediumType.anime
|
||||
? 'Anime Search'
|
||||
: 'Manga Search',
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
@@ -40,17 +40,16 @@ class AnimeSearchPage extends StatelessWidget {
|
||||
),
|
||||
onSubmitted: (_) {
|
||||
context.read<AnimeSearchBloc>().add(
|
||||
SearchQuerySubmittedEvent(),
|
||||
);
|
||||
SearchQuerySubmittedEvent(),
|
||||
);
|
||||
},
|
||||
onChanged: (value) {
|
||||
context.read<AnimeSearchBloc>().add(
|
||||
SearchQueryChangedEvent(value),
|
||||
);
|
||||
SearchQueryChangedEvent(value),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
||||
if (state.working)
|
||||
const Expanded(
|
||||
child: Align(
|
||||
@@ -66,8 +65,8 @@ class AnimeSearchPage extends StatelessWidget {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
context.read<AnimeSearchBloc>().add(
|
||||
ResultTappedEvent(item),
|
||||
);
|
||||
ResultTappedEvent(item),
|
||||
);
|
||||
},
|
||||
child: ListItem(
|
||||
title: item.title,
|
||||
|
||||
@@ -16,11 +16,11 @@ class DetailsPage extends StatelessWidget {
|
||||
});
|
||||
|
||||
static MaterialPageRoute<dynamic> get route => MaterialPageRoute<dynamic>(
|
||||
builder: (_) => const DetailsPage(),
|
||||
settings: const RouteSettings(
|
||||
name: detailsRoute,
|
||||
),
|
||||
);
|
||||
builder: (_) => const DetailsPage(),
|
||||
settings: const RouteSettings(
|
||||
name: detailsRoute,
|
||||
),
|
||||
);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -30,195 +30,213 @@ class DetailsPage extends StatelessWidget {
|
||||
),
|
||||
body: BlocBuilder<DetailsBloc, DetailsState>(
|
||||
builder: (context, state) {
|
||||
return state.data == null ?
|
||||
Container() :
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: ListView(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [AnimeCoverImage(
|
||||
url: state.data!.thumbnailUrl,
|
||||
hero: state.data!.id,
|
||||
),
|
||||
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 8,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
state.data!.title,
|
||||
textAlign: TextAlign.left,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
maxLines: 2,
|
||||
softWrap: true,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('Remove "${state.data!.title}"?'),
|
||||
content: Text('Are you sure you want to remove "${state.data!.title}" from the list?'),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(true);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Colors.red,
|
||||
),
|
||||
child: const Text('Remove'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(false);
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (result != true) return;
|
||||
|
||||
// ignore: use_build_context_synchronously
|
||||
context.read<DetailsBloc>().add(
|
||||
ItemRemovedEvent(
|
||||
state.data!.id,
|
||||
state.trackingType,
|
||||
return state.data == null
|
||||
? Container()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: ListView(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
AnimeCoverImage(
|
||||
url: state.data!.thumbnailUrl,
|
||||
hero: state.data!.id,
|
||||
),
|
||||
Expanded(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 8,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
state.data!.title,
|
||||
textAlign: TextAlign.left,
|
||||
style:
|
||||
Theme.of(context).textTheme.titleLarge,
|
||||
maxLines: 2,
|
||||
softWrap: true,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Icon(Icons.delete),
|
||||
ElevatedButton(
|
||||
onPressed: () async {
|
||||
final result = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text(
|
||||
'Remove "${state.data!.title}"?',
|
||||
),
|
||||
content: Text(
|
||||
'Are you sure you want to remove "${state.data!.title}" from the list?',
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(true);
|
||||
},
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor: Colors.red,
|
||||
),
|
||||
child: const Text('Remove'),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context)
|
||||
.pop(false);
|
||||
},
|
||||
child: const Text('Cancel'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (result != true) return;
|
||||
|
||||
// ignore: use_build_context_synchronously
|
||||
context.read<DetailsBloc>().add(
|
||||
ItemRemovedEvent(
|
||||
state.data!.id,
|
||||
state.trackingType,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Icon(Icons.delete),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
child: DropdownSelector<MediumTrackingState>(
|
||||
title: state.trackingType == TrackingMediumType.anime
|
||||
? 'Watch state'
|
||||
: 'Read state',
|
||||
onChanged: (MediumTrackingState newState) {
|
||||
if (state.trackingType ==
|
||||
TrackingMediumType.anime) {
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
(state.data! as AnimeTrackingData)
|
||||
.copyWith(
|
||||
state: newState,
|
||||
),
|
||||
),
|
||||
);
|
||||
} else if (state.trackingType ==
|
||||
TrackingMediumType.manga) {
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
(state.data! as MangaTrackingData)
|
||||
.copyWith(
|
||||
state: newState,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
values: [
|
||||
SelectorItem(
|
||||
MediumTrackingState.ongoing,
|
||||
MediumTrackingState.ongoing
|
||||
.toNameString(state.trackingType),
|
||||
),
|
||||
SelectorItem(
|
||||
MediumTrackingState.completed,
|
||||
MediumTrackingState.completed
|
||||
.toNameString(state.trackingType),
|
||||
),
|
||||
SelectorItem(
|
||||
MediumTrackingState.planned,
|
||||
MediumTrackingState.planned
|
||||
.toNameString(state.trackingType),
|
||||
),
|
||||
SelectorItem(
|
||||
MediumTrackingState.dropped,
|
||||
MediumTrackingState.dropped
|
||||
.toNameString(state.trackingType),
|
||||
),
|
||||
],
|
||||
initialValue: state.data!.state,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
child: DropdownSelector<MediumTrackingState>(
|
||||
title: state.trackingType == TrackingMediumType.anime ?
|
||||
'Watch state' :
|
||||
'Read state',
|
||||
onChanged: (MediumTrackingState newState) {
|
||||
if (state.trackingType == TrackingMediumType.anime) {
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
(state.data! as AnimeTrackingData).copyWith(
|
||||
state: newState,
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
child: IntegerInput(
|
||||
labelText:
|
||||
state.trackingType == TrackingMediumType.anime
|
||||
? 'Episodes'
|
||||
: 'Chapters',
|
||||
onChanged: (value) {
|
||||
switch (state.trackingType) {
|
||||
case TrackingMediumType.anime:
|
||||
final data = state.data! as AnimeTrackingData;
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
data.copyWith(
|
||||
episodesWatched: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
case TrackingMediumType.manga:
|
||||
final data = state.data! as MangaTrackingData;
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
data.copyWith(
|
||||
chaptersRead: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
initialValue: state.trackingType ==
|
||||
TrackingMediumType.anime
|
||||
? (state.data! as AnimeTrackingData)
|
||||
.episodesWatched
|
||||
: (state.data! as MangaTrackingData).chaptersRead,
|
||||
),
|
||||
),
|
||||
if (state.trackingType == TrackingMediumType.manga)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
);
|
||||
} else if (state.trackingType == TrackingMediumType.manga) {
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
(state.data! as MangaTrackingData).copyWith(
|
||||
state: newState,
|
||||
),
|
||||
child: IntegerInput(
|
||||
labelText: 'Volumes owned',
|
||||
onChanged: (value) {
|
||||
final data = state.data! as MangaTrackingData;
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
data.copyWith(
|
||||
volumesOwned: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
initialValue: (GetIt.I
|
||||
.get<DetailsBloc>()
|
||||
.state
|
||||
.data! as MangaTrackingData)
|
||||
.volumesOwned,
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
values: [
|
||||
SelectorItem(
|
||||
MediumTrackingState.ongoing,
|
||||
MediumTrackingState.ongoing.toNameString(state.trackingType),
|
||||
),
|
||||
SelectorItem(
|
||||
MediumTrackingState.completed,
|
||||
MediumTrackingState.completed.toNameString(state.trackingType),
|
||||
),
|
||||
SelectorItem(
|
||||
MediumTrackingState.planned,
|
||||
MediumTrackingState.planned.toNameString(state.trackingType),
|
||||
),
|
||||
SelectorItem(
|
||||
MediumTrackingState.dropped,
|
||||
MediumTrackingState.dropped.toNameString(state.trackingType),
|
||||
),
|
||||
),
|
||||
],
|
||||
initialValue: state.data!.state,
|
||||
),
|
||||
),
|
||||
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
child: IntegerInput(
|
||||
labelText: state.trackingType == TrackingMediumType.anime ?
|
||||
'Episodes' :
|
||||
'Chapters',
|
||||
onChanged: (value) {
|
||||
switch (state.trackingType) {
|
||||
case TrackingMediumType.anime:
|
||||
final data = state.data! as AnimeTrackingData;
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
data.copyWith(
|
||||
episodesWatched: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
case TrackingMediumType.manga:
|
||||
final data = state.data! as MangaTrackingData;
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
data.copyWith(
|
||||
chaptersRead: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
break;
|
||||
}
|
||||
},
|
||||
initialValue: state.trackingType == TrackingMediumType.anime ?
|
||||
(state.data! as AnimeTrackingData).episodesWatched :
|
||||
(state.data! as MangaTrackingData).chaptersRead,
|
||||
),
|
||||
),
|
||||
|
||||
if (state.trackingType == TrackingMediumType.manga)
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
vertical: 8,
|
||||
),
|
||||
child: IntegerInput(
|
||||
labelText: 'Volumes owned',
|
||||
onChanged: (value) {
|
||||
final data = state.data! as MangaTrackingData;
|
||||
context.read<DetailsBloc>().add(
|
||||
DetailsUpdatedEvent(
|
||||
data.copyWith(
|
||||
volumesOwned: value,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
initialValue: (GetIt.I.get<DetailsBloc>().state.data! as MangaTrackingData).volumesOwned,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user