diff --git a/lib.zip b/lib.zip new file mode 100644 index 0000000..50d883b Binary files /dev/null and b/lib.zip differ diff --git a/lib/data/dtos/car_dto.g.dart b/lib/data/dtos/car_dto.g.dart new file mode 100644 index 0000000..8f6d12e --- /dev/null +++ b/lib/data/dtos/car_dto.g.dart @@ -0,0 +1,25 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'car_dto.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +CarDto _$CarDtoFromJson(Map json) => CarDto( + count: (json['Count'] as num?)?.toInt(), + message: json['Message'] as String?, + searchCriteria: json['SearchCriteria'] as String?, + results: (json['Results'] as List?) + ?.map( + (e) => CarAttributesResultDto.fromJson(e as Map)) + .toList(), + ); + +CarAttributesResultDto _$CarAttributesResultDtoFromJson( + Map json) => + CarAttributesResultDto( + modelID: (json['Model_ID'] as num?)?.toInt(), + makeName: json['Make_Name'] as String?, + modelName: json['Model_Name'] as String?, + ); diff --git a/lib/data/repositories/car_repository.dart b/lib/data/repositories/car_repository.dart index 36dd3f3..6b0ead3 100644 --- a/lib/data/repositories/car_repository.dart +++ b/lib/data/repositories/car_repository.dart @@ -21,7 +21,10 @@ class CarRepository extends ApiInterface { const String url = '$_baseUrl/GetModelsForMakeYear/make/honda/modelyear/1990?format=json'; const String searchurl = '$_baseUrl/GetModelsForMakeYear/make/[name_count]/modelyear/1990?format=json'; - final String finalUrl = q != null ? searchurl.replaceFirst('[name_count]', q) : url; + final String finalUrl = q != null && q.trim().isNotEmpty + ? searchurl.replaceFirst('[name_count]', q.trim()) + : url; + final Response response = await _dio.get>(finalUrl); print('Response data: ${response.data}'); diff --git a/lib/presentation/home_page/car.dart b/lib/presentation/home_page/car.dart index e8dc410..0bfd0b3 100644 --- a/lib/presentation/home_page/car.dart +++ b/lib/presentation/home_page/car.dart @@ -1,4 +1,5 @@ part of 'home_page.dart'; + // Ctrl+Alt+L typedef OnLikeCallback = void Function(String title, bool isLike)?; @@ -66,7 +67,7 @@ class _CarState extends State<_Car> { ClipRRect( borderRadius: BorderRadius.circular(20), child: SizedBox( - height: 150, + height: 160, width: 150, child: Image.network( widget.imageUrl ?? '', @@ -83,12 +84,47 @@ class _CarState extends State<_Car> { children: [ Text( widget.text, - style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold), + style: const TextStyle( + fontSize: 24, fontWeight: FontWeight.bold), ), Text( widget.descriptionCar, - style: const TextStyle(fontSize: 18, fontWeight: FontWeight.normal), - ) + style: const TextStyle( + fontSize: 18, fontWeight: FontWeight.normal), + ), + const SizedBox(height: 8), + // Отступ между текстом и виджетом со скидкой + Align( + alignment: Alignment.bottomLeft, + child: Container( + decoration: const BoxDecoration( + color: Colors.orangeAccent, + borderRadius: BorderRadius.all( + Radius.circular(20), + ), + ), + padding: const EdgeInsets.fromLTRB(8, 2, 8, 2), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + const Icon( + Icons.account_balance_wallet, + // Иконка со скидкой + color: Colors.black, + ), + const SizedBox(width: 4), + // Пробел между иконкой и текстом + Text( + 'Exclusive!', + style: Theme.of(context) + .textTheme + .bodyMedium + ?.copyWith(color: Colors.black), + ), + ], + ), + ), + ), ], ), ), diff --git a/lib/presentation/home_page/home_page.dart b/lib/presentation/home_page/home_page.dart index 895b4b3..01e85d7 100644 --- a/lib/presentation/home_page/home_page.dart +++ b/lib/presentation/home_page/home_page.dart @@ -7,7 +7,7 @@ import 'package:mylab/presentation/details_page/details_page.dart'; import 'package:mylab/presentation/dialogs/show_dialog.dart'; part 'car.dart'; -// showErrorDialog + class HomePage extends StatefulWidget { const HomePage({super.key, required this.title}); @@ -53,6 +53,7 @@ class _BodyState extends State { padding: const EdgeInsets.all(12), child: CupertinoSearchTextField( controller: searchController, + placeholder: 'марка', onChanged: (search) { setState(() { data = repo.loadData(q: search);