diff --git a/lib/features/my_finance/entities/consultant_finance_entity.dart b/lib/features/my_finance/entities/consultant_finance_entity.dart index 7bcf86ef..77568937 100644 --- a/lib/features/my_finance/entities/consultant_finance_entity.dart +++ b/lib/features/my_finance/entities/consultant_finance_entity.dart @@ -1,6 +1,7 @@ enum ConsultationStatus { completed, canceled, + inProgress } class ConsultantFinanceEntity { diff --git a/lib/features/my_finance/presentation/pages/user_finance_screen.dart b/lib/features/my_finance/presentation/pages/user_finance_screen.dart index 3eecb395..d9f56ef6 100644 --- a/lib/features/my_finance/presentation/pages/user_finance_screen.dart +++ b/lib/features/my_finance/presentation/pages/user_finance_screen.dart @@ -3,9 +3,12 @@ import 'package:eatvio_app/core/theme/custom_text_style.dart'; 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/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_cubit.dart'; +import 'package:eatvio_app/features/bottom_navigation_bar/presentation/bloc/profile_avatar_cubit/profile_avatar_state.dart'; import 'package:eatvio_app/features/my_finance/entities/consultant_finance_entity.dart'; import 'package:eatvio_app/features/my_finance/presentation/pages/card_settings.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; class UserFinanceScreen extends StatefulWidget { @@ -20,162 +23,179 @@ class _UserFinanceScreenState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xFFF0F2F5), - appBar: AppBar( - shape: const RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.vertical(bottom: Radius.circular(12))), - title: const Text('Финансы'), - centerTitle: true, - ), - body: SingleChildScrollView( - padding: const EdgeInsets.symmetric(vertical: 8), - child: Column( - children: [ - const SizedBox(height: 8), - InkWell( - onTap: () { - GoRouter.of(context).pushNamed(CardSettingsScreen.name); - }, - borderRadius: BorderRadius.circular(20), - child: Ink( - decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: appTheme.blueA400), - width: MediaQuery.of(context).size.width - 32, - child: const Center( - child: Padding( - padding: EdgeInsets.all(16), - child: Text('Управление картами', style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600)), - ), - ), - ), + return BlocBuilder( + builder: (BuildContext context, ProfileAvatarState state) { + if (state is ProfileAvatarStateLoaded) { + return Scaffold( + backgroundColor: const Color(0xFFF0F2F5), + appBar: AppBar( + shape: const RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.vertical(bottom: Radius.circular(12))), + title: const Text('Финансы'), + centerTitle: true, ), - const SizedBox(height: 16), - 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: periods - .mapIndexed( - (index, value) => DropdownMenuItem( - value: periods[index], - child: Text( - periods[index], - style: TextStyles.textMMedium.copyWith(color: appTheme.black), - ), - ), - ) - .toList(), - onChanged: (value) {}, - value: periods.first, - ), - const SizedBox(height: 12), - ListView.separated( - shrinkWrap: true, - physics: const NeverScrollableScrollPhysics(), - itemBuilder: (context, index) => Material( - color: const Color(0xFFF6F6F6), - borderRadius: BorderRadius.circular(20), + body: SingleChildScrollView( + padding: const EdgeInsets.symmetric(vertical: 8), + child: Column( + children: [ + if (state.profile.roles.contains('consultant')) ...[ + const SizedBox(height: 8), + InkWell( + onTap: () { + GoRouter.of(context).pushNamed(CardSettingsScreen.name); + }, + borderRadius: BorderRadius.circular(20), + child: Ink( + decoration: BoxDecoration(borderRadius: BorderRadius.circular(20), color: appTheme.blueA400), + width: MediaQuery.of(context).size.width - 32, + child: const Center( child: Padding( - padding: const EdgeInsets.all(12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Tooltip( - message: testFinanceEntity.consultationsList[index].id, - triggerMode: TooltipTriggerMode.tap, - textStyle: const TextStyle( - color: Colors.black, - fontSize: 16, - fontWeight: FontWeight.w500, - ), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(4), - boxShadow: [ - BoxShadow( - color: Colors.black.withAlpha((255 * 0.2).toInt()), - blurRadius: 32, - ) - ], - ), - child: Text( - testFinanceEntity.consultationsList[index].id, - style: const TextStyle(color: Color(0xFF323F4B), height: 1, fontWeight: FontWeight.w500), - ), - ), - Text( - testFinanceEntity.consultationsList[index].date.format('dd.MM.yyy', 'RU'), - style: const 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: const TextStyle(color: Color(0xFF323F4B), height: 1, fontSize: 14, fontWeight: FontWeight.w500), - ), - const SizedBox(height: 8), - Text( - '${testFinanceEntity.consultationsList[index].planDuration} дней', - style: const TextStyle(color: Color(0xFF323F4B), height: 1, fontSize: 14, fontWeight: FontWeight.w500), - ), - const SizedBox(height: 8), - Container( - height: 1, - width: double.infinity, - decoration: const BoxDecoration( - color: Color(0xFFDEDEDF), - ), - ), - const SizedBox(height: 8), - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - '${testFinanceEntity.consultationsList[index].price} ₽', - style: const TextStyle(color: Color(0xFF323F4B), height: 1, fontSize: 18, fontWeight: FontWeight.w600), - ), - Material( - color: const 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: const TextStyle(fontSize: 14, fontWeight: FontWeight.w400, color: Color(0xFF0BB450), height: 1), - ), - ), - ), - ], - ), - ], - ), + padding: EdgeInsets.all(16), + child: Text('Управление картами', style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600)), ), ), - separatorBuilder: (context, index) => const SizedBox(height: 12), - itemCount: testFinanceEntity.consultationsList.length, ), - ], + ), + const SizedBox(height: 16), + ], + 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: periods + .mapIndexed( + (index, value) => DropdownMenuItem( + value: periods[index], + child: Text( + periods[index], + style: TextStyles.textMMedium.copyWith(color: appTheme.black), + ), + ), + ) + .toList(), + onChanged: (value) {}, + value: periods.first, + ), + const SizedBox(height: 12), + ListView.separated( + shrinkWrap: true, + physics: const NeverScrollableScrollPhysics(), + itemBuilder: (context, index) => Material( + color: const Color(0xFFF6F6F6), + borderRadius: BorderRadius.circular(20), + child: Padding( + padding: const EdgeInsets.all(12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Tooltip( + message: testFinanceEntity.consultationsList[index].id, + triggerMode: TooltipTriggerMode.tap, + textStyle: const TextStyle( + color: Colors.black, + fontSize: 16, + fontWeight: FontWeight.w500, + ), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + boxShadow: [ + BoxShadow( + color: Colors.black.withAlpha((255 * 0.2).toInt()), + blurRadius: 32, + ) + ], + ), + child: Text( + testFinanceEntity.consultationsList[index].id, + style: const TextStyle(color: Color(0xFF323F4B), height: 1, fontWeight: FontWeight.w500), + ), + ), + Text( + testFinanceEntity.consultationsList[index].date.format('dd.MM.yyy', 'RU'), + style: const 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: const TextStyle(color: Color(0xFF323F4B), height: 1, fontSize: 14, fontWeight: FontWeight.w500), + ), + const SizedBox(height: 8), + Text( + '${testFinanceEntity.consultationsList[index].planDuration} дней', + style: const TextStyle(color: Color(0xFF323F4B), height: 1, fontSize: 14, fontWeight: FontWeight.w500), + ), + const SizedBox(height: 8), + Container( + height: 1, + width: double.infinity, + decoration: const BoxDecoration( + color: Color(0xFFDEDEDF), + ), + ), + const SizedBox(height: 8), + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + '${testFinanceEntity.consultationsList[index].price} ₽', + style: const TextStyle(color: Color(0xFF323F4B), height: 1, fontSize: 18, fontWeight: FontWeight.w600), + ), + Material( + color: testFinanceEntity.consultationsList[index].status == ConsultationStatus.canceled + ? const Color(0xFDD01717).withAlpha((255 * 0.1).toInt()) + : const 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: testFinanceEntity.consultationsList[index].status == ConsultationStatus.canceled + ? const Color(0xFDD01717) + : const Color(0xFF0BB450), + height: 1), + ), + ), + ), + ], + ), + ], + ), + ), + ), + separatorBuilder: (context, index) => const SizedBox(height: 12), + itemCount: testFinanceEntity.consultationsList.length, + ), + ], + ), + ), + ), ), - ), + ], ), ), - ], - ), - ), + ); + } + return Container(); + }, ); } }