-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
124 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Package imports: | ||
import 'package:equatable/equatable.dart'; | ||
|
||
// Project imports: | ||
import 'package:boorusama/boorus/core/feats/tags/tags.dart'; | ||
|
||
class TagGroupItem extends Equatable { | ||
const TagGroupItem({ | ||
required this.category, | ||
required this.groupName, | ||
required this.tags, | ||
required this.order, | ||
}); | ||
|
||
final int category; | ||
final String groupName; | ||
final List<Tag> tags; | ||
final TagCategoryOrder order; | ||
|
||
@override | ||
List<Object?> get props => [category, groupName, tags, order]; | ||
} | ||
|
||
extension TagGroupItemX on TagGroupItem { | ||
List<String> extractRawTag(TagCategory category) => | ||
tags.where((e) => category == e.category).map((e) => e.rawName).toList(); | ||
|
||
List<String> extractArtistTags() => extractRawTag(TagCategory.artist); | ||
List<String> extractCharacterTags() => extractRawTag(TagCategory.charater); | ||
List<String> extractGeneralTags() => extractRawTag(TagCategory.general); | ||
List<String> extractMetaTags() => extractRawTag(TagCategory.meta); | ||
List<String> extractCopyRightTags() => extractRawTag(TagCategory.copyright); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
lib/boorus/moebooru/pages/posts/moebooru_information_section.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Flutter imports: | ||
import 'package:flutter/material.dart'; | ||
|
||
// Package imports: | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
// Project imports: | ||
import 'package:boorusama/boorus/core/feats/posts/posts.dart'; | ||
import 'package:boorusama/boorus/core/feats/tags/tags.dart'; | ||
import 'package:boorusama/boorus/core/widgets/posts/information_section.dart'; | ||
|
||
class MoebooruInformationSection extends ConsumerWidget { | ||
const MoebooruInformationSection({ | ||
super.key, | ||
required this.post, | ||
}); | ||
|
||
final Post post; | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final tags = ref.watch(tagsProvider); | ||
final characterTags = | ||
tags?.map((e) => e.extractCharacterTags()).expand((e) => e).toList(); | ||
final artistTags = | ||
tags?.map((e) => e.extractArtistTags()).expand((e) => e).toList(); | ||
final copyRightTags = | ||
tags?.map((e) => e.extractCopyRightTags()).expand((e) => e).toList(); | ||
|
||
return InformationSection( | ||
characterTags: characterTags ?? [], | ||
artistTags: artistTags ?? [], | ||
copyrightTags: copyRightTags ?? [], | ||
createdAt: post.createdAt ?? DateTime.now(), | ||
source: post.source, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters