lab6 doneee

This commit is contained in:
Dasha 2024-12-08 02:13:03 +04:00
parent 3e2f12f658
commit de44be929d
5 changed files with 14 additions and 17 deletions

View File

@ -12,7 +12,7 @@ class Debounce {
static void run (
VoidCallback action, {
Duration delay = const Duration(milliseconds: 5000),
Duration delay = const Duration(milliseconds: 2000),
}) {
_timer?.cancel();
_timer = Timer(delay, action);

View File

@ -19,7 +19,7 @@ class CatDataDto {
final String? origin;
final String? length;
const CatDataDto({this.id, this.imageLink, this.name, this.origin, this.length});
const CatDataDto({this.imageLink, this.name, this.origin, this.length});
factory CatDataDto.fromJson(Map<String, dynamic> json) => _$CatDataDtoFromJson(json);
}

View File

@ -13,7 +13,6 @@ CatsDto _$CatsDtoFromJson(List<dynamic> json) => CatsDto(
);
CatDataDto _$CatDataDtoFromJson(Map<String, dynamic> json) => CatDataDto(
id: json['id'] as String?,
imageLink: json['image_link'] as String?,
name: json['name'] as String?,
origin: json['origin'] as String?,

View File

@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:pmu/data/repositories/cats_repository.dart';
import 'package:pmu/presentation/home_page/home_page.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
import 'data/repositories/cats_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
void main() {
runApp(const MyApp());

View File

@ -1,10 +1,9 @@
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:pmu/components/utils/debounce.dart';
import 'package:pmu/data/repositories/cats_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:pmu/domain/models/card.dart';
import 'package:pmu/main.dart';
import 'package:pmu/data/repositories/cats_repository.dart';
import 'package:pmu/presentation/details_page/details_page.dart';
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
import 'package:pmu/presentation/home_page/bloc/events.dart';
@ -23,10 +22,9 @@ class MyHomePage extends StatefulWidget {
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return const Scaffold(body: Body());
return Scaffold(body: Body());
}
}
@ -34,10 +32,10 @@ class Body extends StatefulWidget {
const Body();
@override
State<Body> createState() => BodyState();
State<Body> createState() => _BodyState();
}
class BodyState extends State<Body> {
class _BodyState extends State<Body> {
final searchController = TextEditingController();
final scrollController = ScrollController();
@ -48,6 +46,7 @@ class BodyState extends State<Body> {
});
scrollController.addListener(_onNextPageListener);
super.initState();
}
@ -89,7 +88,7 @@ class BodyState extends State<Body> {
builder: (context, state) => state.error != null
? Text(
state.error ?? '',
style: Theme.of(context).textTheme.headlineSmall?.copyWith(color: Colors.deepPurple),
style: Theme.of(context).textTheme.headlineSmall?.copyWith(color: Colors.red),
)
: state.isLoading
? const CircularProgressIndicator()
@ -144,9 +143,8 @@ class BodyState extends State<Body> {
'You ${isLiked ? 'like!' : 'disliked :('} $title ',
style: Theme.of(context).textTheme.bodyLarge,
),
backgroundColor: Colors.purpleAccent,
backgroundColor: Colors.deepPurple.shade600,
duration: const Duration(seconds: 1),
));
});
}
}
}}