Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/search #3

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
6 changes: 6 additions & 0 deletions assets/icons/close_circle_fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions assets/icons/ticats_search_cat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions lib/app/config/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ class Router extends _$Router {
GoRoute(
path: Routes.eventListOfCategory,
name: Routes.eventListOfCategory,
builder: (context, state) => EventListOfCategoryPage(categoryName: state.uri.queryParameters['category'] as String),
builder: (context, state) => EventListOfCategoryPage(
categoryName: state.uri.queryParameters['category'] as String),
),

GoRoute(
path: Routes.eventList,
name: Routes.eventList,
builder: (context, state) => EventListPage(title: state.uri.queryParameters['title'] as String),
builder: (context, state) => EventListPage(
title: state.uri.queryParameters['title'] as String),
),

// Event Detail
Expand Down Expand Up @@ -102,7 +104,8 @@ class Router extends _$Router {
GoRoute(
path: 'select-entertainment',
name: Routes.registerSelectEntertianment,
builder: (context, state) => const RegisterSelectEntertainmentPage(),
builder: (context, state) =>
const RegisterSelectEntertainmentPage(),
),
],
),
Expand Down
1 change: 1 addition & 0 deletions lib/app/config/app_typeface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class AppTypeface {
static TextStyle get label14Bold => TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w700, height: 1.57, color: AppColor.black);
static TextStyle get label14Medium => TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w500, height: 1.57, color: AppColor.black);
static TextStyle get label14SemiBold => TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w600, height: 1.57, color: AppColor.black);
static TextStyle get label14Regular => TextStyle(fontSize: 14.sp, fontWeight: FontWeight.w400, height: 1.57, color: AppColor.black);
static TextStyle get label12Bold => TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w700, height: 1.5, color: AppColor.black);
static TextStyle get label12SemiBold => TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w600, height: 1.5, color: AppColor.black);
static TextStyle get label12Medium => TextStyle(fontSize: 12.sp, fontWeight: FontWeight.w500, height: 1.5, color: AppColor.black);
Expand Down
16 changes: 16 additions & 0 deletions lib/data/data_source/remote/cultural_event_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import 'package:retrofit/retrofit.dart';
import 'package:ticats_app/app/config/app_const.dart';
import 'package:ticats_app/data/model/cultural_event/cultural_event_model.dart';
import 'package:ticats_app/data/model/cultural_event/cultural_events_model.dart';
import 'package:ticats_app/data/model/cultural_event/popular_search_keyword_model.dart';
import 'package:ticats_app/data/model/cultural_event/recent_search_keyword_model.dart';
import 'package:ticats_app/domain/entity/cultural_event/cultural_events_search_entity.dart';

part 'cultural_event_api.g.dart';
Expand All @@ -18,4 +20,18 @@ abstract class CulturalEventAPI {

@GET("/{id}")
Future<CulturalEventModel> getCulturalEventInfo(@Path("id") String id);

@GET("/popular-keywords")
Future<List<PopularSearchKeywordModel>> getPopularSearchKeywords();

@GET("/recent-keywords")
Future<List<RecentSearchKeywordModel>> getRecentSearchKeywords();

@DELETE("/recent-keywords/{id}")
Future<void> deleteRecentSearchKeyword(@Path("id") int id);

@GET("/search")
Future<CulturalEventsModel> getSearchedCulturalEvents(
@Queries(encoded: true) CulturalEventsSearchEntity queries,
);
}
23 changes: 23 additions & 0 deletions lib/data/model/cultural_event/popular_search_keyword_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:ticats_app/domain/entity/cultural_event/popular_search_keyword_entity.dart';

part 'popular_search_keyword_model.freezed.dart';

part 'popular_search_keyword_model.g.dart';

@freezed
class PopularSearchKeywordModel with _$PopularSearchKeywordModel {
const factory PopularSearchKeywordModel({
@Default("") String keyword,
@Default(0) int ordering,
}) = _PopularSearchKeywordModel;

factory PopularSearchKeywordModel.fromJson(Map<String, Object?> json) =>
_$PopularSearchKeywordModelFromJson(json);
}

