Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 14 additions & 23 deletions lib/app/enum/post_type.enum.dart
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:gds/gds.dart';
import 'package:json_annotation/json_annotation.dart';

enum PostType {
@JsonValue('NORMAL')
normal('일반'),
normal('일반', 'NORMAL'),

@JsonValue('QUESTION')
question('질문'),
question('질문', 'QUESTION'),

@JsonValue('FEEDBACK')
feedback('피드백'),
feedback('피드백', 'FEEDBACK'),

@JsonValue('NOTICE')
notice('공지'),
@JsonValue('ALL')
all('전체');
notice('공지', 'NOTICE'),

final String displayName;
@JsonValue('All')
all('전체', 'ALL');
Comment thread
MTtankkeo marked this conversation as resolved.
Outdated

const PostType(this.displayName);
final String displayName;
final String jsonKey;
const PostType(this.displayName, this.jsonKey);

static PostType fromString(String value) {
return PostType.values.firstWhere((e) => e.toJson() == value, orElse: () => PostType.normal);
}

String toJson() {
switch (this) {
case PostType.normal:
return 'NORMAL';
case PostType.question:
return 'QUESTION';
case PostType.feedback:
return 'FEEDBACK';
case PostType.notice:
return 'NOTICE';
case PostType.all:
return 'ALL';
}
}
String toJson() => jsonKey;

GdsChipVariant get chipVariant => switch (this) {
PostType.normal => GdsChipVariant.assistive,
Expand Down
22 changes: 16 additions & 6 deletions lib/app/enum/report.enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,25 @@ enum ReportType {

enum ReportRefType {
@JsonValue('USER')
user,
user('USER'),

@JsonValue('FEED')
feed,
feed('FEED'),

@JsonValue('FEED_COMMENT')
feedComment,
feedComment('FEED_COMMENT'),

@JsonValue('POST')
post,
post('POST'),

@JsonValue('POST_COMMENT')
postComment,
postComment('POST_COMMENT'),

@JsonValue('CHAT')
chat,
chat('CHAT');

final String jsonKey;
const ReportRefType(this.jsonKey);

String toJson() => jsonKey;
}
5 changes: 4 additions & 1 deletion lib/app/enum/search_type.enum.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:json_annotation/json_annotation.dart';

enum SearchType {
@JsonValue('combined')
combined('제목'),

@JsonValue('name')
name('글쓴이');

final String displayName;
const SearchType(this.displayName);

String toJson() => this.name;
}
12 changes: 8 additions & 4 deletions lib/app/enum/sort_type.enum.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:json_annotation/json_annotation.dart';

enum SortType {
@JsonValue('latest')
latest('최신순'),

@JsonValue('like')
like('좋아요순'),

@JsonValue('oldest')
oldest('오래된순'),

@JsonValue('popular')
popular('인기순');

final String typeName;

const SortType(this.typeName);
final String displayName;
const SortType(this.displayName);

static List<SortType> get profileFeedSortValues => [latest, like, oldest];
static List<SortType> get searchFeedSortValues => [latest, popular];

String toJson() => name;
}
24 changes: 17 additions & 7 deletions lib/app/enum/subscription_type.enum.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:json_annotation/json_annotation.dart';

enum SubscriptionType {
@JsonValue('FOLLOW')
follow,
follow('FOLLOW'),

@JsonValue('FEED_LIKE')
feedLike,
feedLike('FEED_LIKE'),

@JsonValue('FEED_COMMENT')
feedComment,
feedComment('FEED_COMMENT'),

@JsonValue('FEED_REPLY')
feedReply,
feedReply('FEED_REPLY'),

@JsonValue('POST_COMMENT')
postComment,
postComment('POST_COMMENT'),

@JsonValue('POST_REPLY')
postReply,
postReply('POST_REPLY');

final String jsonKey;
const SubscriptionType(this.jsonKey);

String toJson() => jsonKey;
}
4 changes: 2 additions & 2 deletions lib/app/extension/build_context_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ extension BuildContextExtension on BuildContext {
}

/// 가로상으로 표시해야 할 사용자 피드에 대한 아이템의 최대 개수를 반환합니다.
int get authorFeedRowCount {
return feedRowCount + 1;
int get userRowCount {
return (feedRowCount / 2).toInt();
}

/// 가로상으로 표시해야 할 이미지 카드에 대한 아이템의 최대 개수를 반환합니다.
Expand Down
3 changes: 1 addition & 2 deletions lib/data/data_source/remote/feed_api.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:dio/dio.dart' hide Headers;
import 'package:grimity/app/enum/sort_type.enum.dart';
import 'package:grimity/data/model/common/id_response.dart';
import 'package:grimity/data/model/feed/feed_detail_response.dart';
import 'package:grimity/data/model/feed/feed_rankings_response.dart';
Expand Down Expand Up @@ -29,7 +28,7 @@ abstract class FeedAPI {
@Query('cursor') String? cursor,
@Query('size') int? size,
@Query('keyword') String keyword,
@Query('sort') SortType sort,
@Query('sort') String sort,
);

@GET('/feeds/latest')
Expand Down
2 changes: 1 addition & 1 deletion lib/data/repository_impl/feed_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class FeedRepositoryImpl extends FeedRepository {
request.cursor,
request.size,
request.keyword,
request.sort,
request.sort.name,
);
return Result.success(response.toEntity());
} on Exception catch (e) {
Expand Down
7 changes: 6 additions & 1 deletion lib/domain/repository/post_repository.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ abstract class PostRepository {

Future<Result<void>> updatePost(String id, CreatePostRequest request);

Future<Result<Posts>> searchPosts(int page, int size, String keyword, SearchType searchBy);
Future<Result<Posts>> searchPosts(
int page,
int size,
String keyword,
SearchType searchBy,
);

Future<Result<Post>> getPostDetail(String id);

Expand Down
14 changes: 12 additions & 2 deletions lib/domain/usecase/post/search_posts_usecase.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ class SearchPostsUseCase extends UseCase<SearchPostsRequestParam, Result<Posts>>

@override
Future<Result<Posts>> execute(SearchPostsRequestParam request) async {
return await _postRepository.searchPosts(request.page, request.size, request.keyword, request.searchBy);
return await _postRepository.searchPosts(
request.page,
request.size,
request.keyword,
request.searchBy,
);
}
}

Expand All @@ -23,5 +28,10 @@ class SearchPostsRequestParam {
final String keyword;
final SearchType searchBy;

SearchPostsRequestParam({required this.page, required this.size, required this.keyword, required this.searchBy});
SearchPostsRequestParam({
required this.page,
required this.size,
required this.keyword,
required this.searchBy,
});
}
79 changes: 0 additions & 79 deletions lib/presentation/board/view/board_list_view.dart

This file was deleted.

28 changes: 20 additions & 8 deletions lib/presentation/board/view/board_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:gds/gds.dart';
import 'package:grimity/app/enum/post_type.enum.dart';
import 'package:grimity/domain/entity/post.dart';
import 'package:grimity/presentation/board/provider/board_notice_data_provider.dart';
import 'package:grimity/presentation/board/provider/board_post_data_provider.dart';
import 'package:grimity/presentation/board/view/board_list_view.dart';
import 'package:grimity/presentation/board/provider/board_search_query_provider.dart';
import 'package:grimity/presentation/board/widget/board_search_header.dart';
import 'package:grimity/presentation/board/widget/board_tab_header.dart';
import 'package:grimity/presentation/board/widget/board_title_header.dart';
import 'package:grimity/presentation/common/widget/grimity_refresh_indicator.dart';
import 'package:grimity/presentation/common/widget/grimity_state_view.dart';
import 'package:grimity/presentation/common/widget/system/board/grimity_post_view.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:skeletonizer/skeletonizer.dart';

Expand Down Expand Up @@ -103,36 +105,46 @@ class BoardView extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final scrollController = useScrollController();
final type = useState(tabList.first);
Comment thread
MTtankkeo marked this conversation as resolved.

return AppBarConnection(
appBars: buildAppBars(context, type),
child: Builder(
builder: (context) {
final postAsync = ref.watch(boardPostDataProvider(type.value));
final postNotifier = ref.read(boardPostDataProvider(type.value).notifier);
final isSearching = ref.watch(searchQueryProvider).keyword.trim().length >= 2;
final noticePosts = ref.watch(boardNoticeDataProvider).value ?? [];

return postAsync.when(
data: (posts) {
return GrimityRefreshIndicator(
onRefresh: () async {
await Future.wait([ref.refresh(boardPostDataProvider(type.value).future)]);
},
child: BoardListView(
child: GrimityPostView(
posts: posts.posts,
noticePosts: !isSearching && postNotifier.currentPage == 1 ? noticePosts : [],
totalCount: posts.totalCount ?? 0,
type: type.value,
scrollController: scrollController,
currentPage: postNotifier.currentPage,
size: postNotifier.size,
showPostType: isSearching || type.value == PostType.all,
isBookMark: true,
onPageChanged: postNotifier.goToPage,
),
);
},
loading: () {
return Skeletonizer(
child: BoardListView(
child: GrimityPostView(
posts: Post.emptyList,
noticePosts: !isSearching && postNotifier.currentPage == 1 ? noticePosts : [],
totalCount: 0,
type: type.value,
scrollController: scrollController,
currentPage: postNotifier.currentPage,
size: postNotifier.size,
showPostType: isSearching || type.value == PostType.all,
isBookMark: true,
onPageChanged: postNotifier.goToPage,
),
);
},
Expand Down
Loading
Loading