diff --git a/lib/data/dtos/news_dto.dart b/lib/data/dtos/news_dto.dart index 79f885c..5115185 100644 --- a/lib/data/dtos/news_dto.dart +++ b/lib/data/dtos/news_dto.dart @@ -2,20 +2,12 @@ import 'package:json_annotation/json_annotation.dart'; part 'news_dto.g.dart'; @JsonSerializable(createToJson: false) class NewsDto{ - final List? data; + @JsonKey(name: 'Главное') + final List? data; const NewsDto({this.data}); factory NewsDto.fromJson(Map json) => _$NewsDtoFromJson(json); } -@JsonSerializable(createToJson: false) -class NewDataDto{ - final String? id; - final String? type; - final NewAttributesDataDto? attributes; - const NewDataDto({this.id, this.type, this.attributes}); - - factory NewDataDto.fromJson(Map json) => _$NewDataDtoFromJson(json); -} @JsonSerializable(createToJson: false) class NewAttributesDataDto{ @@ -26,5 +18,4 @@ class NewAttributesDataDto{ const NewAttributesDataDto({this.title, this.summary, this.imagelink }); factory NewAttributesDataDto.fromJson(Map json) => _$NewAttributesDataDtoFromJson(json); - } \ No newline at end of file diff --git a/lib/data/dtos/news_dto.g.dart b/lib/data/dtos/news_dto.g.dart index 96aa89a..adca9de 100644 --- a/lib/data/dtos/news_dto.g.dart +++ b/lib/data/dtos/news_dto.g.dart @@ -7,19 +7,11 @@ part of 'news_dto.dart'; // ************************************************************************** NewsDto _$NewsDtoFromJson(Map json) => NewsDto( - data: (json['data'] as List?) - ?.map((e) => NewDataDto.fromJson(e as Map)) + data: (json['Главное'] as List?) + ?.map((e) => NewAttributesDataDto.fromJson(e as Map)) .toList(), ); -NewDataDto _$NewDataDtoFromJson(Map json) => NewDataDto( - id: json['id'] as String?, - type: json['type'] as String?, - attributes: json['attributes'] == null - ? null - : NewAttributesDataDto.fromJson( - json['attributes'] as Map), - ); NewAttributesDataDto _$NewAttributesDataDtoFromJson( Map json) => diff --git a/lib/data/mappers/news_mapper.dart b/lib/data/mappers/news_mapper.dart index d2e2e9c..af04f92 100644 --- a/lib/data/mappers/news_mapper.dart +++ b/lib/data/mappers/news_mapper.dart @@ -1,10 +1,10 @@ import 'package:pmu/data/dtos/news_dto.dart'; import 'package:pmu/domain/models/card.dart'; -extension NewDataDtoToModel on NewDataDto{ +extension NewDataDtoToModel on NewAttributesDataDto{ CardData toDomain() => CardData( - text: attributes?.title ?? 'UNKNOWN', - imageUrl: attributes?.imagelink, - descText: attributes?.summary ?? 'NOTHING', + text: title ?? 'UNKNOWN', + imageUrl: imagelink, + descText: summary ?? 'NOTHING', ); } \ No newline at end of file diff --git a/lib/data/repositories/bbc_repository.dart b/lib/data/repositories/bbc_repository.dart index 5fb8b35..40eb888 100644 --- a/lib/data/repositories/bbc_repository.dart +++ b/lib/data/repositories/bbc_repository.dart @@ -20,7 +20,7 @@ class BbcRepository extends ApiInterface { const String url = '$_baseUrl/news?lang=russian'; final Response response = await _dio.get>( url, - // queryParameters: q != null ? {'filter[name_cont]': q} : null, + //queryParameters: q != null ? {'filter[name_cont]': q} : null, ); final NewsDto dto = NewsDto.fromJson(response.data as Map); diff --git a/lib/presentation/details_page/details_page.dart b/lib/presentation/details_page/details_page.dart index 1669ea2..539b18f 100644 --- a/lib/presentation/details_page/details_page.dart +++ b/lib/presentation/details_page/details_page.dart @@ -29,12 +29,15 @@ class DetailsPage extends StatelessWidget { Padding( padding: const EdgeInsets.only( bottom: 16.0, top: 8.0, left: 8.0, right: 8.0), - child: ClipRRect( - borderRadius: BorderRadius.circular(10.0), - child: Image.network( - data.imageUrl ?? '', - fit: BoxFit.cover, - ))), + child: SizedBox( + width: double.infinity, + child: ClipRRect( + borderRadius: BorderRadius.circular(10.0), + child: Image.network( + data.imageUrl ?? '', + fit: BoxFit.cover, + )), + )), Padding( padding: const EdgeInsets.only( bottom: 4.0, top: 8.0, left: 8.0, right: 8.0),