From 170b30e889d1acf393fbe2f299468f6e1e23bd04 Mon Sep 17 00:00:00 2001 From: bulatova_karina Date: Wed, 27 Nov 2024 15:02:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B1=D0=B5=D0=B4=D0=B0=20=D0=B1=D0=B5=D0=B4?= =?UTF-8?q?=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/src/main/AndroidManifest.xml | 2 ++ lib/data/repositories/films_repository.dart | 35 ++++++++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index e5b738a..2ddddc6 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,6 @@ + + loadData({ OnErrorCallback? onError, @@ -37,10 +37,12 @@ class FilmsRepository { for (final month in months) { final Response response = - await _dio.get>( + await _dio.get>( 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); + FilmsDto.fromJson(response.data as Map); final SearchDto dtos = - SearchDto.fromJson(response.data as Map); + SearchDto.fromJson(response.data as Map); /*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); + FilmDataDto.fromJson(response.data as Map); return dto; } else { print('Request failed with status: ${response.statusCode}');