беда беда
This commit is contained in:
parent
0fad387e57
commit
170b30e889
@ -1,4 +1,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<application
|
||||
android:label="project1"
|
||||
android:name="${applicationName}"
|
||||
|
@ -15,7 +15,7 @@ class FilmsRepository {
|
||||
));
|
||||
|
||||
static const String _baseUrl = 'https://kinopoiskapiunofficial.tech';
|
||||
static const String _apiKey = 'e6b9a002-9956-465d-af28-a4afa34d7c5d';
|
||||
static const String _apiKey = '67c830e4-b979-48ba-903d-a00c8f96fd4b';
|
||||
|
||||
Future<HomeData?> loadData({
|
||||
OnErrorCallback? onError,
|
||||
@ -37,10 +37,12 @@ class FilmsRepository {
|
||||
|
||||
for (final month in months) {
|
||||
final Response<dynamic> response =
|
||||
await _dio.get<Map<dynamic, dynamic>>(
|
||||
await _dio.get<Map<dynamic, dynamic>>(
|
||||
url,
|
||||
queryParameters: {
|
||||
'year': DateTime.now().year,
|
||||
'year': DateTime
|
||||
.now()
|
||||
.year,
|
||||
'month': month,
|
||||
'keyword': q,
|
||||
'page': page,
|
||||
@ -56,9 +58,9 @@ class FilmsRepository {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final FilmsDto dto =
|
||||
FilmsDto.fromJson(response.data as Map<String, dynamic>);
|
||||
FilmsDto.fromJson(response.data as Map<String, dynamic>);
|
||||
final SearchDto dtos =
|
||||
SearchDto.fromJson(response.data as Map<String, dynamic>);
|
||||
SearchDto.fromJson(response.data as Map<String, dynamic>);
|
||||
|
||||
/*if (dto.items != null) {
|
||||
dto.items = dto.films;
|
||||
@ -78,12 +80,23 @@ class FilmsRepository {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
final HomeData data = HomeData(
|
||||
data: allFilms.map((e) => e.toDomain()).toList(),
|
||||
nextPage: page + 1, // Увеличиваем номер страницы для следующего запроса
|
||||
);
|
||||
if (q != null) {
|
||||
final HomeData data = HomeData(
|
||||
data: someFilms.map((e) => e.toDomain()).toList(),
|
||||
nextPage: page +
|
||||
1, // Увеличиваем номер страницы для следующего запроса
|
||||
);
|
||||
|
||||
return data;
|
||||
return data;
|
||||
}
|
||||
else {
|
||||
final HomeData data = HomeData(
|
||||
data: allFilms.map((e) => e.toDomain()).toList(),
|
||||
nextPage: page +
|
||||
1, // Увеличиваем номер страницы для следующего запроса
|
||||
);
|
||||
return data;
|
||||
}
|
||||
} on DioException catch (e) {
|
||||
onError?.call(e.error?.toString());
|
||||
return null;
|
||||
@ -108,7 +121,7 @@ class FilmsRepository {
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final FilmDataDto dto =
|
||||
FilmDataDto.fromJson(response.data as Map<String, dynamic>);
|
||||
FilmDataDto.fromJson(response.data as Map<String, dynamic>);
|
||||
return dto;
|
||||
} else {
|
||||
print('Request failed with status: ${response.statusCode}');
|
||||
|
Loading…
Reference in New Issue
Block a user