import 'package:comwell_key_app/.generated/assets/assets.gen.dart';
import 'package:comwell_key_app/presentation/screens/booking_details/bloc/booking_details_cubit.dart';
import 'package:comwell_key_app/overview/models/booking.dart';
import 'package:comwell_key_app/routing/app_routes.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
import 'package:comwell_key_app/utils/l10n_utils.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 HousekeepingButton extends StatelessWidget {
final Booking booking;
const HousekeepingButton({super.key, required this.booking});
@override
Widget build(BuildContext context) {
final cubit = context.read<BookingDetailsCubit>();
return Material(
color: Colors.transparent,
shape: RoundedRectangleBorder(
side: const BorderSide(
color: colorDivider,
),
borderRadius: BorderRadius.circular(10),
),
child: InkWell(
borderRadius: BorderRadius.circular(10),
onTap: () async {
if (cubit.state.isHouseKeepingOrdered) return;
final result = await context.push(AppRoutes.houseKeeping, extra: booking);
if (result != null && !cubit.isClosed) {
cubit.orderHouseKeeping(result as List<String>);
}
if (!cubit.isClosed) cubit.checkIfHouseKeepingOrdered();
},
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
children: [
Container(
height: 36,
width: 36,
decoration: const BoxDecoration(
color: colorSecondary,
shape: BoxShape.circle,
),
child: Padding(
padding: const EdgeInsets.all(10.0),
child: SvgPicture.asset(Assets.icons.iconHousekeepingCleaning.path),
),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
cubit.state.isHouseKeepingOrdered == true
? context.strings.booking_details_page_housekeeping_button_title_ordered
: context.strings.booking_details_page_housekeeping_button_title,
style: Theme.of(context).textTheme.headlineSmall,
maxLines: 1,
),
Text(
cubit.state.isHouseKeepingOrdered == true
? context
.strings
.booking_details_page_housekeeping_button_subtitle_ordered
: context.strings.booking_details_page_housekeeping_button_subtitle,
maxLines: 1,
softWrap: true,
style: Theme.of(context).textTheme.bodySmall?.copyWith(color: Colors.grey),
),
],
),
),
const SizedBox(width: 12),
if (cubit.state.isHouseKeepingOrdered == true)
SvgPicture.asset(Assets.icons.icCheckmark.path)
else
SvgPicture.asset(Assets.icons.arrowLeft.path),
],
),
),
),
);
}
}