forked from eatvio/eatvio_app
101 lines
4.2 KiB
Dart
101 lines
4.2 KiB
Dart
import 'package:eatvio_app/core/enums/base_state.dart';
|
|
import 'package:eatvio_app/core/locator_service.dart';
|
|
import 'package:eatvio_app/core/theme/theme_helper.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:eatvio_app/features/finances_and_consultations_archive/presentation/consultations_archive_screen.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:go_router/go_router.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 {
|
|
context.read<ConsultationsCubit>().loadConsultations();
|
|
}),
|
|
BaseState.initial => const Loader(),
|
|
BaseState.success => SingleChildScrollView(
|
|
child: Column(
|
|
children: [
|
|
ListView.separated(
|
|
padding: const EdgeInsets.symmetric(vertical: 12),
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
itemBuilder: (context, index) => ConsultationCardWidget(
|
|
consultationsModel: state.consultations[index],
|
|
),
|
|
separatorBuilder: (context, index) => const SizedBox(
|
|
height: 12,
|
|
),
|
|
shrinkWrap: true,
|
|
itemCount: state.consultations.length,
|
|
),
|
|
const SizedBox(height: 20),
|
|
InkWell(
|
|
borderRadius: BorderRadius.circular(20),
|
|
onTap: () {
|
|
GoRouter.of(context).pushNamed(ConsultationsArchiveScreen.name);
|
|
},
|
|
child: Ink(
|
|
width: MediaQuery.of(context).size.width - 32,
|
|
padding: const EdgeInsets.all(16),
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(20),
|
|
color: appTheme.blueA400,
|
|
),
|
|
child: const Center(
|
|
child: Text(
|
|
'Архив консультаций',
|
|
style: TextStyle(
|
|
color: Colors.white,
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 20),
|
|
],
|
|
),
|
|
),
|
|
});
|
|
},
|
|
);
|
|
}
|
|
}
|