Skip to content

Commit

Permalink
V0.4.2 (Suwayomi#122)
Browse files Browse the repository at this point in the history
* updated Download screen UI

* updated Packages

* updated kotlin
  • Loading branch information
DattatreyaReddy authored Feb 17, 2023
1 parent a7e50fb commit bb4c9e3
Show file tree
Hide file tree
Showing 49 changed files with 360 additions and 184 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.7.21'
ext.kotlin_version = '1.8.10'
repositories {
google()
mavenCentral()
Expand Down
3 changes: 3 additions & 0 deletions assets/locales/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
"missingExtension": "Missing Extensions",
"missingTrackers": "Missing Trackers",
"more": "More",
"moveToBottom": "Move to Bottom",
"moveToTop": "Move to top",
"newUpdateAvailable": "New update available",
"noCategoriesFound": "You don't have any Categories. \nTap the Plus button to create one for organizing your library",
"noCategoriesFoundAlt": "You don't have any Categories. \nCreate one in settings for organizing your library",
Expand All @@ -156,6 +158,7 @@
},
"nsfw18": "18+",
"numSelected": "{num} Selected",
"obsolete": "Obsolete",
"page": "Page: {number}",
"password": "Password",
"pause": "Pause",
Expand Down
3 changes: 3 additions & 0 deletions assets/locales/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
"missingExtension": "Extensões em falta",
"missingTrackers": "Rasteadores em falta",
"more": "Mais",
"moveToBottom": "Mover para baixo",
"moveToTop": "Mover para cima",
"newUpdateAvailable": "Nova atualização disponível",
"noCategoriesFound": "Não tem nenhuma categoria. \nToque no no botão mais para criar uma categoria para organizar a sua biblioteca",
"noCategoriesFoundAlt": "Não tem nenhuma categoria. \nCria uma nas definições para organizar a sua biblioteca",
Expand All @@ -156,6 +158,7 @@
},
"nsfw18": "18+",
"numSelected": "{num} Selecionado",
"obsolete": "Obsoleta",
"page": "Página: {number}",
"password": "Senha",
"pause": "Pausa",
Expand Down
3 changes: 3 additions & 0 deletions lib/src/constants/endpoints.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ abstract class DownloaderUrl {
static String chapter(int mangaId, int chapterIndex) =>
"/download/$mangaId/chapter/$chapterIndex";

static String reorderDownload(int mangaId, int chapterIndex, int to) =>
"/download/$mangaId/chapter/$chapterIndex/reorder/$to";

static const String downloads = "/downloads";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ AsyncValue<Map<String, List<Extension>>> extensionMap(ExtensionMapRef ref) {
final extensionMap = <String, List<Extension>>{};
final extensionListData = ref.watch(extensionProvider);
final extensionList = [...?extensionListData.valueOrNull];
final showNsfw = ref.watch(showNSFWProvider) ?? true;
final showNsfw = ref.watch(showNSFWProvider).ifNull(true);
for (final e in extensionList) {
if (!showNsfw && (e.isNsfw ?? false)) continue;
if (e.installed ?? false) {
if (e.hasUpdate ?? false) {
if (!showNsfw && (e.isNsfw.ifNull())) continue;
if (e.installed.ifNull()) {
if (e.hasUpdate.ifNull()) {
extensionMap.update(
"update",
(value) => [...value, e],
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ExtensionLanguageFilterDialog extends ConsumerWidget {
{...?enabledLanguages, languageCodes[index]}.toList(),
);
} else {
if (!(enabledLanguagesIndex?.isNegative ?? true)) {
if (!((enabledLanguagesIndex?.isNegative).ifNull(true))) {
ref.read(extensionLanguageFilterProvider.notifier).update(
[...?enabledLanguages]
..removeAt(enabledLanguagesIndex!),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ class ExtensionListTile extends HookConsumerWidget {
isLoading: isLoading.value,
),
),
title: Text(extension.name ?? ""),
title: Text(
extension.name ?? "",
overflow: TextOverflow.ellipsis,
),
subtitle: Text.rich(
TextSpan(
text: (extension.lang) != null
Expand All @@ -55,7 +58,7 @@ class ExtensionListTile extends HookConsumerWidget {
text: "${extension.versionName ?? ""} ",
style: const TextStyle(fontWeight: FontWeight.normal),
),
if (extension.isNsfw ?? false)
if (extension.isNsfw.ifNull())
TextSpan(
text: LocaleKeys.nsfw18.tr(),
style: const TextStyle(
Expand All @@ -66,65 +69,79 @@ class ExtensionListTile extends HookConsumerWidget {
],
),
),
trailing: (extension.installed ?? false)
? TextButton(
onPressed: isLoading.value
? null
: () async {
try {
isLoading.value = true;
(await AsyncValue.guard(() async {
if (extension.pkgName.isBlank) {
throw LocaleKeys.error_extension.tr();
}
await (extension.hasUpdate ?? false
? repository.updateExtension(extension.pkgName!)
: repository
.uninstallExtension(extension.pkgName!));

await refresh();
}))
.showToastOnError(ref.read(toastProvider(context)));
isLoading.value = false;
} catch (e) {
//
}
},
trailing: extension.obsolete.ifNull()
? OutlinedButton(
onPressed: extension.installed.ifNull()
? () => repository.uninstallExtension(extension.pkgName!)
: null,
child: Text(
extension.hasUpdate ?? false
? isLoading.value
? LocaleKeys.updating.tr()
: LocaleKeys.update.tr()
: isLoading.value
? LocaleKeys.uninstalling.tr()
: LocaleKeys.uninstall.tr(),
LocaleKeys.obsolete.tr(),
style: const TextStyle(color: Colors.redAccent),
),
)
: TextButton(
onPressed: isLoading.value
? null
: () async {
try {
isLoading.value = true;
(await AsyncValue.guard(() async {
if (extension.pkgName.isBlank) {
throw LocaleKeys.error_extension.tr();
: extension.installed.ifNull()
? TextButton(
onPressed: isLoading.value
? null
: () async {
try {
isLoading.value = true;
(await AsyncValue.guard(() async {
if (extension.pkgName.isBlank) {
throw LocaleKeys.error_extension.tr();
}
await (extension.hasUpdate.ifNull()
? repository
.updateExtension(extension.pkgName!)
: repository
.uninstallExtension(extension.pkgName!));

await refresh();
}))
.showToastOnError(
ref.read(toastProvider(context)));
isLoading.value = false;
} catch (e) {
//
}
await repository.installExtension(extension.pkgName!);
await refresh();
}))
.showToastOnError(ref.read(toastProvider(context)));
isLoading.value = false;
} catch (e) {
//
}
},
child: Text(
isLoading.value
? LocaleKeys.installing.tr()
: LocaleKeys.install.tr(),
),
),
},
child: Text(
extension.hasUpdate.ifNull()
? isLoading.value
? LocaleKeys.updating.tr()
: LocaleKeys.update.tr()
: isLoading.value
? LocaleKeys.uninstalling.tr()
: LocaleKeys.uninstall.tr(),
),
)
: TextButton(
onPressed: isLoading.value
? null
: () async {
try {
isLoading.value = true;
(await AsyncValue.guard(() async {
if (extension.pkgName.isBlank) {
throw LocaleKeys.error_extension.tr();
}
await repository
.installExtension(extension.pkgName!);
await refresh();
}))
.showToastOnError(
ref.read(toastProvider(context)));
isLoading.value = false;
} catch (e) {
//
}
},
child: Text(
isLoading.value
? LocaleKeys.installing.tr()
: LocaleKeys.install.tr(),
),
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class SourceQuickSearch extends ConsumerWidget {
height: 192,
child: MangaCoverGridTile(
manga: i,
showDarkOverlay: i.inLibrary ?? false,
showDarkOverlay: i.inLibrary.ifNull(),
onPressed: i.id != null
? () => context.push(Routes.getManga(i.id!))
: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SourceLanguageFilter extends ConsumerWidget {
{...?enabledLanguages, languageCodes[index]}.toList(),
);
} else {
if (!(enabledLanguagesIndex?.isNegative ?? true)) {
if (!((enabledLanguagesIndex?.isNegative).ifNull(true))) {
ref.read(sourceLanguageFilterProvider.notifier).update(
[...?enabledLanguages]
..removeAt(enabledLanguagesIndex!),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SourceListTile extends ConsumerWidget {
subtitle: (source.lang?.displayName).isNotBlank
? Text(source.lang?.displayName ?? "")
: null,
trailing: (source.supportsLatest ?? false)
trailing: (source.supportsLatest.ifNull())
? TextButton(
onPressed: () async {
ref.read(sourceLastUsedProvider.notifier).update(source.id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class SourceMangaListScreen extends HookConsumerWidget {
data: (recentChaptersPage) {
try {
if (recentChaptersPage != null) {
if (recentChaptersPage.hasNextPage ?? false) {
if (recentChaptersPage.hasNextPage.ifNull()) {
controller.appendPage(
[...?recentChaptersPage.mangaList],
pageKey + 1,
Expand Down Expand Up @@ -158,7 +158,7 @@ class SourceMangaListScreen extends HookConsumerWidget {
);
},
),
if (data?.supportsLatest ?? false)
if ((data?.supportsLatest).ifNull())
SourceTypeSelectableChip(
value: SourceType.latest,
groupValue: sourceType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class FilterToWidget extends StatelessWidget {
initialText: text.state,
),
checkBox: (checkbox) => CheckboxListTile(
value: checkbox.state ?? false,
value: checkbox.state.ifNull(),
title: Text(checkbox.name ?? ""),
onChanged: (value) =>
onChangedFilterCopyWith(checkbox.copyWith(state: value)),
Expand All @@ -66,7 +66,7 @@ class FilterToWidget extends StatelessWidget {
for (int i = 0; i < (sort.values?.length ?? 0); i++)
SortListTile(
key: ValueKey("${sort.name}-$i"),
ascending: sort.state?.ascending ?? true,
ascending: (sort.state?.ascending).ifNull(true),
title: Text(sort.values != null ? sort.values![i] : ""),
selected: i == sort.state?.index,
onChanged: (value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import '../../../../../constants/app_sizes.dart';
import '../../../../../i18n/locale_keys.g.dart';
import '../../../../../routes/router_config.dart';
import '../../../../../utils/extensions/custom_extensions.dart';
import '../../../../../widgets/emoticons.dart';
import '../../../../../widgets/manga_cover/grid/manga_cover_grid_tile.dart';
import '../../../../manga_book/domain/manga/manga_model.dart';
Expand Down Expand Up @@ -42,7 +43,7 @@ class SourceMangaGridView extends StatelessWidget {
),
itemBuilder: (context, item, index) => MangaCoverGridTile(
manga: item.copyWith(source: source),
showDarkOverlay: item.inLibrary ?? false,
showDarkOverlay: item.inLibrary.ifNull(),
onPressed: () {
if (item.id != null) {
context.push(Routes.getManga(item.id!));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EditCategoryDialog extends HookConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final categoryName = useTextEditingController(text: category?.name);
final defaultCategory = useState(category?.defaultCategory ?? false);
final defaultCategory = useState((category?.defaultCategory).ifNull());
return AlertDialog(
title: Text(
category == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool genreMatches(List<String>? mangaGenreList, List<String>? queryGenreList) {
Set<String>? mangaSet = mangaGenreList?.map((e) => e.toLowerCase()).toSet();
Set<String>? querySet =
queryGenreList?.map((e) => e.toLowerCase().trim()).toSet();
return mangaSet?.containsAll(querySet ?? <String>{}) ?? true;
return (mangaSet?.containsAll(querySet ?? <String>{})).ifNull(true);
}

@riverpod
Expand All @@ -48,7 +48,7 @@ class CategoryMangaListWithQueryAndFilter
final mangaFilterCompleted = ref.watch(libraryMangaFilterCompletedProvider);
final sortedBy = ref.watch(libraryMangaSortProvider);
final sortedDirection =
ref.watch(libraryMangaSortDirectionProvider) ?? true;
ref.watch(libraryMangaSortDirectionProvider).ifNull(true);

bool applyMangaFilter(Manga manga) {
if (mangaFilterUnread != null &&
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

import '../../../../../constants/enum.dart';
import '../../../../../utils/extensions/custom_extensions.dart';
import '../../../../../widgets/sort_list_tile.dart';
import '../controller/library_controller.dart';

Expand All @@ -25,10 +26,10 @@ class LibraryMangaSortTile extends ConsumerWidget {
return SortListTile(
selected: sortType == sortedBy,
title: Text(sortType.toString().tr()),
ascending: sortedDirection ?? true,
ascending: sortedDirection.ifNull(true),
onChanged: (bool? value) => ref
.read(libraryMangaSortDirectionProvider.notifier)
.update(!(sortedDirection ?? false)),
.update(!(sortedDirection.ifNull())),
onSelected: () =>
ref.read(libraryMangaSortProvider.notifier).update(sortType),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ class DownloadsRepository {
Future<void> removeChapterFromDownloadQueue(int mangaId, int chapterIndex) =>
dioClient.delete(DownloaderUrl.chapter(mangaId, chapterIndex));

Future<void> reorderDownload(int mangaId, int chapterIndex, int to) =>
dioClient.patch(
DownloaderUrl.reorderDownload(mangaId, chapterIndex, to),
);

Pair<Stream<Downloads>, AsyncCallback> socketDownloads() {
final url = (dioClient.dio.options.baseUrl.toWebSocket!);
final channel =
Expand Down
Loading

0 comments on commit bb4c9e3

Please sign in to comment.