forked from eatvio/eatvio_app
244 lines
12 KiB
Dart
244 lines
12 KiB
Dart
import 'package:eatvio_app/core/theme/custom_text_style.dart';
|
|
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
|
import 'package:eatvio_app/core/widgets/bottom_sheet_with_blur.dart';
|
|
import 'package:eatvio_app/core/widgets/custom_outlined_button.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_cubit.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/bloc/chat_room_cubit/chat_room_state.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/widgets/chose_plan_date_widget.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/widgets/complete_plan_bottom_sheet.dart';
|
|
import 'package:eatvio_app/features/chat/presentation/widgets/plan_complain_bottom_sheet.dart';
|
|
import 'package:eatvio_app/features/my_diets/presentation/my_diets_screen.dart';
|
|
import 'package:eatvio_app/features/my_finance/presentation/pages/card_settings.dart';
|
|
import 'package:eatvio_app/features/payment/presentation/payment_flow.dart';
|
|
import 'package:eatvio_app/generated/l10n.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:flutter_svg/svg.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
class NotificationBanner extends StatefulWidget {
|
|
const NotificationBanner({super.key, required this.bannerType, this.planPrice, this.planName, this.chosenPlanId, this.hasPersonalDiet = false});
|
|
final BannerType bannerType;
|
|
final double? planPrice;
|
|
final String? planName;
|
|
final int? chosenPlanId;
|
|
final bool hasPersonalDiet;
|
|
@override
|
|
State<NotificationBanner> createState() => _NotificationBannerState();
|
|
}
|
|
|
|
class _NotificationBannerState extends State<NotificationBanner> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final size = MediaQuery.sizeOf(context);
|
|
final s = S.of(context);
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFFFFDD8),
|
|
borderRadius: BorderRadius.circular(20),
|
|
),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (widget.bannerType != BannerType.collectCharge && widget.bannerType != BannerType.finishPlan)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 12, right: 8, left: 12),
|
|
child: SvgPicture.asset('assets/icons/reversed_exclamation_mark.svg', height: 68, width: 68),
|
|
)
|
|
else
|
|
const Padding(
|
|
padding: EdgeInsets.only(top: 12, right: 8, left: 12),
|
|
child: _StarIcon(),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 16),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: switch (widget.bannerType) {
|
|
BannerType.date => [
|
|
SizedBox(
|
|
width: size.width * 0.6,
|
|
child: Text(widget.hasPersonalDiet == true ? s.choose_plan_start_date_with_personal_diet : s.choose_plan_start_date,
|
|
style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 12),
|
|
GestureDetector(
|
|
onTap: () {
|
|
final cubit = context.read<ChatRoomCubit>();
|
|
showModalBottomSheet(
|
|
context: context,
|
|
builder: (context) => ChosePlanDateWidget(
|
|
chatCubit: cubit,
|
|
hasPersonalDiet: widget.hasPersonalDiet,
|
|
),
|
|
);
|
|
},
|
|
child: Text(s.choose_date, style: TextStyles.textLSemibold.copyWith(color: appTheme.blueA400)),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
BannerType.card => [
|
|
SizedBox(
|
|
width: size.width * 0.6,
|
|
child: Text(s.can_not_choose_start_date, style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 12),
|
|
GestureDetector(
|
|
onTap: () {
|
|
GoRouter.of(context).pushReplacement(
|
|
CardSettingsScreen.path,
|
|
);
|
|
},
|
|
child: Text(s.add_card, style: TextStyles.textLSemibold.copyWith(color: appTheme.blueA400)),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
BannerType.payment => [
|
|
SizedBox(
|
|
width: size.width * 0.6,
|
|
child: Text(s.tap_on_link_to_pay, style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 12),
|
|
GestureDetector(
|
|
onTap: () {
|
|
final planId = (context.read<ChatRoomCubit>().state as ChatRoomStateLoaded).chatRoom.chosenPlan?.id;
|
|
if (planId != null) {
|
|
showConsultationPaymentFlow(context, planId: planId);
|
|
}
|
|
},
|
|
child: Text(s.pay, style: TextStyles.textLSemibold.copyWith(color: appTheme.blueA400)),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
BannerType.collectCharge => [
|
|
SizedBox(
|
|
width: size.width * 0.6,
|
|
child:
|
|
Text('${s.congratsYouHaveFinishedPlan} «${widget.planName}»', style: TextStyles.textMSemibold.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 8),
|
|
SizedBox(
|
|
width: size.width * 0.6,
|
|
child: Text('${s.userConfirmedPlanCompletion} ${widget.planPrice}₽', style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 8),
|
|
],
|
|
BannerType.finishPlan => [
|
|
SizedBox(
|
|
width: size.width * 0.6,
|
|
child: Text('${s.congratsYouHaveFinishedPlan} «${widget.planName}». ${s.pleaseConfirmPlan}',
|
|
style: TextStyles.textMMediumAuto.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 8),
|
|
SizedBox(
|
|
width: size.width * 0.7,
|
|
child: Text(s.planWillBeConfirmedAfterThreeDays, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 8),
|
|
],
|
|
BannerType.setPersonalDiet => [
|
|
SizedBox(
|
|
width: size.width * 0.6,
|
|
child: Text(s.createPersonalDiet, style: TextStyles.textMMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
const SizedBox(height: 12),
|
|
GestureDetector(
|
|
onTap: () {
|
|
GoRouter.of(context).pushNamed(MyDietsScreen.name);
|
|
},
|
|
child: Text(s.goToMyDiets, style: TextStyles.textLSemibold.copyWith(color: appTheme.blueA400)),
|
|
),
|
|
const SizedBox(height: 16),
|
|
],
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
if (widget.bannerType == BannerType.collectCharge)
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
child: CustomOutlinedButton(
|
|
text: s.collectCharge,
|
|
height: 52,
|
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
|
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.green)),
|
|
onPressed: () async {
|
|
GoRouter.of(context).push(CardSettingsScreen.path, extra: widget.chosenPlanId);
|
|
},
|
|
),
|
|
),
|
|
if (widget.bannerType == BannerType.finishPlan) ...[
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
child: CustomOutlinedButton(
|
|
text: s.confirm,
|
|
height: 52,
|
|
buttonTextStyle: TextStyles.textMSemibold.copyWith(color: appTheme.whiteA700),
|
|
buttonStyle: ButtonStyle(side: const WidgetStatePropertyAll(BorderSide.none), backgroundColor: WidgetStatePropertyAll(appTheme.blueA400)),
|
|
onPressed: () async {
|
|
final cubit = context.read<ChatRoomCubit>();
|
|
showBottomSheetWithBlur(
|
|
userRootNavigator: true,
|
|
context: context,
|
|
height: null,
|
|
child: CompletePlanBottomSheet(
|
|
cubit: cubit,
|
|
),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: SizedBox(
|
|
child: Text(s.youCanComplain, style: TextStyles.textSMedium.copyWith(color: appTheme.black)),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Align(
|
|
alignment: Alignment.centerLeft,
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: GestureDetector(
|
|
onTap: () {
|
|
final cubit = context.read<ChatRoomCubit>();
|
|
showBottomSheetWithBlur(
|
|
userRootNavigator: true,
|
|
context: context,
|
|
height: null,
|
|
child: PlanComplainBottomSheet(
|
|
cubit: cubit,
|
|
),
|
|
);
|
|
},
|
|
child: Text(s.leaveComplainRequest, style: TextStyles.textSMedium.copyWith(color: appTheme.red))),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
]
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _StarIcon extends StatelessWidget {
|
|
const _StarIcon();
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Container(
|
|
padding: const EdgeInsets.all(12),
|
|
decoration: BoxDecoration(color: appTheme.whiteA700, shape: BoxShape.circle),
|
|
child: SvgPicture.asset('assets/icons/star.svg'),
|
|
);
|
|
}
|
|
}
|
|
|
|
enum BannerType { date, card, payment, collectCharge, finishPlan, setPersonalDiet }
|