feat: finance consultation

This commit is contained in:
BLoC
2025-02-24 10:48:28 +03:00
parent e142ce7b96
commit 0ee94e96c9
10 changed files with 445 additions and 68 deletions

View File

@@ -12,6 +12,11 @@ class ConsultationsScreen extends StatelessWidget {
appBar: AppBar(
title: Text('Консультации'),
centerTitle: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.vertical(
bottom: Radius.circular(12),
),
),
),
body: ListView.separated(
padding: EdgeInsets.symmetric(vertical: 12),

View File

@@ -7,12 +7,18 @@ import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/features/dev_tools/presentation/dev_tools_screen.dart';
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
import 'package:eatvio_app/features/my_plans/presentation/my_plans_screen.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:go_router/go_router.dart';
class MenuScreen extends StatelessWidget {
MenuScreen({super.key});
final ProfileModel profileModel;
const MenuScreen({
super.key,
required this.profileModel,
});
@override
Widget build(BuildContext context) {
@@ -29,24 +35,40 @@ class MenuScreen extends StatelessWidget {
leading: ImageConstant.icnProfileSettings,
onTap: () => GoRouter.of(context).push('/settings-screen'),
),
if (profileModel.roles.contains('consultant')) _divider(context),
if (profileModel.roles.contains('consultant'))
_tile(
leading: ImageConstant.icnRecipes,
title: 'Мои рецепты',
onTap: () => GoRouter.of(context).push('/recipe-select-screen'),
),
if (profileModel.roles.contains('consultant')) _divider(context),
if (profileModel.roles.contains('consultant'))
_tile(
leading: 'assets/icons/diets.svg',
title: 'Мои диеты',
onTap: () => GoRouter.of(context).push(MyDietsScreen.path),
),
if (profileModel.roles.contains('consultant')) _divider(context),
if (profileModel.roles.contains('consultant'))
_tile(
leading: ImageConstant.icnPlans,
title: 'Мои планы',
onTap: () => GoRouter.of(context).push(MyPlansScreen.path),
),
_divider(context),
_tile(
leading: ImageConstant.icnRecipes,
title: 'Мои рецепты',
onTap: () => GoRouter.of(context).push('/recipe-select-screen'),
),
_divider(context),
_tile(
leading: 'assets/icons/diets.svg',
title: 'Мои диеты',
onTap: () => GoRouter.of(context).push(MyDietsScreen.path),
),
_divider(context),
_tile(
leading: ImageConstant.icnPlans,
title: 'Мои планы',
onTap: () => GoRouter.of(context).push(MyPlansScreen.path),
),
if (profileModel.roles.contains('consultant'))
_tile(
leading: 'assets/icons/finance.svg',
title: 'Мои финансы',
onTap: () => GoRouter.of(context).pushNamed('consultantFinanceScreen'),
)
else
_tile(
leading: 'assets/icons/finance.svg',
title: 'Мои финансы',
onTap: () => GoRouter.of(context).pushNamed('userFinanceScreen'),
),
_divider(context),
_tile(
leading: 'assets/icons/calendar.svg',

View File

@@ -0,0 +1,80 @@
enum ConsultationStatus {
Completed,
Canceled,
CanceledByInitiator,
}
class ConsultantFinanceEntity {
final int totalConsultationsCount;
final int completedCount;
final int canceledCount;
final int canceledByInitiatorCount;
final List<ConsultationFinanceCardEntity> consultationsList;
ConsultantFinanceEntity({
required this.totalConsultationsCount,
required this.completedCount,
required this.canceledCount,
required this.canceledByInitiatorCount,
required this.consultationsList,
});
}
class ConsultationFinanceCardEntity {
final String id;
final DateTime date;
final String title;
final String clientName;
final int planDuration;
final int price;
final ConsultationStatus status;
ConsultationFinanceCardEntity({
required this.id,
required this.date,
required this.title,
required this.clientName,
required this.planDuration,
required this.price,
required this.status,
});
}
// Test data
final testConsultations = [
ConsultationFinanceCardEntity(
id: '1',
date: DateTime.now(),
title: 'Consultation A',
clientName: 'Alice',
planDuration: 30,
price: 100,
status: ConsultationStatus.Completed,
),
ConsultationFinanceCardEntity(
id: '2',
date: DateTime.now().subtract(Duration(days: 1)),
title: 'Consultation B',
clientName: 'Bob',
planDuration: 45,
price: 150,
status: ConsultationStatus.Canceled,
),
ConsultationFinanceCardEntity(
id: '3',
date: DateTime.now().subtract(Duration(days: 2)),
title: 'Consultation C',
clientName: 'Charlie',
planDuration: 60,
price: 200,
status: ConsultationStatus.CanceledByInitiator,
),
];
final testFinanceEntity = ConsultantFinanceEntity(
totalConsultationsCount: testConsultations.length,
completedCount: testConsultations.where((c) => c.status == ConsultationStatus.Completed).length,
canceledCount: testConsultations.where((c) => c.status == ConsultationStatus.Canceled).length,
canceledByInitiatorCount: testConsultations.where((c) => c.status == ConsultationStatus.CanceledByInitiator).length,
consultationsList: testConsultations,
);

View File

@@ -0,0 +1,239 @@
import 'package:eatvio_app/core/theme/theme_helper.dart';
import 'package:eatvio_app/core/utils/date_time_utils.dart';
import 'package:eatvio_app/core/widgets/custom_drop_down_button.dart';
import 'package:eatvio_app/features/my_finance/entities/consultant_finance_entity.dart';
import 'package:flutter/material.dart';
class ConsultantFinanceScreen extends StatelessWidget {
const ConsultantFinanceScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Color(0xFFF0F2F5),
appBar: AppBar(
shape: RoundedRectangleBorder(
borderRadius: BorderRadiusDirectional.vertical(
bottom: Radius.circular(12),
),
),
title: Text('Архив консультаций'),
centerTitle: true,
),
body: SingleChildScrollView(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Column(
children: [
Material(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(height: 16),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Text(
'Всего консультаций: ${testFinanceEntity.totalConsultationsCount}',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: Color(0xFF6D6F71),
height: 1,
),
),
),
const SizedBox(height: 12),
SingleChildScrollView(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 16),
child: Row(
children: [
Material(
color: Color(0xFF0BB450).withAlpha(11),
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Text(
'Завершено: ${testFinanceEntity.completedCount}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Color(0xFF0BB450),
height: 1,
),
),
),
),
const SizedBox(width: 8),
Material(
color: Color(0xFFD01717).withAlpha(11),
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Text(
'Отменено: ${testFinanceEntity.canceledCount}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Color(0xFFD01717),
height: 1,
),
),
),
),
const SizedBox(width: 8),
Material(
color: Color(0xFFD07317).withAlpha(11),
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Text(
'Отменено инициатором: ${testFinanceEntity.canceledByInitiatorCount}',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Color(0xFFD07317),
height: 1,
),
),
),
),
],
),
),
const SizedBox(height: 16),
],
),
),
const SizedBox(height: 8),
Material(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
child: Padding(
padding: const EdgeInsets.only(left: 16, right: 16, top: 16),
child: SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
child: Column(
children: [
CustomDropDownButton(
items: [],
onChanged: (value) {},
),
const SizedBox(height: 12),
CustomDropDownButton(
items: [],
onChanged: (value) {},
),
const SizedBox(height: 12),
ListView.separated(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) => Material(
color: Color(0xFFF6F6F6),
borderRadius: BorderRadius.circular(20),
child: Padding(
padding: const EdgeInsets.all(12),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
testFinanceEntity.consultationsList[index].id,
style: TextStyle(
color: Color(0xFF323F4B),
height: 1,
fontWeight: FontWeight.w500,
),
),
Text(
testFinanceEntity.consultationsList[index].date.format('dd.MM.yyy', 'RU'),
style: TextStyle(
color: Color(0xFF6D6F71),
height: 1,
fontWeight: FontWeight.w500,
),
),
],
),
const SizedBox(height: 8),
Text(
testFinanceEntity.consultationsList[index].title,
style: TextStyle(
color: appTheme.blueA400,
height: 1,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
const SizedBox(height: 8),
Text(
'Покупатель: ' + testFinanceEntity.consultationsList[index].clientName,
style: TextStyle(
color: Color(0xFF323F4B),
height: 1,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
Text(
testFinanceEntity.consultationsList[index].planDuration.toString() + ' дней',
style: TextStyle(
color: Color(0xFF323F4B),
height: 1,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
const SizedBox(height: 8),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
testFinanceEntity.consultationsList[index].price.toString() + ' ₽',
style: TextStyle(
color: Color(0xFF323F4B),
height: 1,
fontSize: 18,
fontWeight: FontWeight.w600,
),
),
Material(
color: Color(0xFF0BB450).withAlpha(11),
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Text(
testFinanceEntity.consultationsList[index].status.name,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Color(0xFF0BB450),
height: 1,
),
),
),
),
],
),
],
),
),
),
separatorBuilder: (context, index) => const SizedBox(height: 12),
itemCount: testFinanceEntity.consultationsList.length,
),
],
),
),
),
),
],
),
),
);
}
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class UserFinanceScreen extends StatelessWidget {
const UserFinanceScreen({super.key});
@override
Widget build(BuildContext context) {
return const Placeholder();
}
}