forked from eatvio/eatvio_app
62 lines
2.4 KiB
Dart
62 lines
2.4 KiB
Dart
import 'package:eatvio_app/core/enums/base_state.dart';
|
|
import 'package:eatvio_app/core/locator_service.dart';
|
|
import 'package:eatvio_app/core/widgets/data_error_widget.dart';
|
|
import 'package:eatvio_app/core/widgets/loader.dart';
|
|
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_cubit.dart';
|
|
import 'package:eatvio_app/features/consultations/presentation/cubit/consultations_state.dart';
|
|
import 'package:eatvio_app/features/consultations/presentation/widgets/consultation_card_widget.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
|
|
class ConsultationsScreen extends StatelessWidget {
|
|
static const path = '/consultations-screen';
|
|
static const name = 'consultationsScreen';
|
|
const ConsultationsScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) => sl<ConsultationsCubit>()..loadConsultations(),
|
|
child: const ConsultationsContent(),
|
|
);
|
|
}
|
|
}
|
|
|
|
class ConsultationsContent extends StatelessWidget {
|
|
const ConsultationsContent({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<ConsultationsCubit, ConsultationsState>(
|
|
builder: (context, state) {
|
|
return Scaffold(
|
|
backgroundColor: const Color(0xFFF0F2F5),
|
|
appBar: AppBar(
|
|
title: const Text('Консультации'),
|
|
centerTitle: true,
|
|
shape: const RoundedRectangleBorder(
|
|
borderRadius: BorderRadiusDirectional.vertical(
|
|
bottom: Radius.circular(12),
|
|
),
|
|
),
|
|
),
|
|
body: switch (state.state) {
|
|
BaseState.loading => const Loader(),
|
|
BaseState.error => DataErrorWidget(onReload: () async {}),
|
|
BaseState.initial => const Loader(),
|
|
BaseState.success => ListView.separated(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
itemBuilder: (context, index) => ConsultationCardWidget(
|
|
consultationsModel: state.consultations[index],
|
|
),
|
|
separatorBuilder: (context, index) => const SizedBox(
|
|
height: 12,
|
|
),
|
|
itemCount: state.consultations.length,
|
|
),
|
|
});
|
|
},
|
|
);
|
|
}
|
|
}
|