chore: Format code
This commit is contained in:
@@ -2085,7 +2085,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''',
|
|||||||
homepage: 'https://github.com/fluttercommunity/get_it',
|
homepage: 'https://github.com/fluttercommunity/get_it',
|
||||||
authors: [
|
authors: [
|
||||||
'Flutter Community <community@flutter.zone>',
|
'Flutter Community <community@flutter.zone>',
|
||||||
'Thomas Burkhart <burkhartsengineering@gmail.com>'
|
'Thomas Burkhart <burkhartsengineering@gmail.com>',
|
||||||
],
|
],
|
||||||
version: '7.2.0',
|
version: '7.2.0',
|
||||||
license: '''MIT License
|
license: '''MIT License
|
||||||
|
|||||||
@@ -123,7 +123,10 @@ class DatabaseService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<AnimeTrackingData> incrementAnimeWatchCounter(AnimeTrackingData data, int value) async {
|
Future<AnimeTrackingData> incrementAnimeWatchCounter(
|
||||||
|
AnimeTrackingData data,
|
||||||
|
int value,
|
||||||
|
) async {
|
||||||
final result = await _db.rawQuery(
|
final result = await _db.rawQuery(
|
||||||
'UPDATE $animeTable SET episodesWatched = episodesWatched + $value WHERE id = ? RETURNING *',
|
'UPDATE $animeTable SET episodesWatched = episodesWatched + $value WHERE id = ? RETURNING *',
|
||||||
[
|
[
|
||||||
@@ -171,7 +174,10 @@ class DatabaseService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<MangaTrackingData> incrementMangaReadChapters(MangaTrackingData data, int value) async {
|
Future<MangaTrackingData> incrementMangaReadChapters(
|
||||||
|
MangaTrackingData data,
|
||||||
|
int value,
|
||||||
|
) async {
|
||||||
final result = await _db.rawQuery(
|
final result = await _db.rawQuery(
|
||||||
'UPDATE $mangaTable SET episodesWatched = chaptersRead + $value WHERE id = ? RETURNING *',
|
'UPDATE $mangaTable SET episodesWatched = chaptersRead + $value WHERE id = ? RETURNING *',
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Internal anime state
|
/// Internal anime state
|
||||||
final List<AnimeTrackingData> _animes =
|
final List<AnimeTrackingData> _animes = List<AnimeTrackingData>.empty(
|
||||||
List<AnimeTrackingData>.empty(growable: true);
|
growable: true,
|
||||||
final List<MangaTrackingData> _mangas =
|
);
|
||||||
List<MangaTrackingData>.empty(growable: true);
|
final List<MangaTrackingData> _mangas = List<MangaTrackingData>.empty(
|
||||||
|
growable: true,
|
||||||
|
);
|
||||||
|
|
||||||
List<AnimeTrackingData> get unfilteredAnime => _animes;
|
List<AnimeTrackingData> get unfilteredAnime => _animes;
|
||||||
|
|
||||||
@@ -120,9 +122,12 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
|
|||||||
|
|
||||||
final anime = state.animes[index];
|
final anime = state.animes[index];
|
||||||
if (anime.episodesTotal != null &&
|
if (anime.episodesTotal != null &&
|
||||||
anime.episodesWatched + 1 > anime.episodesTotal!) return;
|
anime.episodesWatched + 1 > anime.episodesTotal!)
|
||||||
|
return;
|
||||||
|
|
||||||
final newAnime = await GetIt.I.get<DatabaseService>().incrementAnimeWatchCounter(anime, 1);
|
final newAnime = await GetIt.I
|
||||||
|
.get<DatabaseService>()
|
||||||
|
.incrementAnimeWatchCounter(anime, 1);
|
||||||
final newList = List<AnimeTrackingData>.from(state.animes);
|
final newList = List<AnimeTrackingData>.from(state.animes);
|
||||||
newList[index] = newAnime;
|
newList[index] = newAnime;
|
||||||
emit(
|
emit(
|
||||||
@@ -142,8 +147,9 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
|
|||||||
final anime = state.animes[index];
|
final anime = state.animes[index];
|
||||||
if (anime.episodesWatched - 1 < 0) return;
|
if (anime.episodesWatched - 1 < 0) return;
|
||||||
|
|
||||||
|
final newAnime = await GetIt.I
|
||||||
final newAnime = await GetIt.I.get<DatabaseService>().incrementAnimeWatchCounter(anime, -1);
|
.get<DatabaseService>()
|
||||||
|
.incrementAnimeWatchCounter(anime, -1);
|
||||||
final newList = List<AnimeTrackingData>.from(state.animes);
|
final newList = List<AnimeTrackingData>.from(state.animes);
|
||||||
newList[index] = newAnime;
|
newList[index] = newAnime;
|
||||||
emit(
|
emit(
|
||||||
@@ -217,9 +223,12 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
|
|||||||
|
|
||||||
final manga = state.mangas[index];
|
final manga = state.mangas[index];
|
||||||
if (manga.chaptersTotal != null &&
|
if (manga.chaptersTotal != null &&
|
||||||
manga.chaptersRead + 1 > manga.chaptersTotal!) return;
|
manga.chaptersRead + 1 > manga.chaptersTotal!)
|
||||||
|
return;
|
||||||
|
|
||||||
final newManga = await GetIt.I.get<DatabaseService>().incrementMangaReadChapters(manga, 1);
|
final newManga = await GetIt.I
|
||||||
|
.get<DatabaseService>()
|
||||||
|
.incrementMangaReadChapters(manga, 1);
|
||||||
final newList = List<MangaTrackingData>.from(state.mangas);
|
final newList = List<MangaTrackingData>.from(state.mangas);
|
||||||
newList[index] = newManga;
|
newList[index] = newManga;
|
||||||
emit(
|
emit(
|
||||||
@@ -244,7 +253,9 @@ class AnimeListBloc extends Bloc<AnimeListEvent, AnimeListState> {
|
|||||||
final manga = state.mangas[index];
|
final manga = state.mangas[index];
|
||||||
if (manga.chaptersRead - 1 < 0) return;
|
if (manga.chaptersRead - 1 < 0) return;
|
||||||
|
|
||||||
final newManga = await GetIt.I.get<DatabaseService>().incrementMangaReadChapters(manga, -1);
|
final newManga = await GetIt.I
|
||||||
|
.get<DatabaseService>()
|
||||||
|
.incrementMangaReadChapters(manga, -1);
|
||||||
final newList = List<MangaTrackingData>.from(state.mangas);
|
final newList = List<MangaTrackingData>.from(state.mangas);
|
||||||
newList[index] = newManga;
|
newList[index] = newManga;
|
||||||
emit(
|
emit(
|
||||||
|
|||||||
@@ -69,9 +69,9 @@ class DetailsBloc extends Bloc<DetailsEvent, DetailsState> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await GetIt.I
|
await GetIt.I.get<DatabaseService>().updateAnime(
|
||||||
.get<DatabaseService>()
|
event.data as AnimeTrackingData,
|
||||||
.updateAnime(event.data as AnimeTrackingData);
|
);
|
||||||
|
|
||||||
GetIt.I.get<AnimeListBloc>().add(
|
GetIt.I.get<AnimeListBloc>().add(
|
||||||
AnimeUpdatedEvent(event.data as AnimeTrackingData),
|
AnimeUpdatedEvent(event.data as AnimeTrackingData),
|
||||||
@@ -83,9 +83,9 @@ class DetailsBloc extends Bloc<DetailsEvent, DetailsState> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
await GetIt.I
|
await GetIt.I.get<DatabaseService>().updateManga(
|
||||||
.get<DatabaseService>()
|
event.data as MangaTrackingData,
|
||||||
.updateManga(event.data as MangaTrackingData);
|
);
|
||||||
|
|
||||||
GetIt.I.get<AnimeListBloc>().add(
|
GetIt.I.get<AnimeListBloc>().add(
|
||||||
MangaUpdatedEvent(event.data as MangaTrackingData),
|
MangaUpdatedEvent(event.data as MangaTrackingData),
|
||||||
|
|||||||
@@ -105,8 +105,9 @@ class SettingsBloc extends Bloc<SettingsEvent, SettingsState> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
final title = anime.getElement('series_title')!.text;
|
final title = anime.getElement('series_title')!.text;
|
||||||
final totalEpisodes =
|
final totalEpisodes = int.parse(
|
||||||
int.parse(anime.getElement('series_episodes')!.text);
|
anime.getElement('series_episodes')!.text,
|
||||||
|
);
|
||||||
final id = anime.getElement('series_animedb_id')!.text;
|
final id = anime.getElement('series_animedb_id')!.text;
|
||||||
|
|
||||||
print('Waiting 500ms to not hammer Jikan ($title)');
|
print('Waiting 500ms to not hammer Jikan ($title)');
|
||||||
|
|||||||
@@ -273,8 +273,9 @@ class AnimeListPageState extends State<AnimeListPage> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
bottomNavigationBar: BottomBar(
|
bottomNavigationBar: BottomBar(
|
||||||
selectedIndex:
|
selectedIndex: state.trackingType == TrackingMediumType.anime
|
||||||
state.trackingType == TrackingMediumType.anime ? 0 : 1,
|
? 0
|
||||||
|
: 1,
|
||||||
onTap: (int index) {
|
onTap: (int index) {
|
||||||
context.read<AnimeListBloc>().add(
|
context.read<AnimeListBloc>().add(
|
||||||
AnimeTrackingTypeChanged(
|
AnimeTrackingTypeChanged(
|
||||||
|
|||||||
@@ -183,9 +183,9 @@ class CalendarPageState extends State<CalendarPage> {
|
|||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
context
|
context.read<CalendarBloc>().add(
|
||||||
.read<CalendarBloc>()
|
RefreshPerformedEvent(),
|
||||||
.add(RefreshPerformedEvent());
|
);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.refresh),
|
icon: const Icon(Icons.refresh),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -157,7 +157,10 @@ class DetailsPage extends StatelessWidget {
|
|||||||
end: 8,
|
end: 8,
|
||||||
),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
t.details.details.titleJa,
|
t
|
||||||
|
.details
|
||||||
|
.details
|
||||||
|
.titleJa,
|
||||||
style:
|
style:
|
||||||
Theme.of(
|
Theme.of(
|
||||||
context,
|
context,
|
||||||
@@ -173,21 +176,32 @@ class DetailsPage extends StatelessWidget {
|
|||||||
end: 8,
|
end: 8,
|
||||||
),
|
),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize:
|
||||||
|
MainAxisSize
|
||||||
|
.min,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
await Clipboard.setData(
|
await Clipboard.setData(
|
||||||
ClipboardData(
|
ClipboardData(
|
||||||
text: state.data!.title,
|
text: state
|
||||||
|
.data!
|
||||||
|
.title,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.copy),
|
icon:
|
||||||
|
const Icon(
|
||||||
|
Icons
|
||||||
|
.copy,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsetsGeometry.only(left: 8),
|
padding:
|
||||||
|
const EdgeInsetsGeometry.only(
|
||||||
|
left: 8,
|
||||||
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
state
|
state
|
||||||
.data!
|
.data!
|
||||||
@@ -223,13 +237,17 @@ class DetailsPage extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
final url = switch (state.trackingType) {
|
final url = switch (state
|
||||||
TrackingMediumType.anime => 'https://myanimelist.net/anime/${state.data!.id}',
|
.trackingType) {
|
||||||
TrackingMediumType.manga => 'https://myanimelist.net/manga/${state.data!.id}',
|
TrackingMediumType.anime =>
|
||||||
|
'https://myanimelist.net/anime/${state.data!.id}',
|
||||||
|
TrackingMediumType.manga =>
|
||||||
|
'https://myanimelist.net/manga/${state.data!.id}',
|
||||||
};
|
};
|
||||||
await launchUrl(
|
await launchUrl(
|
||||||
Uri.parse(url),
|
Uri.parse(url),
|
||||||
mode: LaunchMode.externalApplication,
|
mode: LaunchMode
|
||||||
|
.externalApplication,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: Text(t.details.mal),
|
child: Text(t.details.mal),
|
||||||
|
|||||||
@@ -96,13 +96,14 @@ class SettingsPage extends StatelessWidget {
|
|||||||
title: Text(t.settings.exportData),
|
title: Text(t.settings.exportData),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// Pick the file
|
// Pick the file
|
||||||
final result =
|
final result = await FilePicker.platform
|
||||||
await FilePicker.platform.getDirectoryPath();
|
.getDirectoryPath();
|
||||||
if (result == null) return;
|
if (result == null) return;
|
||||||
|
|
||||||
if (!(await Permission.manageExternalStorage
|
if (!(await Permission.manageExternalStorage
|
||||||
.request())
|
.request())
|
||||||
.isGranted) return;
|
.isGranted)
|
||||||
|
return;
|
||||||
|
|
||||||
GetIt.I.get<SettingsBloc>().add(
|
GetIt.I.get<SettingsBloc>().add(
|
||||||
DataExportedEvent(
|
DataExportedEvent(
|
||||||
@@ -123,8 +124,9 @@ class SettingsPage extends StatelessWidget {
|
|||||||
context: context,
|
context: context,
|
||||||
builder: (_) => AlertDialog(
|
builder: (_) => AlertDialog(
|
||||||
title: Text(t.settings.importInvalidData.title),
|
title: Text(t.settings.importInvalidData.title),
|
||||||
content:
|
content: Text(
|
||||||
Text(t.settings.importInvalidData.content),
|
t.settings.importInvalidData.content,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ class DropdownSelectorState<T> extends State<DropdownSelector<T>> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
|
|
||||||
index =
|
index = widget.values.indexWhere(
|
||||||
widget.values.indexWhere((item) => item.value == widget.initialValue);
|
(item) => item.value == widget.initialValue,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -93,8 +94,9 @@ class DropdownSelectorState<T> extends State<DropdownSelector<T>> {
|
|||||||
if (result == widget.values[index].value) return;
|
if (result == widget.values[index].value) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
index =
|
index = widget.values.indexWhere(
|
||||||
widget.values.indexWhere((item) => item.value == result);
|
(item) => item.value == result,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
widget.onChanged(result);
|
widget.onChanged(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user