lab6 doneee
This commit is contained in:
parent
3e2f12f658
commit
de44be929d
@ -12,7 +12,7 @@ class Debounce {
|
|||||||
|
|
||||||
static void run (
|
static void run (
|
||||||
VoidCallback action, {
|
VoidCallback action, {
|
||||||
Duration delay = const Duration(milliseconds: 5000),
|
Duration delay = const Duration(milliseconds: 2000),
|
||||||
}) {
|
}) {
|
||||||
_timer?.cancel();
|
_timer?.cancel();
|
||||||
_timer = Timer(delay, action);
|
_timer = Timer(delay, action);
|
||||||
|
@ -19,7 +19,7 @@ class CatDataDto {
|
|||||||
final String? origin;
|
final String? origin;
|
||||||
final String? length;
|
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);
|
factory CatDataDto.fromJson(Map<String, dynamic> json) => _$CatDataDtoFromJson(json);
|
||||||
}
|
}
|
@ -13,7 +13,6 @@ CatsDto _$CatsDtoFromJson(List<dynamic> json) => CatsDto(
|
|||||||
);
|
);
|
||||||
|
|
||||||
CatDataDto _$CatDataDtoFromJson(Map<String, dynamic> json) => CatDataDto(
|
CatDataDto _$CatDataDtoFromJson(Map<String, dynamic> json) => CatDataDto(
|
||||||
id: json['id'] as String?,
|
|
||||||
imageLink: json['image_link'] as String?,
|
imageLink: json['image_link'] as String?,
|
||||||
name: json['name'] as String?,
|
name: json['name'] as String?,
|
||||||
origin: json['origin'] as String?,
|
origin: json['origin'] as String?,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:pmu/data/repositories/cats_repository.dart';
|
||||||
import 'package:pmu/presentation/home_page/home_page.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 'package:pmu/presentation/home_page/bloc/bloc.dart';
|
||||||
import 'data/repositories/cats_repository.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:flutter/cupertino.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/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/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/details_page/details_page.dart';
|
||||||
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
|
import 'package:pmu/presentation/home_page/bloc/bloc.dart';
|
||||||
import 'package:pmu/presentation/home_page/bloc/events.dart';
|
import 'package:pmu/presentation/home_page/bloc/events.dart';
|
||||||
@ -23,10 +22,9 @@ class MyHomePage extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
class _MyHomePageState extends State<MyHomePage> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return const Scaffold(body: Body());
|
return Scaffold(body: Body());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,10 +32,10 @@ class Body extends StatefulWidget {
|
|||||||
const Body();
|
const Body();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<Body> createState() => BodyState();
|
State<Body> createState() => _BodyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class BodyState extends State<Body> {
|
class _BodyState extends State<Body> {
|
||||||
final searchController = TextEditingController();
|
final searchController = TextEditingController();
|
||||||
final scrollController = ScrollController();
|
final scrollController = ScrollController();
|
||||||
|
|
||||||
@ -48,6 +46,7 @@ class BodyState extends State<Body> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
scrollController.addListener(_onNextPageListener);
|
scrollController.addListener(_onNextPageListener);
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ class BodyState extends State<Body> {
|
|||||||
builder: (context, state) => state.error != null
|
builder: (context, state) => state.error != null
|
||||||
? Text(
|
? Text(
|
||||||
state.error ?? '',
|
state.error ?? '',
|
||||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(color: Colors.deepPurple),
|
style: Theme.of(context).textTheme.headlineSmall?.copyWith(color: Colors.red),
|
||||||
)
|
)
|
||||||
: state.isLoading
|
: state.isLoading
|
||||||
? const CircularProgressIndicator()
|
? const CircularProgressIndicator()
|
||||||
@ -144,9 +143,8 @@ class BodyState extends State<Body> {
|
|||||||
'You ${isLiked ? 'like!' : 'disliked :('} $title ',
|
'You ${isLiked ? 'like!' : 'disliked :('} $title ',
|
||||||
style: Theme.of(context).textTheme.bodyLarge,
|
style: Theme.of(context).textTheme.bodyLarge,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.purpleAccent,
|
backgroundColor: Colors.deepPurple.shade600,
|
||||||
duration: const Duration(seconds: 1),
|
duration: const Duration(seconds: 1),
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
}
|
}}
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user