Ещё доработки по курсачу
This commit is contained in:
parent
f303d8e459
commit
377897cd46
@ -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,
|
||||
);
|
||||
}
|
||||
|
@ -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<HomeData?> loadData({
|
||||
OnErrorCallback? onError,
|
||||
String? q,
|
||||
int? status,
|
||||
}) async {
|
||||
try {
|
||||
// Формирование URL для запроса
|
||||
final Response<dynamic> response = await _dio.get(_baseUrl);
|
||||
String url =
|
||||
'$_baseUrl/v1/agents?developerName=BountyHunter';
|
||||
final queryParameters = <String, dynamic>{};
|
||||
|
||||
if (q != null && q.isNotEmpty) {
|
||||
queryParameters['displayName'] = q;
|
||||
}
|
||||
|
||||
final Response<dynamic> response = await _dio.get(url, queryParameters: queryParameters);
|
||||
|
||||
// Получение данных агентов из API
|
||||
final agentsData = response.data['data'] as List<dynamic>;
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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,
|
||||
});
|
||||
}
|
||||
|
@ -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,
|
||||
)
|
||||
],
|
||||
|
@ -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),
|
||||
|
@ -83,7 +83,7 @@ class _BodyState extends State<Body> {
|
||||
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(
|
||||
|
Loading…
Reference in New Issue
Block a user