lab6 - точно готова
This commit is contained in:
parent
077b48175e
commit
25ebc8f7ab
@ -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<UniversityScreen> {
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orangeAccent),
|
||||
useMaterial3: true,
|
||||
scaffoldBackgroundColor: Colors.white, // Устанавливаем белый фон
|
||||
),
|
||||
home: RepositoryProvider<PotterRepo>(
|
||||
lazy: true,
|
||||
@ -66,9 +70,11 @@ class _UniversityScreenState extends State<UniversityScreen> {
|
||||
child: BlocProvider<HomeBloc>(
|
||||
lazy: false,
|
||||
create: (context) => HomeBloc(context.read<PotterRepo>()),
|
||||
child: const MyHomePage(),
|
||||
child: Scaffold(
|
||||
body: const MyHomePage(),
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
}
|
||||
|
||||
void _onNextPageListener(){
|
||||
if(scrollController.offset > scrollController.position.maxScrollExtent) {
|
||||
if(scrollController.offset >= scrollController.position.maxScrollExtent) {
|
||||
final bloc = context.read<HomeBloc>();
|
||||
if(!bloc.state.isPaginationLoading) {
|
||||
bloc.add(HomeLoadDataEvent (
|
||||
@ -75,6 +75,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
||||
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<MyHomePage> {
|
||||
},
|
||||
),
|
||||
),
|
||||
)
|
||||
),
|
||||
),
|
||||
BlocBuilder<HomeBloc, HomeState>(
|
||||
builder: (context, state) => state.isPaginationLoading
|
||||
? const CircularProgressIndicator()
|
||||
: const SizedBox.shrink(),
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
|
@ -18,14 +18,18 @@ class PotterRepo extends ApiInterface {
|
||||
|
||||
@override
|
||||
Future<HomeData?> 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<dynamic> response = await _dio.get<Map<dynamic, dynamic>>(
|
||||
url,
|
||||
queryParameters: {
|
||||
'filter[name_count]': q,
|
||||
'filter[name_cont]': q,
|
||||
'page[number]': page,
|
||||
'page[size]': pageSize,
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user