From 25ebc8f7ab2866545e7f01437e82513857341501 Mon Sep 17 00:00:00 2001 From: DyCTaTOR <125912249+DyCTaTOR@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:21:57 +0400 Subject: [PATCH] =?UTF-8?q?lab6=20-=20=D1=82=D0=BE=D1=87=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/main.dart | 14 ++++++++++---- lib/presentation/home_page/home_page.dart | 10 ++++++++-- lib/repo/potter_repo.dart | 8 ++++++-- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index ac75a1c..bdf80a1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -17,8 +17,11 @@ class MyApp extends StatelessWidget { title: 'University App', theme: ThemeData( primarySwatch: Colors.blue, + scaffoldBackgroundColor: Colors.white, // Устанавливаем белый фон + ), + home: ScaffoldMessenger( + child: UniversityScreen(), ), - home: UniversityScreen(), ); } } @@ -59,6 +62,7 @@ class _UniversityScreenState extends State { theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.orangeAccent), useMaterial3: true, + scaffoldBackgroundColor: Colors.white, // Устанавливаем белый фон ), home: RepositoryProvider( lazy: true, @@ -66,9 +70,11 @@ class _UniversityScreenState extends State { child: BlocProvider( lazy: false, create: (context) => HomeBloc(context.read()), - child: const MyHomePage(), + child: Scaffold( + body: const MyHomePage(), + ), ), - ) + ), ); } -} +} \ No newline at end of file diff --git a/lib/presentation/home_page/home_page.dart b/lib/presentation/home_page/home_page.dart index a8f68c5..c9d4657 100644 --- a/lib/presentation/home_page/home_page.dart +++ b/lib/presentation/home_page/home_page.dart @@ -35,7 +35,7 @@ class _MyHomePageState extends State { } void _onNextPageListener(){ - if(scrollController.offset > scrollController.position.maxScrollExtent) { + if(scrollController.offset >= scrollController.position.maxScrollExtent) { final bloc = context.read(); if(!bloc.state.isPaginationLoading) { bloc.add(HomeLoadDataEvent ( @@ -75,6 +75,7 @@ class _MyHomePageState extends State { child: RefreshIndicator( onRefresh: _onRefresh, child: ListView.builder( + controller: scrollController, padding: EdgeInsets.zero, itemCount: state.data?.data?.length ?? 0, itemBuilder: (context, index) { @@ -89,8 +90,13 @@ class _MyHomePageState extends State { }, ), ), - ) + ), ), + BlocBuilder( + builder: (context, state) => state.isPaginationLoading + ? const CircularProgressIndicator() + : const SizedBox.shrink(), + ) ], ), ); diff --git a/lib/repo/potter_repo.dart b/lib/repo/potter_repo.dart index fb094de..21cc9c5 100644 --- a/lib/repo/potter_repo.dart +++ b/lib/repo/potter_repo.dart @@ -18,14 +18,18 @@ class PotterRepo extends ApiInterface { @override Future loadData( - {OnErrorCallback? onError, String? q, int page = 1, int pageSize = 25}) async { + {OnErrorCallback? onError, + String? q, + int page = 1, + int pageSize = 25 + }) async { try { const String url = '$_baseUrl/v1/characters'; final Response response = await _dio.get>( url, queryParameters: { - 'filter[name_count]': q, + 'filter[name_cont]': q, 'page[number]': page, 'page[size]': pageSize, },