Files
be_happy_public/lib/presentation/components/sheet/tariff_info_sheet.dart
2026-08-18 15:09:53 +03:00

191 lines
7.0 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import 'dart:ui';
import 'package:be_happy/domain/entities/tariff.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import '../content_parser.dart';
class TariffInfoSheet extends StatefulWidget {
final Tariff tariff;
final bool isInsurance;
final Function(bool) onChanged;
const TariffInfoSheet({super.key, required this.tariff, required this.isInsurance, required this.onChanged});
@override
State<TariffInfoSheet> createState() => _TariffInfoSheetState();
}
class _TariffInfoSheetState extends State<TariffInfoSheet> {
late bool _isInsuranceEnabled;
@override
void initState() {
super.initState();
_isInsuranceEnabled = widget.isInsurance;
}
@override
Widget build(BuildContext context) {
return DraggableScrollableSheet(
initialChildSize: 0.6,
minChildSize: 0.4,
maxChildSize: 0.9,
expand: false,
builder: (context, scrollController) {
return ClipRRect(
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 20, sigmaY: 20),
child: Container(
decoration: BoxDecoration(
color: const Color(0xFF000032).withOpacity(0.9),
borderRadius: const BorderRadius.vertical(top: Radius.circular(30)),
),
child: Column(
children: [
const SizedBox(height: 12),
Container(
width: 40,
height: 4,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(2),
),
),
const SizedBox(height: 12),
// Контент со скроллом
Expanded(
child: ListView(
controller: scrollController,
padding: const EdgeInsets.symmetric(horizontal: 20),
children: [
// Заголовок
Center(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(Icons.timer_outlined, color: Color(0xFF66E3C4), size: 18),
const SizedBox(width: 8),
Text(
widget.tariff.title,
style: const TextStyle(
color: Color(0xFF66E3C4),
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
],
),
),
const SizedBox(height: 30),
// Таблица цен
_buildPriceRow('Старт поездки', '${widget.tariff.startPrice} руб.'),
_buildPriceRow('Последующая минута', '${widget.tariff.drivePrice} руб.'),
_buildPriceRow('Пауза', '${widget.tariff.pausePrice} руб./мин'),
_buildPriceRow('КЕШБЭК', '${widget.tariff.cashback * 100}%', isAccent: true),
const Divider(color: Colors.white24, height: 40),
Row(
children: [
const Text(
'Страховка',
style: TextStyle(color: Colors.white, fontSize: 16, fontWeight: FontWeight.w600),
),
const SizedBox(width: 8),
Image.asset('assets/icons/info_icon.png', width: 18, height: 18),
const Spacer(),
Text(
'${widget.tariff.insurance} руб.',
style: TextStyle(color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold),
),
const SizedBox(width: 12),
Transform.scale(
scale: 0.8,
child: CupertinoSwitch(
value: _isInsuranceEnabled,
activeColor: const Color(0xFF66E3C4),
onChanged: (val) {
setState(() => _isInsuranceEnabled = val);
widget.onChanged(val);
},
),
),
],
),
const Divider(color: Colors.white24, height: 40),
Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: ContentParser.parseContent(
textJson: widget.tariff.description,
text: widget.tariff.descriptionJson,
),
),
const SizedBox(height: 30),
],
),
),
],
),
),
),
);
},
);
}
Widget _buildPriceRow(String label, String value, {bool isAccent = false}) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
label,
style: TextStyle(color: Colors.white.withOpacity(0.8), fontSize: 15),
),
Text(
value,
style: TextStyle(
color: Colors.white,
fontSize: 18,
fontWeight: isAccent ? FontWeight.bold : FontWeight.w500,
),
),
],
),
);
}
Widget _buildInfoBullet(String text) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Padding(
padding: EdgeInsets.only(top: 6),
child: Icon(Icons.circle, size: 4, color: Colors.white),
),
const SizedBox(width: 12),
Expanded(
child: Text(
text,
style: TextStyle(
color: Colors.white.withOpacity(0.9),
fontSize: 13,
height: 1.5,
),
),
),
],
),
);
}
}