extension PopularSearchKeywordModelX on PopularSearchKeywordModel {
PopularSearchKeywordEntity toEntity() {
return PopularSearchKeywordEntity(keyword: keyword, ordering: ordering);
}
}
24 changes: 24 additions & 0 deletions lib/data/model/cultural_event/recent_search_keyword_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:ticats_app/domain/entity/cultural_event/recent_search_keyword_entity.dart';

part 'recent_search_keyword_model.freezed.dart';

part 'recent_search_keyword_model.g.dart';

@freezed
class RecentSearchKeywordModel with _$RecentSearchKeywordModel {
const factory RecentSearchKeywordModel({
required int id,
@Default("") String keyword,
@Default(0) int ordering,
}) = _RecentSearchKeywordModel;

factory RecentSearchKeywordModel.fromJson(Map<String, Object?> json) =>
_$RecentSearchKeywordModelFromJson(json);
}

extension RecentSearchKeywordModelX on RecentSearchKeywordModel {
RecentSearchKeywordEntity toEntity() {
return RecentSearchKeywordEntity(id: id, keyword: keyword, ordering: ordering);
}
}
49 changes: 39 additions & 10 deletions lib/data/repository_impl/cultural_event_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@ import 'package:ticats_app/app/network/dio_provider.dart';
import 'package:ticats_app/data/data_source/remote/cultural_event_api.dart';
import 'package:ticats_app/data/model/cultural_event/cultural_event_model.dart';
import 'package:ticats_app/data/model/cultural_event/cultural_events_model.dart';
import 'package:ticats_app/data/model/cultural_event/popular_search_keyword_model.dart';
import 'package:ticats_app/data/model/cultural_event/recent_search_keyword_model.dart';
import 'package:ticats_app/domain/entity/cultural_event/cultural_event_entity.dart';
import 'package:ticats_app/domain/entity/cultural_event/cultural_events_search_entity.dart';
import 'package:ticats_app/domain/entity/cultural_event/popular_search_keyword_entity.dart';
import 'package:ticats_app/domain/entity/cultural_event/recent_search_keyword_entity.dart';
import 'package:ticats_app/domain/repository/cultural_event_repository.dart';

part 'cultural_event_repository_impl.g.dart';
Expand All @@ -22,38 +26,63 @@ class CulturalEventRepositoryImpl implements CulturalEventRepository {
}

