Skip to content

Commit

Permalink
bug fixes (#187)
Browse files Browse the repository at this point in the history
* bug fixes

* updated pubspec

* fixed refresh on update check comlete

* fixed previous done button in updates screen

* added tap on cover to goto manga in updates screen

* updated pubspec

* updated pubspec
  • Loading branch information
DattatreyaReddy authored May 11, 2023
1 parent 05a1997 commit 8e23e41
Show file tree
Hide file tree
Showing 21 changed files with 177 additions and 182 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ class UpdateStatus with _$UpdateStatus {

int get updateChecked => (completed?.length ?? 0) + (failed?.length ?? 0);

bool get isUpdateCompleted => total == updateChecked;
bool get isUpdateCheckCompleted => total == updateChecked;

bool get showUpdateStatus => (total).isGreaterThan(0) && !(isUpdateCompleted);
bool get isUpdateChecking =>
(total).isGreaterThan(0) && !(isUpdateCheckCompleted);

factory UpdateStatus.fromJson(Map<String, dynamic> json) =>
_$UpdateStatusFromJson(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ class MangaDetailsScreen extends HookConsumerWidget {
await chapterListRefresh(onlineFetch);
if (context.mounted && onlineFetch) {
if (manga.hasError) {
ref.read(toastProvider(context)).showError(
context.l10n!.errorSomethingWentWrong,
);
} else {
ref.read(toastProvider(context)).show(
context.l10n!.updateCompleted,
withMicrotask: true,
);
} else {
ref.read(toastProvider(context)).showError(
context.l10n!.errorSomethingWentWrong,
);
}
}
}, []);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ChapterListTile extends StatelessWidget {
? Row(
children: [
Text(
chapter.uploadDate!.toDaysAgo,
chapter.uploadDate!.toDaysAgo(context),
style: TextStyle(
color: chapter.read.ifNull() ? Colors.grey : null,
),
Expand All @@ -76,12 +76,14 @@ class ChapterListTile extends StatelessWidget {
overflow: TextOverflow.ellipsis,
),
if (chapter.scanlator.isNotBlank)
Text(
" • ${chapter.scanlator}",
style: TextStyle(
color: chapter.read.ifNull() ? Colors.grey : null,
Expanded(
child: Text(
" • ${chapter.scanlator}",
style: TextStyle(
color: chapter.read.ifNull() ? Colors.grey : null,
),
overflow: TextOverflow.ellipsis,
),
overflow: TextOverflow.ellipsis,
),
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class PreviousScrollIntent extends Intent {}

class PreviousChapterIntent extends Intent {}

class HideQuickOpenIntent extends Intent {}

class ReaderWrapper extends HookConsumerWidget {
const ReaderWrapper({
super.key,
Expand Down Expand Up @@ -377,6 +379,8 @@ class ReaderWrapper extends HookConsumerWidget {
scrollDirection == Axis.vertical
? NextScrollIntent()
: PreviousChapterIntent(),
const SingleActivator(LogicalKeyboardKey.escape):
HideQuickOpenIntent(),
},
child: Actions(
actions: {
Expand Down Expand Up @@ -408,6 +412,12 @@ class ReaderWrapper extends HookConsumerWidget {
).pushReplacement(context)
: onNext(),
),
HideQuickOpenIntent: CallbackAction<HideQuickOpenIntent>(
onInvoke: (HideQuickOpenIntent intent) {
visibility.value = !visibility.value;
return null;
},
),
},
child: Focus(
autofocus: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ class UpdatesScreen extends HookConsumerWidget {
final controller =
usePagingController<int, ChapterMangaPair>(firstPageKey: 0);
final updatesRepository = ref.watch(updatesRepositoryProvider);
final isUpdatesChecking = ref
.watch(updatesSocketProvider
.select((value) => value.valueOrNull?.isUpdateChecking))
.ifNull();
final selectedChapters = useState<Map<int, Chapter>>({});
useEffect(() {
controller.addPageRequestListener((pageKey) => _fetchPage(
updatesRepository,
Expand All @@ -66,7 +71,17 @@ class UpdatesScreen extends HookConsumerWidget {
));
return;
}, []);
final selectedChapters = useState<Map<int, Chapter>>({});
useEffect(() {
if (!isUpdatesChecking) {
try {
selectedChapters.value = <int, Chapter>{};
controller.refresh();
} catch (e) {
//
}
}
return null;
}, [isUpdatesChecking]);
return Scaffold(
floatingActionButton: const UpdateStatusFab(),
appBar: selectedChapters.value.isNotEmpty
Expand All @@ -87,6 +102,7 @@ class UpdatesScreen extends HookConsumerWidget {
? MultiChaptersActionsBottomAppBar(
selectedChapters: selectedChapters,
afterOptionSelected: () async => controller.refresh(),
hasPreviousDone: false,
)
: null,
body: RefreshIndicator(
Expand Down Expand Up @@ -159,7 +175,9 @@ class UpdatesScreen extends HookConsumerWidget {
mainAxisSize: MainAxisSize.min,
children: [
ListTile(
title: Text(item.chapter!.fetchedAt.toDaysAgoFromSeconds),
title: Text(
item.chapter!.fetchedAt.toDaysAgoFromSeconds(context),
),
),
chapterTile,
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,18 @@ class ChapterMangaListTile extends StatelessWidget {
),
leading: ClipRRect(
borderRadius: KBorderRadius.r8.radius,
child: ServerImage(
imageUrl: pair.manga?.thumbnailUrl ?? "",
size: const Size.square(48),
child: InkWell(
onTap: () {
if ((pair.manga?.id) != null) {
MangaRoute(
mangaId: pair.manga!.id!,
).push(context);
}
},
child: ServerImage(
imageUrl: pair.manga?.thumbnailUrl ?? "",
size: const Size.square(48),
),
),
),
subtitle: Text(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ class MultiChaptersActionsBottomAppBar extends HookConsumerWidget {
super.key,
required this.selectedChapters,
required this.afterOptionSelected,
this.hasPreviousDone = true,
});

final ValueNotifier<Map<int, Chapter>> selectedChapters;
final AsyncCallback afterOptionSelected;
final bool hasPreviousDone;

List<int> get chapterList => selectedChapters.value.keys.toList();

Expand Down Expand Up @@ -58,7 +60,7 @@ class MultiChaptersActionsBottomAppBar extends HookConsumerWidget {
change: ChapterChange(isBookmarked: true),
refresh: refresh,
),
if (selectedList.isSingletonList)
if (selectedList.isSingletonList && hasPreviousDone)
SingleChapterActionIcon(
chapterIndex: selectedChapters.value[chapterList.first]!.index!,
mangaId: selectedChapters.value[chapterList.first]!.mangaId!,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/features/manga_book/widgets/update_status_fab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class UpdateStatusFab extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final updateStatus = ref.watch(updatesSocketProvider);
final showStatus = (updateStatus.valueOrNull?.showUpdateStatus).ifNull();
final showStatus = (updateStatus.valueOrNull?.isUpdateChecking).ifNull();
return FloatingActionButton.extended(
icon: showStatus ? null : const Icon(Icons.refresh),
onPressed: () => showStatus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,11 @@ class SearchStackScreen extends HookWidget {
@override
Widget build(BuildContext context) {
final visible = useState(false);
final focus = useFocusNode();
useEffect(() {
if (!visible.value) {
focus.requestFocus();
}
return null;
}, [visible.value]);
return QuickSearchShortcutWrapper(
visible: visible,
child: Stack(
children: [
if (child != null)
Focus(
autofocus: true,
focusNode: focus,
child: child!,
),
if (child != null) child!,
if (visible.value)
GestureDetector(
onTap: () => visible.value = false,
Expand Down
12 changes: 12 additions & 0 deletions lib/src/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
"@current": {
"description": "Text to show the currently reading chapter in Reader Screen"
},
"@daysAgo": {
"description": "Days ago text to show the release date of manga"
},
"@defaultCategory": {
"description": "Checkbox description when creating a Category to add manga to the Category by Default"
},
Expand Down Expand Up @@ -571,6 +574,12 @@
"@start": {
"description": "Button text start reading the manga"
},
"@today": {
"description": "Today Text to show the release date of manga"
},
"@yesterday": {
"description": "Yesterday Text to show the release date of manga"
},
"@themeModeDark": {
"description": "Radio button text for App theme - Dark"
},
Expand Down Expand Up @@ -675,6 +684,7 @@
"createBackupTitle": "Create Backup",
"credentials": "Credentials",
"current": "Current",
"daysAgo": "{days} days ago",
"defaultCategory": "Default category when adding new manga to library",
"delete": "Delete",
"deleteCategoryDescription": "This will merge all Mangas in this Category to Default!",
Expand Down Expand Up @@ -816,6 +826,8 @@
"themeModeDark": "Dark",
"themeModeLight": "Light",
"themeModeSystem": "System",
"today": "Today",
"yesterday" : "Yesterday",
"uninstall": "Uninstall",
"uninstalling": "Uninstalling",
"unknownAuthor": "Unknown Author",
Expand Down
2 changes: 1 addition & 1 deletion lib/src/routes/router_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class Routes {
static const settings = '/settings';
static const browseSettings = 'browse';
static const readerSettings = 'reader';
static const reader = '/reader/:mangaId/:chapterIndex';
static const reader = '/manga/:mangaId/chapter/:chapterIndex';
static const serverSettings = 'server';
static const editCategories = 'edit-categories';
static const extensions = '/extensions';
Expand Down
29 changes: 15 additions & 14 deletions lib/src/routes/router_config.g.dart

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 @@ -100,15 +100,15 @@ extension DateTimeExtensions on DateTime {

static DateTime max(DateTime a, DateTime b) => a.compareTo(b) > 0 ? a : b;

String get convertToDaysAgo {
String convertToDaysAgo(BuildContext context) {
Duration diff = DateTime.now().difference(this);

if (diff.inDays < 1) {
return "Today";
return context.l10n!.today;
} else if (diff.inDays < 2) {
return 'Yesterday';
return context.l10n!.yesterday;
} else if (diff.inDays < 10) {
return '${diff.inDays} days ago';
return context.l10n!.daysAgo(diff.inDays);
} else {
return DateFormat.yMMMd().format(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ extension IntExtensions on int? {
return DateTime.fromMillisecondsSinceEpoch(this! * 1000).toDateString;
}

String get toDaysAgoFromSeconds {
String toDaysAgoFromSeconds(BuildContext context) {
if (isNull) return "";
return DateTime.fromMillisecondsSinceEpoch(this! * 1000).convertToDaysAgo;
return DateTime.fromMillisecondsSinceEpoch(this! * 1000)
.convertToDaysAgo(context);
}

String get toDaysAgo {
String toDaysAgo(context) {
if (isNull) return "";
return DateTime.fromMillisecondsSinceEpoch(this!).convertToDaysAgo;
return DateTime.fromMillisecondsSinceEpoch(this!).convertToDaysAgo(context);
}

bool isSameDayAs(int? anotherDate) {
Expand Down
Loading

0 comments on commit 8e23e41

Please sign in to comment.