Ещё доработки по курсачу
This commit is contained in:
parent
f303d8e459
commit
377897cd46
@ -6,8 +6,8 @@ extension CharacterDtoToModel on CharacterDto {
|
|||||||
CardData toDomain() => CardData(
|
CardData toDomain() => CardData(
|
||||||
displayName ?? 'UNKNOWN',
|
displayName ?? 'UNKNOWN',
|
||||||
uuid: uuid ?? 'UNKNOWN',
|
uuid: uuid ?? 'UNKNOWN',
|
||||||
descriptionText: developerName ?? 'Описание отсутствует',
|
developerName: developerName ?? 'Описание отсутствует',
|
||||||
gameDesc: description,
|
description: description,
|
||||||
imageUrl: displayIcon,
|
imageUrl: displayIcon,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,25 @@ class AgentsRepository extends ApiInterface {
|
|||||||
requestBody: true,
|
requestBody: true,
|
||||||
));
|
));
|
||||||
|
|
||||||
static const String _baseUrl = 'https://valorant-api.com/v1/agents';
|
static const String _baseUrl = 'https://valorant-api.com';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<HomeData?> loadData({
|
Future<HomeData?> loadData({
|
||||||
OnErrorCallback? onError,
|
OnErrorCallback? onError,
|
||||||
String? q,
|
String? q,
|
||||||
|
int? status,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
// Формирование URL для запроса
|
// Формирование 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
|
// Получение данных агентов из API
|
||||||
final agentsData = response.data['data'] as List<dynamic>;
|
final agentsData = response.data['data'] as List<dynamic>;
|
||||||
@ -35,7 +44,7 @@ class AgentsRepository extends ApiInterface {
|
|||||||
// Фильтрация данных по displayName
|
// Фильтрация данных по displayName
|
||||||
if (q != null && q.isNotEmpty) {
|
if (q != null && q.isNotEmpty) {
|
||||||
final filteredData = data.data
|
final filteredData = data.data
|
||||||
?.where((agent) => agent.text?.toLowerCase().contains(q.toLowerCase()) ?? false)
|
?.where((agent) => agent.displayName?.toLowerCase().contains(q.toLowerCase()) ?? false)
|
||||||
.toList();
|
.toList();
|
||||||
data = HomeData(data: filteredData);
|
data = HomeData(data: filteredData);
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class CardData {
|
class CardData {
|
||||||
final String? text;
|
final String? displayName;
|
||||||
final String? descriptionText;
|
final String? developerName;
|
||||||
//final IconData icon;
|
//final IconData icon;
|
||||||
final String? imageUrl;
|
final String? imageUrl;
|
||||||
final String? gameDesc;
|
final String? description;
|
||||||
late final String uuid;
|
late final String uuid;
|
||||||
|
|
||||||
CardData(
|
CardData(
|
||||||
this.text, {
|
this.displayName, {
|
||||||
required this.descriptionText,
|
required this.developerName,
|
||||||
this.imageUrl,
|
this.imageUrl,
|
||||||
required this.gameDesc,
|
required this.description,
|
||||||
required this.uuid,
|
required this.uuid,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -29,12 +29,12 @@ class DetailsPage extends StatelessWidget {
|
|||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(bottom: 4.0),
|
padding: const EdgeInsets.only(bottom: 4.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
data.text!,
|
data.displayName!,
|
||||||
style: Theme.of(context).textTheme.headlineLarge,
|
style: Theme.of(context).textTheme.headlineLarge,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
data.gameDesc!,
|
data.description!,
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
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); //сделано от дублирования кода
|
typedef OnLikeCallback = void Function(String? id, String title, bool isLiked); //сделано от дублирования кода
|
||||||
|
|
||||||
class _Card extends StatelessWidget {
|
class _Card extends StatelessWidget {
|
||||||
final String text;
|
final String displayName;
|
||||||
final String descriptionText;
|
final String developerName;
|
||||||
//final IconData icon;
|
//final IconData icon;
|
||||||
final String? imageUrl;
|
final String? imageUrl;
|
||||||
final OnLikeCallback? onLike;
|
final OnLikeCallback? onLike;
|
||||||
@ -13,9 +13,9 @@ class _Card extends StatelessWidget {
|
|||||||
final bool isLiked;
|
final bool isLiked;
|
||||||
|
|
||||||
const _Card(
|
const _Card(
|
||||||
this.text, {
|
this.displayName, {
|
||||||
//this.icon = Icons.ac_unit_outlined,
|
//this.icon = Icons.ac_unit_outlined,
|
||||||
required this.descriptionText,
|
required this.developerName,
|
||||||
this.imageUrl,
|
this.imageUrl,
|
||||||
this.onLike,
|
this.onLike,
|
||||||
this.onTap,
|
this.onTap,
|
||||||
@ -31,8 +31,8 @@ class _Card extends StatelessWidget {
|
|||||||
}) =>
|
}) =>
|
||||||
_Card(
|
_Card(
|
||||||
uuid: data.uuid,
|
uuid: data.uuid,
|
||||||
data.text!,
|
data.displayName!,
|
||||||
descriptionText: data.descriptionText!,
|
developerName: data.developerName!,
|
||||||
imageUrl: data.imageUrl,
|
imageUrl: data.imageUrl,
|
||||||
onLike: onLike,
|
onLike: onLike,
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
@ -78,25 +78,7 @@ class _Card extends StatelessWidget {
|
|||||||
errorBuilder: (_, __, ___) => const Placeholder(),
|
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,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
text,
|
displayName,
|
||||||
style: Theme
|
style: Theme
|
||||||
.of(context)
|
.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
.titleLarge,
|
.titleLarge,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
descriptionText,
|
developerName,
|
||||||
style: Theme
|
style: Theme
|
||||||
.of(context)
|
.of(context)
|
||||||
.textTheme
|
.textTheme
|
||||||
@ -134,7 +116,7 @@ class _Card extends StatelessWidget {
|
|||||||
bottom: 16,
|
bottom: 16,
|
||||||
),
|
),
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTap: () => onLike?.call(uuid, text, isLiked),
|
onTap: () => onLike?.call(uuid, displayName, isLiked),
|
||||||
child: AnimatedSwitcher(
|
child: AnimatedSwitcher(
|
||||||
// Анимация для наших лайков
|
// Анимация для наших лайков
|
||||||
duration: const Duration(milliseconds: 300),
|
duration: const Duration(milliseconds: 300),
|
||||||
|
@ -83,7 +83,7 @@ class _BodyState extends State<Body> {
|
|||||||
if (dataList == null || dataList.isEmpty) return;
|
if (dataList == null || dataList.isEmpty) return;
|
||||||
|
|
||||||
final index =
|
final index =
|
||||||
dataList.indexWhere((data) => data.text?.toLowerCase() == searchQuery.toLowerCase());
|
dataList.indexWhere((data) => data.displayName?.toLowerCase() == searchQuery.toLowerCase());
|
||||||
|
|
||||||
if (index != -1) {
|
if (index != -1) {
|
||||||
_scrollController.animateTo(
|
_scrollController.animateTo(
|
||||||
|
Loading…
Reference in New Issue
Block a user