@override
Future<List<CulturalEventEntity>> getCulturalEvents(CulturalEventsSearchEntity queries) async {
Future<List<CulturalEventEntity>> getCulturalEvents(
CulturalEventsSearchEntity queries) async {
CulturalEventsModel response = await _api.getCulturalEvents(queries);
return response.toEntityList();
}

@override
Future<List<CulturalEventEntity>> getOpenDateEvents(CulturalEventsSearchEntity queries) async {
queries = queries.copyWith(isOpened: false, ordering: TicatsEventOrdering.ticketOpenDate);
Future<List<CulturalEventEntity>> getOpenDateEvents(
CulturalEventsSearchEntity queries) async {
queries = queries.copyWith(
isOpened: false, ordering: TicatsEventOrdering.ticketOpenDate);

CulturalEventsModel response = await _api.getCulturalEvents(queries);
return response.toEntityList();
}

@override
Future<List<CulturalEventEntity>> getPointEvents(CulturalEventsSearchEntity quries) async {
quries = quries.copyWith(ordering: TicatsEventOrdering.point);
Future<List<CulturalEventEntity>> getPointEvents(
CulturalEventsSearchEntity queries) async {
queries = queries.copyWith(ordering: TicatsEventOrdering.point);

CulturalEventsModel response = await _api.getCulturalEvents(quries);
CulturalEventsModel response = await _api.getCulturalEvents(queries);
return response.toEntityList();
}

@override
Future<List<CulturalEventEntity>> getRecommendEvents(CulturalEventsSearchEntity quries) async {
quries = quries.copyWith(ordering: TicatsEventOrdering.recommend);
Future<List<CulturalEventEntity>> getRecommendEvents(
CulturalEventsSearchEntity queries) async {
queries = queries.copyWith(ordering: TicatsEventOrdering.recommend);

CulturalEventsModel response = await _api.getCulturalEvents(quries);
CulturalEventsModel response = await _api.getCulturalEvents(queries);
return response.toEntityList();
}

@override
Future<List<PopularSearchKeywordEntity>> getPopularSearchKeywords() async {
List<PopularSearchKeywordModel> response =
await _api.getPopularSearchKeywords();
return response.map((e) => e.toEntity()).toList();
}

@override
Future<List<RecentSearchKeywordEntity>> getRecentSearchKeywords() async {
List<RecentSearchKeywordModel> response =
await _api.getRecentSearchKeywords();
return response.map((e) => e.toEntity()).toList();
}

@override
Future<void> deleteRecentSearchKeyword(int id) async {
await _api.deleteRecentSearchKeyword(id);
}
}

@riverpod
CulturalEventRepository culturalEventRepository(CulturalEventRepositoryRef ref) {
CulturalEventRepository culturalEventRepository(
CulturalEventRepositoryRef ref) {
final api = CulturalEventAPI(ref.read(dioProvider));

return CulturalEventRepositoryImpl(api: api);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'popular_search_keyword_entity.freezed.dart';
part 'popular_search_keyword_entity.g.dart';

@freezed
class PopularSearchKeywordEntity with _$PopularSearchKeywordEntity {
const factory PopularSearchKeywordEntity({
@Default("") String keyword,
@Default(0) int ordering,
}) = _PopularSearchKeywordEntity;

factory PopularSearchKeywordEntity.fromJson(Map<String, Object?> json) => _$PopularSearchKeywordEntityFromJson(json);
}

16 changes: 16 additions & 0 deletions lib/domain/entity/cultural_event/recent_search_keyword_entity.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'recent_search_keyword_entity.freezed.dart';

part 'recent_search_keyword_entity.g.dart';

@freezed
class RecentSearchKeywordEntity with _$RecentSearchKeywordEntity {
const factory RecentSearchKeywordEntity({
required int id,
@Default("") String keyword,
@Default(0) int ordering,
}) = _RecentSearchKeywordEntity;

factory RecentSearchKeywordEntity.fromJson(Map<String, Object?> json) => _$RecentSearchKeywordEntityFromJson(json);
}
17 changes: 13 additions & 4 deletions lib/domain/repository/cultural_event_repository.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import 'package:ticats_app/domain/entity/cultural_event/cultural_event_entity.dart';
import 'package:ticats_app/domain/entity/cultural_event/cultural_events_search_entity.dart';
import 'package:ticats_app/domain/entity/cultural_event/popular_search_keyword_entity.dart';
import 'package:ticats_app/domain/entity/cultural_event/recent_search_keyword_entity.dart';

abstract class CulturalEventRepository {
Future<CulturalEventEntity> getCulturalEventInfo(String id);
Future<List<CulturalEventEntity>> getCulturalEvents(CulturalEventsSearchEntity request);
Future<List<CulturalEventEntity>> getRecommendEvents(CulturalEventsSearchEntity request);
Future<List<CulturalEventEntity>> getPointEvents(CulturalEventsSearchEntity request);
Future<List<CulturalEventEntity>> getOpenDateEvents(CulturalEventsSearchEntity request);
Future<List<CulturalEventEntity>> getCulturalEvents(
CulturalEventsSearchEntity request);
Future<List<CulturalEventEntity>> getRecommendEvents(
CulturalEventsSearchEntity request);
Future<List<CulturalEventEntity>> getPointEvents(
CulturalEventsSearchEntity request);
Future<List<CulturalEventEntity>> getOpenDateEvents(
CulturalEventsSearchEntity request);
Future<List<RecentSearchKeywordEntity>> getRecentSearchKeywords();
Future<void> deleteRecentSearchKeyword(int id);
Future<List<PopularSearchKeywordEntity>> getPopularSearchKeywords();
}
Loading