diff --git a/lib/data/mappers/characters_mapper.dart b/lib/data/mappers/characters_mapper.dart index c29edfc..06b55dc 100644 --- a/lib/data/mappers/characters_mapper.dart +++ b/lib/data/mappers/characters_mapper.dart @@ -6,8 +6,8 @@ extension CharacterDtoToModel on CharacterDto { CardData toDomain() => CardData( displayName ?? 'UNKNOWN', uuid: uuid ?? 'UNKNOWN', - descriptionText: developerName ?? 'Описание отсутствует', - gameDesc: description, + developerName: developerName ?? 'Описание отсутствует', + description: description, imageUrl: displayIcon, ); } diff --git a/lib/data/repositories/characters_repository.dart b/lib/data/repositories/characters_repository.dart index fbe1d9d..0e0df59 100644 --- a/lib/data/repositories/characters_repository.dart +++ b/lib/data/repositories/characters_repository.dart @@ -14,16 +14,25 @@ class AgentsRepository extends ApiInterface { requestBody: true, )); - static const String _baseUrl = 'https://valorant-api.com/v1/agents'; + static const String _baseUrl = 'https://valorant-api.com'; @override Future loadData({ OnErrorCallback? onError, String? q, + int? status, }) async { try { // Формирование URL для запроса - final Response response = await _dio.get(_baseUrl); + String url = + '$_baseUrl/v1/agents?developerName=BountyHunter'; + final queryParameters = {}; + + if (q != null && q.isNotEmpty) { + queryParameters['displayName'] = q; + } + + final Response response = await _dio.get(url, queryParameters: queryParameters); // Получение данных агентов из API final agentsData = response.data['data'] as List; @@ -35,7 +44,7 @@ class AgentsRepository extends ApiInterface { // Фильтрация данных по displayName if (q != null && q.isNotEmpty) { final filteredData = data.data - ?.where((agent) => agent.text?.toLowerCase().contains(q.toLowerCase()) ?? false) + ?.where((agent) => agent.displayName?.toLowerCase().contains(q.toLowerCase()) ?? false) .toList(); data = HomeData(data: filteredData); } diff --git a/lib/domain/models/card.dart b/lib/domain/models/card.dart index 27c9721..853cc09 100644 --- a/lib/domain/models/card.dart +++ b/lib/domain/models/card.dart @@ -1,18 +1,18 @@ import 'package:flutter/material.dart'; class CardData { - final String? text; - final String? descriptionText; + final String? displayName; + final String? developerName; //final IconData icon; final String? imageUrl; - final String? gameDesc; + final String? description; late final String uuid; CardData( - this.text, { - required this.descriptionText, + this.displayName, { + required this.developerName, this.imageUrl, - required this.gameDesc, + required this.description, required this.uuid, }); } diff --git a/lib/presentation/details_page/details_page.dart b/lib/presentation/details_page/details_page.dart index d2df418..1776715 100644 --- a/lib/presentation/details_page/details_page.dart +++ b/lib/presentation/details_page/details_page.dart @@ -29,12 +29,12 @@ class DetailsPage extends StatelessWidget { Padding( padding: const EdgeInsets.only(bottom: 4.0), child: Text( - data.text!, + data.displayName!, style: Theme.of(context).textTheme.headlineLarge, ), ), Text( - data.gameDesc!, + data.description!, style: Theme.of(context).textTheme.bodyLarge, ) ], diff --git a/lib/presentation/home_page/card.dart b/lib/presentation/home_page/card.dart index 02a1768..13d5fd7 100644 --- a/lib/presentation/home_page/card.dart +++ b/lib/presentation/home_page/card.dart @@ -3,8 +3,8 @@ part of 'home_page.dart'; typedef OnLikeCallback = void Function(String? id, String title, bool isLiked); //сделано от дублирования кода class _Card extends StatelessWidget { - final String text; - final String descriptionText; + final String displayName; + final String developerName; //final IconData icon; final String? imageUrl; final OnLikeCallback? onLike; @@ -13,9 +13,9 @@ class _Card extends StatelessWidget { final bool isLiked; const _Card( - this.text, { + this.displayName, { //this.icon = Icons.ac_unit_outlined, - required this.descriptionText, + required this.developerName, this.imageUrl, this.onLike, this.onTap, @@ -31,8 +31,8 @@ class _Card extends StatelessWidget { }) => _Card( uuid: data.uuid, - data.text!, - descriptionText: data.descriptionText!, + data.displayName!, + developerName: data.developerName!, imageUrl: data.imageUrl, onLike: onLike, onTap: onTap, @@ -78,25 +78,7 @@ class _Card extends StatelessWidget { errorBuilder: (_, __, ___) => const Placeholder(), ), ), - Align( - alignment: Alignment.bottomLeft, - child: Container( - decoration: const BoxDecoration( - color: Colors.purpleAccent, - borderRadius: BorderRadius.only( - bottomRight: Radius.circular(20), - ), - ), - padding: const EdgeInsets.fromLTRB(8, 2, 8, 2), - child: Text( - 'New!!!!', - style: Theme.of(context) - .textTheme - .bodyMedium - ?.copyWith(color: Colors.black), - ), - ), - ) + ], ), ), @@ -108,14 +90,14 @@ class _Card extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - text, + displayName, style: Theme .of(context) .textTheme .titleLarge, ), Text( - descriptionText, + developerName, style: Theme .of(context) .textTheme @@ -134,7 +116,7 @@ class _Card extends StatelessWidget { bottom: 16, ), child: GestureDetector( - onTap: () => onLike?.call(uuid, text, isLiked), + onTap: () => onLike?.call(uuid, displayName, isLiked), child: AnimatedSwitcher( // Анимация для наших лайков duration: const Duration(milliseconds: 300), diff --git a/lib/presentation/home_page/home_page.dart b/lib/presentation/home_page/home_page.dart index fd279b5..3234ea7 100644 --- a/lib/presentation/home_page/home_page.dart +++ b/lib/presentation/home_page/home_page.dart @@ -83,7 +83,7 @@ class _BodyState extends State { if (dataList == null || dataList.isEmpty) return; final index = - dataList.indexWhere((data) => data.text?.toLowerCase() == searchQuery.toLowerCase()); + dataList.indexWhere((data) => data.displayName?.toLowerCase() == searchQuery.toLowerCase()); if (index != -1) { _scrollController.animateTo(