Skip to content

Commit

Permalink
Add tap to entry detail
Browse files Browse the repository at this point in the history
  • Loading branch information
up2code committed Mar 14, 2024
1 parent 18d31dc commit 1ea9fdf
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lib/src/features/entries/domain/entry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:vocadb_app/src/features/artists/domain/artist.dart';
import 'package:vocadb_app/src/features/entries/domain/main_picture.dart';
import 'package:vocadb_app/src/features/releaseEvents/domain/release_event.dart';
import 'package:vocadb_app/src/features/songs/domain/song.dart';
import 'package:vocadb_app/src/features/tags/domain/tag.dart';
import 'package:vocadb_app/src/features/tags/domain/tag_usage.dart';
import 'package:vocadb_app/src/features/weblinks/domain/web_link.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
Expand Down Expand Up @@ -88,6 +89,13 @@ extension EntryExtended on Entry {
);
}

Tag toTag() {
return Tag(
id: id,
name: name,
);
}

String get imageUrl {
if (mainPicture == null || mainPicture!.urlOriginal == null) {
return kPlaceholderImageUrl;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:vocadb_app/src/common_widgets/custom_network_image.dart';
import 'package:vocadb_app/src/features/entries/domain/entry.dart';
import 'package:vocadb_app/src/routing/app_route_context.dart';

class EntriesSearchResult extends StatelessWidget {
const EntriesSearchResult({super.key, required this.entries});
Expand All @@ -21,7 +23,9 @@ class EntriesSearchResult extends StatelessWidget {
),
title: Text(entry.name ?? '<None>'),
subtitle: Text(entry.entryType),
onTap: () {},
onTap: () {
context.goEntryDetail(entry);
},
);
}),
);
Expand Down
24 changes: 24 additions & 0 deletions lib/src/routing/app_route_context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:go_router/go_router.dart';
import 'package:vocadb_app/src/features/albums/domain/album.dart';
import 'package:vocadb_app/src/features/artists/domain/artist.dart';
import 'package:vocadb_app/src/features/entries/domain/entry.dart';
import 'package:vocadb_app/src/features/releaseEvents/domain/release_event.dart';
import 'package:vocadb_app/src/features/songs/domain/song.dart';
import 'package:vocadb_app/src/features/tags/domain/tag.dart';
Expand Down Expand Up @@ -33,6 +34,29 @@ extension AppRouteContext on BuildContext {

}

Future<void> goEntryDetail(Entry entry) async {
String entryType = entry.entryType;
switch (entryType) {
case 'Album':
goAlbumDetail(entry.toAlbum());
break;
case 'Artist':
goArtistDetail(entry.toArtist());
break;
case 'Song':
goSongDetail(entry.toSong());
break;
case 'Tag':
goTagDetail(entry.toTag());
break;
case 'ReleaseEvent':
goReleaseEventDetail(entry.toReleaseEvent());
break;
default:
throw Exception('Unsupported entry type: $entryType');
}
}

Future<void> goLogin() async {
goNamed(AppRoute.signIn.name);
}
Expand Down

0 comments on commit 1ea9fdf

Please sign in to comment.