forked from eatvio/eatvio_app
merge upstream
This commit is contained in:
@@ -122,7 +122,10 @@ class _DiaryScreenContentState extends State<DiaryScreenContent> {
|
||||
centerTitle: true,
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
padding: const EdgeInsets.only(bottom: 16, top: 8),
|
||||
padding: EdgeInsets.only(
|
||||
bottom: 16,
|
||||
top: widget.diaryId == null ? 0 : 8,
|
||||
),
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
children: [
|
||||
@@ -133,7 +136,12 @@ class _DiaryScreenContentState extends State<DiaryScreenContent> {
|
||||
],
|
||||
if (state is DiaryStateLoaded && _canShowInsights(state))
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 12, 4, 12),
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
4,
|
||||
widget.diaryId == null ? 0 : 12,
|
||||
4,
|
||||
12,
|
||||
),
|
||||
child: _DiaryInsights(
|
||||
slug: state.isConsultantView ? _ownerSlug(state) : null,
|
||||
canAdd: !state.isConsultantView,
|
||||
@@ -325,6 +333,7 @@ class _DiaryInsightsState extends State<_DiaryInsights> {
|
||||
canAdd: widget.canAdd,
|
||||
refreshToken: _refreshToken,
|
||||
initialIntraDate: widget.diaryDate,
|
||||
showShadow: false,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@ import 'package:eatvio_app/core/widgets/show_error_dialog.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_cubit.dart';
|
||||
import 'package:eatvio_app/features/diary/presentation/bloc/diary_state.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
import 'package:table_calendar/table_calendar.dart';
|
||||
|
||||
class CalendarWidget extends StatefulWidget {
|
||||
@@ -15,13 +17,21 @@ class CalendarWidget extends StatefulWidget {
|
||||
State<CalendarWidget> createState() => _CalendarWidgetState();
|
||||
}
|
||||
|
||||
class _CalendarWidgetState extends State<CalendarWidget> {
|
||||
class _CalendarWidgetState extends State<CalendarWidget>
|
||||
with SingleTickerProviderStateMixin {
|
||||
static const _locale = 'ru_RU';
|
||||
static const _kDaysOfWeekHeight = 16.0;
|
||||
static const _kRowHeight = 52.0;
|
||||
static const _dayCellMargin = 6.0;
|
||||
static const _dragHandlePadding = 5.0;
|
||||
|
||||
CalendarFormat _calendarFormat = CalendarFormat.week;
|
||||
late final _expansion = AnimationController(
|
||||
vsync: this,
|
||||
duration: const Duration(milliseconds: 180),
|
||||
);
|
||||
DateTime _focusedDay = DateTime.now();
|
||||
DateTime _selectedDay = DateTime.now();
|
||||
|
||||
DateTime? _dayFromState(DiaryState state) {
|
||||
if (state is DiaryStateLoaded) {
|
||||
return state.selectedDay;
|
||||
@@ -35,11 +45,9 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final selected = _dayFromState(context.read<DiaryCubit>().state);
|
||||
if (widget.date != null) {
|
||||
_selectedDay = widget.date!;
|
||||
_focusedDay = widget.date!;
|
||||
} else if (selected != null) {
|
||||
final selected =
|
||||
widget.date ?? _dayFromState(context.read<DiaryCubit>().state);
|
||||
if (selected != null) {
|
||||
_selectedDay = selected;
|
||||
_focusedDay = selected;
|
||||
}
|
||||
@@ -54,13 +62,30 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_expansion.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
final textScaler = MediaQuery.textScalerOf(context);
|
||||
final daysOfWeekHeight = _scaledDaysOfWeekHeight(context);
|
||||
return BlocConsumer<DiaryCubit, DiaryState>(
|
||||
listener: (BuildContext context, DiaryState state) {
|
||||
final rowHeight = MediaQuery.textScalerOf(context).scale(_kRowHeight);
|
||||
final firstOfMonth = DateTime.utc(_focusedDay.year, _focusedDay.month);
|
||||
final daysInMonth = DateTime.utc(
|
||||
_focusedDay.year,
|
||||
_focusedDay.month + 1,
|
||||
0,
|
||||
).day;
|
||||
final daysBeforeMonth = firstOfMonth.weekday - DateTime.monday;
|
||||
final weekCount = (daysBeforeMonth + daysInMonth + 6) ~/ 7;
|
||||
final focusedWeek = (daysBeforeMonth + _focusedDay.day - 1) ~/ 7;
|
||||
final extraHeight = (weekCount - 1) * rowHeight;
|
||||
final week = _buildDays(rowHeight, CalendarFormat.week);
|
||||
final month = _buildDays(rowHeight, CalendarFormat.month);
|
||||
|
||||
return BlocListener<DiaryCubit, DiaryState>(
|
||||
listener: (context, state) {
|
||||
final selected = _dayFromState(state);
|
||||
if (selected != null) {
|
||||
setState(() {
|
||||
@@ -69,80 +94,167 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
||||
});
|
||||
}
|
||||
},
|
||||
builder: (BuildContext context, DiaryState state) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 16),
|
||||
child: TableCalendar(
|
||||
focusedDay: _focusedDay,
|
||||
firstDay: DateTime.utc(2020, 10, 16),
|
||||
lastDay: DateTime.utc(2030, 3, 14),
|
||||
locale: 'ru_RU',
|
||||
startingDayOfWeek: StartingDayOfWeek.monday,
|
||||
calendarFormat: _calendarFormat,
|
||||
daysOfWeekHeight: daysOfWeekHeight,
|
||||
rowHeight: textScaler.scale(_kRowHeight),
|
||||
headerStyle: const HeaderStyle(titleCentered: true, formatButtonVisible: false, leftChevronVisible: false, rightChevronVisible: false),
|
||||
onDaySelected: (selectedDay, focusedDay) async {
|
||||
if (!isSameDay(_selectedDay, selectedDay)) {
|
||||
final previousSelectedDay = _selectedDay;
|
||||
final previousFocusedDay = _selectedDay;
|
||||
setState(() {
|
||||
_selectedDay = selectedDay;
|
||||
_focusedDay = focusedDay;
|
||||
});
|
||||
final cubit = context.read<DiaryCubit>();
|
||||
final canOpenNextDay = await cubit.setSelectedDay(selectedDay);
|
||||
if (!context.mounted || cubit.state is DiaryStateError) {
|
||||
return;
|
||||
}
|
||||
if (!canOpenNextDay) {
|
||||
showErrorDialog(context, title: s.want_to_see_tomorrow, description: s.can_not_see_next_day);
|
||||
setState(() {
|
||||
_selectedDay = previousSelectedDay;
|
||||
_focusedDay = previousFocusedDay;
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
selectedDayPredicate: (day) {
|
||||
return isSameDay(_selectedDay, day);
|
||||
},
|
||||
onPageChanged: (focusedDay) {
|
||||
setState(() {
|
||||
_focusedDay = focusedDay;
|
||||
});
|
||||
},
|
||||
onFormatChanged: (format) {
|
||||
if (_calendarFormat != format) {
|
||||
setState(() {
|
||||
_calendarFormat = format;
|
||||
});
|
||||
}
|
||||
},
|
||||
calendarStyle: CalendarStyle(
|
||||
weekendDecoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
|
||||
defaultDecoration: const BoxDecoration(color: Colors.white, shape: BoxShape.circle),
|
||||
selectedDecoration: BoxDecoration(color: appTheme.blueA400, shape: BoxShape.circle),
|
||||
todayTextStyle: const TextStyle(color: Colors.black),
|
||||
todayDecoration: BoxDecoration(
|
||||
border: Border.all(color: appTheme.blueA400, width: 2),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 4),
|
||||
child: AnimatedBuilder(
|
||||
animation: _expansion,
|
||||
child: _buildWeekdays(context),
|
||||
builder: (context, weekdays) {
|
||||
return Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
_buildHeader(context),
|
||||
weekdays!,
|
||||
ClipRect(
|
||||
child: SizedBox(
|
||||
height: rowHeight + extraHeight * _expansion.value,
|
||||
child: OverflowBox(
|
||||
// При раскрытии показываем строки вокруг открытой недели.
|
||||
alignment: Alignment(
|
||||
0,
|
||||
2 * focusedWeek / (weekCount - 1) - 1,
|
||||
),
|
||||
minHeight: 0,
|
||||
maxHeight: double.infinity,
|
||||
child: _expansion.value == 0 ? week : month,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
_arrowDown(),
|
||||
],
|
||||
);
|
||||
},
|
||||
_buildDragHandle(extraHeight),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildHeader(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
final expanded = _expansion.value >= 0.5;
|
||||
final label = DateFormat.yMMMM(_locale).format(_focusedDay);
|
||||
|
||||
return Tooltip(
|
||||
message: expanded ? s.hide : s.expand,
|
||||
child: InkWell(
|
||||
onTap: () => _expansion.value = expanded ? 0 : 1,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Text(label, style: const HeaderStyle().titleTextStyle),
|
||||
const SizedBox(width: 4),
|
||||
Icon(
|
||||
expanded
|
||||
? Icons.keyboard_arrow_up_rounded
|
||||
: Icons.keyboard_arrow_down_rounded,
|
||||
size: 18,
|
||||
color: appTheme.blueA400,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildWeekdays(BuildContext context) {
|
||||
const style = DaysOfWeekStyle();
|
||||
final format = DateFormat.E(_locale);
|
||||
|
||||
return ExcludeSemantics(
|
||||
child: SizedBox(
|
||||
height: _scaledDaysOfWeekHeight(context),
|
||||
child: Row(
|
||||
children: List.generate(DateTime.daysPerWeek, (index) {
|
||||
final day = DateTime.utc(
|
||||
_focusedDay.year,
|
||||
_focusedDay.month,
|
||||
_focusedDay.day - _focusedDay.weekday + DateTime.monday + index,
|
||||
);
|
||||
return Expanded(
|
||||
child: Center(
|
||||
child: Text(
|
||||
format.format(day),
|
||||
style: day.weekday >= DateTime.saturday
|
||||
? style.weekendStyle
|
||||
: style.weekdayStyle,
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDays(double rowHeight, CalendarFormat format) {
|
||||
return TableCalendar(
|
||||
key: ValueKey(format),
|
||||
focusedDay: _focusedDay,
|
||||
firstDay: DateTime.utc(2020, 10, 16),
|
||||
lastDay: DateTime.utc(2030, 3, 14),
|
||||
locale: _locale,
|
||||
startingDayOfWeek: StartingDayOfWeek.monday,
|
||||
calendarFormat: format,
|
||||
availableGestures: AvailableGestures.horizontalSwipe,
|
||||
headerVisible: false,
|
||||
daysOfWeekVisible: false,
|
||||
rowHeight: rowHeight,
|
||||
onDaySelected: _selectDay,
|
||||
selectedDayPredicate: (day) => isSameDay(_selectedDay, day),
|
||||
onPageChanged: (focusedDay) => setState(() => _focusedDay = focusedDay),
|
||||
calendarStyle: CalendarStyle(
|
||||
cellMargin: const EdgeInsets.all(_dayCellMargin),
|
||||
weekendDecoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
defaultDecoration: const BoxDecoration(
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
selectedDecoration: BoxDecoration(
|
||||
color: appTheme.blueA400,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
todayTextStyle: const TextStyle(color: Colors.black),
|
||||
todayDecoration: BoxDecoration(
|
||||
border: Border.all(color: appTheme.blueA400, width: 2),
|
||||
color: Colors.white,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _selectDay(DateTime selectedDay, DateTime focusedDay) async {
|
||||
if (isSameDay(_selectedDay, selectedDay)) return;
|
||||
|
||||
final previousSelectedDay = _selectedDay;
|
||||
final previousFocusedDay = _focusedDay;
|
||||
setState(() {
|
||||
_selectedDay = selectedDay;
|
||||
_focusedDay = focusedDay;
|
||||
});
|
||||
final cubit = context.read<DiaryCubit>();
|
||||
final canOpenNextDay = await cubit.setSelectedDay(selectedDay);
|
||||
if (!mounted || cubit.state is DiaryStateError || canOpenNextDay) return;
|
||||
|
||||
final s = S.of(context);
|
||||
showErrorDialog(
|
||||
context,
|
||||
title: s.want_to_see_tomorrow,
|
||||
description: s.can_not_see_next_day,
|
||||
);
|
||||
setState(() {
|
||||
_selectedDay = previousSelectedDay;
|
||||
_focusedDay = previousFocusedDay;
|
||||
});
|
||||
}
|
||||
|
||||
double _scaledDaysOfWeekHeight(BuildContext context) {
|
||||
final painter = TextPainter(
|
||||
text: TextSpan(text: 'Щy', style: DefaultTextStyle.of(context).style),
|
||||
@@ -155,26 +267,44 @@ class _CalendarWidgetState extends State<CalendarWidget> {
|
||||
return height.clamp(_kDaysOfWeekHeight, double.infinity);
|
||||
}
|
||||
|
||||
void _nextCalendarFormat() {
|
||||
setState(() {
|
||||
_calendarFormat = CalendarFormat.values[(_calendarFormat.index - 1) % CalendarFormat.values.length];
|
||||
});
|
||||
}
|
||||
|
||||
GestureDetector _arrowDown() {
|
||||
Widget _buildDragHandle(double extraHeight) {
|
||||
return GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onVerticalDragStart: (_) {
|
||||
_nextCalendarFormat();
|
||||
behavior: HitTestBehavior.opaque,
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onVerticalDragStart: (_) => _expansion.stop(),
|
||||
onVerticalDragUpdate: (details) {
|
||||
_expansion.value = (_expansion.value + details.delta.dy / extraHeight)
|
||||
.clamp(0.0, 1.0);
|
||||
},
|
||||
onTap: () {
|
||||
_nextCalendarFormat();
|
||||
},
|
||||
child: Container(
|
||||
onVerticalDragEnd: (details) =>
|
||||
_settleExpansion(details.velocity.pixelsPerSecond.dy),
|
||||
onVerticalDragCancel: _settleExpansion,
|
||||
child: SizedBox(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.only(top: 8, bottom: 16),
|
||||
child: Icon(_calendarFormat == CalendarFormat.month ? Icons.keyboard_arrow_up_rounded : Icons.keyboard_arrow_down_rounded, color: Colors.grey.shade600),
|
||||
child: Padding(
|
||||
// Отступ ячеек уже добавляет место над полоской.
|
||||
padding: const EdgeInsets.only(
|
||||
top: _dragHandlePadding,
|
||||
bottom: _dragHandlePadding + _dayCellMargin,
|
||||
),
|
||||
child: Center(
|
||||
child: DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: appTheme.blueA400,
|
||||
borderRadius: BorderRadius.circular(2),
|
||||
),
|
||||
child: const SizedBox(width: 28, height: 4),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _settleExpansion([double velocity = 0]) {
|
||||
final shouldExpand = velocity.abs() >= 400
|
||||
? velocity > 0
|
||||
: _expansion.value >= 0.5;
|
||||
_expansion.animateTo(shouldExpand ? 1 : 0, curve: Curves.easeOutCubic);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import 'package:share_plus/share_plus.dart';
|
||||
class PlanWidget extends StatefulWidget {
|
||||
final PlanModel plan;
|
||||
final int index;
|
||||
final bool showPriceOnCover;
|
||||
final Future<void> Function(String slug)? onLikeTap;
|
||||
final Future<void> Function(String slug, bool isFavorite)? onToggleFavorite;
|
||||
final VoidCallback? onPlanChanged;
|
||||
@@ -30,6 +31,7 @@ class PlanWidget extends StatefulWidget {
|
||||
super.key,
|
||||
required this.plan,
|
||||
required this.index,
|
||||
this.showPriceOnCover = false,
|
||||
this.onLikeTap,
|
||||
this.onToggleFavorite,
|
||||
this.onPlanChanged,
|
||||
@@ -45,6 +47,10 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final s = S.of(context);
|
||||
final minPrice = widget.plan.minPriceOfOptions.toStringAsFixed(0);
|
||||
final price = widget.plan.packetsCount == 1
|
||||
? '${widget.plan.packet1Options?.price ?? minPrice}₽'
|
||||
: '${s.from} $minPrice₽';
|
||||
return InkWell(
|
||||
onTap: () => GoRouter.of(context).pushNamed(
|
||||
'aboutPlanScreen',
|
||||
@@ -119,14 +125,40 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
),
|
||||
Positioned(
|
||||
bottom: 16,
|
||||
child: SizedBox(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
child: InfoRow(
|
||||
plan: widget.plan,
|
||||
itemsBackgroundColor: appTheme.whiteA700,
|
||||
disableDescriptionOfTypes: true,
|
||||
type: ProductType.plan,
|
||||
),
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (widget.showPriceOnCover)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 8),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 14,
|
||||
vertical: 4,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: appTheme.greenA700,
|
||||
borderRadius: const BorderRadius.horizontal(
|
||||
right: Radius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
price,
|
||||
style: TextStyles.textSSemibold.copyWith(
|
||||
color: appTheme.whiteA700,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
InfoRow(
|
||||
plan: widget.plan,
|
||||
itemsBackgroundColor: appTheme.whiteA700,
|
||||
disableDescriptionOfTypes: true,
|
||||
type: ProductType.plan,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -221,14 +253,16 @@ class _PlanWidgetState extends State<PlanWidget> {
|
||||
),
|
||||
],
|
||||
),
|
||||
const Spacer(),
|
||||
Text(
|
||||
'${widget.plan.packetsCount == 1 ? widget.plan.packet1Options?.price : '${s.from} ${widget.plan.minPriceOfOptions.toStringAsFixed(0)}'}₽',
|
||||
style: TextStyles.headingXLSemibold.copyWith(
|
||||
color: appTheme.greenA700,
|
||||
if (!widget.showPriceOnCover) ...[
|
||||
const Spacer(),
|
||||
Text(
|
||||
price,
|
||||
style: TextStyles.headingXLSemibold.copyWith(
|
||||
color: appTheme.greenA700,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
],
|
||||
),
|
||||
title: Padding(
|
||||
|
||||
@@ -39,12 +39,14 @@ class InsightsCard extends StatelessWidget {
|
||||
this.kbjuEnabled = InsightsFeatureFlags.kbjuEnabled,
|
||||
this.refreshToken = 0,
|
||||
this.initialIntraDate,
|
||||
this.showShadow = true,
|
||||
});
|
||||
|
||||
final String? slug;
|
||||
final bool canAdd;
|
||||
final InsightsRepository? repository;
|
||||
final bool kbjuEnabled;
|
||||
final bool showShadow;
|
||||
|
||||
/// При смене значения блок перезапрашивает данные (например, после правок
|
||||
/// в дневнике), сохраняя вкладку, период и выбранный день.
|
||||
@@ -68,6 +70,7 @@ class InsightsCard extends StatelessWidget {
|
||||
child: _InsightsView(
|
||||
refreshToken: refreshToken,
|
||||
initialIntraDate: initialIntraDate,
|
||||
showShadow: showShadow,
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -78,10 +81,12 @@ class _InsightsView extends StatefulWidget {
|
||||
const _InsightsView({
|
||||
required this.refreshToken,
|
||||
required this.initialIntraDate,
|
||||
required this.showShadow,
|
||||
});
|
||||
|
||||
final int refreshToken;
|
||||
final String? initialIntraDate;
|
||||
final bool showShadow;
|
||||
|
||||
@override
|
||||
State<_InsightsView> createState() => _InsightsViewState();
|
||||
@@ -112,9 +117,13 @@ class _InsightsViewState extends State<_InsightsView> {
|
||||
builder: (context, state) {
|
||||
return switch (state) {
|
||||
InsightsStateLoaded() => _CardShell(
|
||||
showShadow: widget.showShadow,
|
||||
child: _LoadedContent(state: state),
|
||||
),
|
||||
InsightsStateError() => const _CardShell(child: _ErrorContent()),
|
||||
InsightsStateError() => _CardShell(
|
||||
showShadow: widget.showShadow,
|
||||
child: const _ErrorContent(),
|
||||
),
|
||||
_ => const SizedBox.shrink(),
|
||||
};
|
||||
},
|
||||
@@ -123,9 +132,10 @@ class _InsightsViewState extends State<_InsightsView> {
|
||||
}
|
||||
|
||||
class _CardShell extends StatelessWidget {
|
||||
const _CardShell({required this.child});
|
||||
const _CardShell({required this.child, required this.showShadow});
|
||||
|
||||
final Widget child;
|
||||
final bool showShadow;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -135,12 +145,13 @@ class _CardShell extends StatelessWidget {
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: InsightsColors.cardShadow,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
boxShadow: [
|
||||
if (showShadow)
|
||||
const BoxShadow(
|
||||
color: InsightsColors.cardShadow,
|
||||
blurRadius: 4,
|
||||
offset: Offset(0, 2),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: child,
|
||||
|
||||
@@ -494,6 +494,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
return PlanWidget(
|
||||
plan: state.plansList[index],
|
||||
index: index,
|
||||
showPriceOnCover: true,
|
||||
onLikeTap: (slug) => plansCubit.likePlan(slug),
|
||||
onToggleFavorite: (slug, isFavorite) => isFavorite
|
||||
? plansCubit.removePlanFromFavorite(slug)
|
||||
|
||||
Reference in New Issue
Block a user