Skip to content

Commit

Permalink
feat: support unique slug for comic issues (#82)
Browse files Browse the repository at this point in the history
* make bottom navigation to the old style

* support issue id as a string
  • Loading branch information
d-reader-luka authored Mar 26, 2024
1 parent 11247f9 commit ebd4d41
Show file tree
Hide file tree
Showing 21 changed files with 41 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import 'package:d_reader_flutter/shared/exceptions/exceptions.dart';
abstract class ComicIssueDataSource {
Future<Either<AppException, List<ComicIssueModel>>> getComicIssues(
{String? queryString});
Future<Either<AppException, ComicIssueModel>> getComicIssue(int id);
Future<Either<AppException, ComicIssueModel>> getComicIssue(String id);
Future<List<PageModel>> getComicIssuePages(int id);
Future<void> favouritiseIssue(int id);
Future<void> rateIssue({
Expand All @@ -32,7 +32,7 @@ class ComicIssueRemoteDataSource implements ComicIssueDataSource {
}

@override
Future<Either<AppException, ComicIssueModel>> getComicIssue(int id) async {
Future<Either<AppException, ComicIssueModel>> getComicIssue(String id) async {
try {
final response = await networkService.get('/comic-issue/get/$id');
return response.fold(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ComicIssueRepositoryImpl implements ComicIssueRepository {
}

@override
Future<Either<AppException, ComicIssueModel>> getComicIssue(int id) {
Future<Either<AppException, ComicIssueModel>> getComicIssue(String id) {
return dataSource.getComicIssue(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:d_reader_flutter/shared/exceptions/exceptions.dart';
abstract class ComicIssueRepository {
Future<Either<AppException, List<ComicIssueModel>>> getComicIssues(
{String? queryString});
Future<Either<AppException, ComicIssueModel>> getComicIssue(int id);
Future<Either<AppException, ComicIssueModel>> getComicIssue(String id);
Future<List<PageModel>> getComicIssuePages(int id);
Future<void> favouritiseIssue(int id);
Future<void> rateIssue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ part 'comic_issue_providers.g.dart';

@riverpod
Future<ComicIssueModel> comicIssueDetails(
ComicIssueDetailsRef ref, int id) async {
ComicIssueDetailsRef ref, String id) async {
final response =
await ref.read(comicIssueRepositoryProvider).getComicIssue(id);
return response.fold((exception) {
Expand Down

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

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 @@ -31,7 +31,7 @@ import 'package:go_router/go_router.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';

class ComicIssueDetails extends ConsumerStatefulWidget {
final int id;
final String id;
const ComicIssueDetails({
super.key,
required this.id,
Expand Down
2 changes: 1 addition & 1 deletion lib/features/e_reader/presentation/screens/e_reader.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class _EReaderViewState extends ConsumerState<EReaderView>
AsyncValue<List<PageModel>> pagesProvider =
ref.watch(comicIssuePagesProvider(widget.issueId));
AsyncValue<ComicIssueModel?> issueProvider =
ref.watch(comicIssueDetailsProvider(widget.issueId));
ref.watch(comicIssueDetailsProvider('${widget.issueId}'));
final notifier = ref.read(isAppBarVisibleProvider.notifier);
return NotificationListener(
onNotification: (notification) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class EReaderBottomNavigation extends ConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final provider = ref.watch(comicIssueDetailsProvider(issueId));
final provider = ref.watch(comicIssueDetailsProvider('$issueId'));

return provider.maybeWhen(
orElse: () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class OwnedController extends _$OwnedController {
goToNftDetails(ownedNfts.elementAt(properIndex).address);
}
final ComicIssueModel? comicIssue = await ref.read(
comicIssueDetailsProvider(comicIssueId).future,
comicIssueDetailsProvider('$comicIssueId').future,
);
ref.read(selectedIssueInfoProvider.notifier).update((state) => comicIssue);
}
Expand Down

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

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

10 changes: 6 additions & 4 deletions lib/main_dev.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ class MyApp extends ConsumerWidget {
),
navigationBarTheme: NavigationBarThemeData(
height: 48,
labelTextStyle: MaterialStateProperty.all(
const TextStyle(
color: Colors.white,
labelTextStyle: MaterialStateProperty.resolveWith<TextStyle>(
(Set<MaterialState> states) => TextStyle(
color: states.contains(MaterialState.selected)
? ColorPalette.dReaderYellow100
: Colors.white,
fontSize: 12,
fontWeight: FontWeight.w500,
letterSpacing: 0.2,
letterSpacing: .2,
),
),
),
Expand Down
10 changes: 6 additions & 4 deletions lib/main_prod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,14 @@ class MyApp extends ConsumerWidget {
),
navigationBarTheme: NavigationBarThemeData(
height: 48,
labelTextStyle: MaterialStateProperty.all(
const TextStyle(
color: Colors.white,
labelTextStyle: MaterialStateProperty.resolveWith<TextStyle>(
(Set<MaterialState> states) => TextStyle(
color: states.contains(MaterialState.selected)
? ColorPalette.dReaderYellow100
: Colors.white,
fontSize: 12,
fontWeight: FontWeight.w500,
letterSpacing: 0.2,
letterSpacing: .2,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/routing/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ final List<GoRoute> homeRoutes = [
path: '${RoutePath.comicIssueDetails}/:id',
builder: (context, state) {
final id = state.pathParameters['id'] ?? '';
return ComicIssueDetails(id: int.parse(id));
return ComicIssueDetails(id: id);
},
),
GoRoute(
Expand Down
4 changes: 1 addition & 3 deletions lib/shared/data/remote/notification_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ handleNotificationAction(Map payload) {
return routerNavigatorKey.currentState!.push(
MaterialPageRoute(
builder: (context) => ComicIssueDetails(
id: int.parse(
payload[NotificationDataKey.comicIssueId.stringValue],
),
id: payload[NotificationDataKey.comicIssueId.stringValue],
),
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/shared/domain/providers/solana/solana_notifier.g.dart

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

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

3 changes: 2 additions & 1 deletion lib/shared/widgets/layout/bottom_navigation_item_icon.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:d_reader_flutter/shared/theme/app_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

Expand All @@ -18,7 +19,7 @@ class BottomNavigationItemIcon extends StatelessWidget {
imagePath,
colorFilter: isActive
? const ColorFilter.mode(
Colors.white,
ColorPalette.dReaderYellow100,
BlendMode.srcIn,
)
: null,
Expand Down
7 changes: 3 additions & 4 deletions lib/shared/widgets/layout/custom_bottom_navigation_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'dart:ui';

import 'package:d_reader_flutter/config/config.dart';
import 'package:d_reader_flutter/shared/presentations/providers/global/scaffold_provider.dart';
import 'package:d_reader_flutter/shared/theme/app_colors.dart';
import 'package:d_reader_flutter/shared/widgets/layout/bottom_navigation_item_icon.dart';
import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand Down Expand Up @@ -32,10 +31,10 @@ class CustomBottomNavigationBar extends ConsumerWidget {
},
selectedIndex: ref.watch(scaffoldNavigationIndexProvider),
backgroundColor: Colors.transparent,
indicatorColor: ColorPalette.dReaderYellow100,
indicatorColor: Colors.transparent,
elevation: 0,
labelBehavior: NavigationDestinationLabelBehavior.onlyShowSelected,
animationDuration: const Duration(milliseconds: 700),
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
overlayColor: const MaterialStatePropertyAll(Colors.transparent),
destinations: const [
NavigationDestination(
icon: BottomNavigationItemIcon(
Expand Down
3 changes: 2 additions & 1 deletion lib/shared/widgets/scaffolds/d_reader_scaffold.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class _DReaderScaffoldState extends ConsumerState<DReaderScaffold> {
AppBar(
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
toolbarHeight: 40,
toolbarHeight: 42,
titleSpacing: 12,
title: const Text(
'Settings',
style: TextStyle(
Expand Down

0 comments on commit ebd4d41

Please sign in to comment.