-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from andannn/search_feature
Search feature
- Loading branch information
Showing
53 changed files
with
1,126 additions
and
266 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
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
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
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
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,39 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:anime_tracker/core/common/util/load_page_util.dart'; | ||
import 'package:anime_tracker/core/data/load_result.dart'; | ||
import 'package:anime_tracker/core/data/model/anime_model.dart'; | ||
import 'package:anime_tracker/core/database/anime_database.dart'; | ||
import 'package:anime_tracker/core/database/dao/anime_dao.dart'; | ||
import 'package:anime_tracker/core/database/model/anime_entity.dart'; | ||
import 'package:anime_tracker/core/network/ani_list_data_source.dart'; | ||
import 'package:anime_tracker/core/network/model/anime_dto.dart'; | ||
|
||
abstract class SearchRepository { | ||
Future<LoadResult<List<AnimeModel>>> loadMediaSearchResultByPage( | ||
{required int page, required int perPage, required String search}); | ||
} | ||
|
||
class SearchRepositoryImpl implements SearchRepository { | ||
final AniListDataSource dataSource = AniListDataSource(); | ||
final AnimeListDao dao = AnimeDatabase().getAnimeDao(); | ||
|
||
@override | ||
Future<LoadResult<List<AnimeModel>>> loadMediaSearchResultByPage( | ||
{required int page, required int perPage, required String search}) { | ||
return LoadPageUtil.loadPageWithoutDBCache<AnimeDto, AnimeModel>( | ||
page: page, | ||
perPage: perPage, | ||
onGetNetworkRes: (int page, int perPage) => dataSource.searchAnimePage( | ||
page: page, | ||
perPage: perPage, | ||
search: search, | ||
), | ||
mapDtoToModel: (AnimeDto dto) => AnimeModel.fromDto(dto), | ||
onInsertEntityToDB: (List<AnimeDto> dto) async { | ||
final entities = dto.map((e) => AnimeEntity.fromNetworkModel(e)).toList(); | ||
await dao.upsertAnimeInformation(entities); | ||
}, | ||
); | ||
} | ||
} |
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
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
lib/core/database/anime_track_list_dao.dart → ...re/database/dao/anime_track_list_dao.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
File renamed without changes.
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
Oops, something went wrong.