import 'package:comwell_key_app/presentation/screens/house_keeping/components/housekeeping_service.dart';
import 'package:comwell_key_app/presentation/screens/house_keeping/components/selectable_service.dart';
import 'package:comwell_key_app/presentation/screens/house_keeping/cubit/housekeeping_cubit.dart';
import 'package:comwell_key_app/presentation/screens/house_keeping/cubit/housekeeping_state.dart';
import 'package:comwell_key_app/overview/models/booking.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:go_router/go_router.dart';
import '../../../common/components/comwell_app_bar.dart';
class HousekeepingPage extends StatefulWidget {
final Booking booking;
const HousekeepingPage({super.key, required this.booking});
@override
State<HousekeepingPage> createState() => _HousekeepingPageState();
}
class _HousekeepingPageState extends State<HousekeepingPage> {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return BlocProvider(
create: (context) => HouseKeepingCubit(),
child: BlocBuilder<HouseKeepingCubit, HouseKeepingState>(
builder: (context, state) {
final cubit = context.read<HouseKeepingCubit>();
return Scaffold(
backgroundColor: Colors.white,
appBar: const ComwellAppBar(),
bottomNavigationBar: Builder(builder: (context) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
const Divider(
color: colorDivider,
height: 0,
),
Row(
children: [
Expanded(
child: Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
onPressed: () async {
final selectedServices = await cubit
.onOrderHousekeepingClicked(widget.booking);
if (context.mounted) {
context.pop(selectedServices);
}
},
style: const ButtonStyle(
backgroundColor:
WidgetStatePropertyAll(Color(0xffAA8D65)),
foregroundColor:
WidgetStatePropertyAll(Colors.white)),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: Text(context.strings.housekeeping_page_button),
),
),
),
),
],
),
],
);
}),
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: ListView(
children: [
const SizedBox(height: 20),
Text(context.strings.housekeeping_page_title,
style: theme.textTheme.headlineLarge),
const SizedBox(height: 8),
Text(
context.strings.housekeeping_page_subtitle,
style: theme.textTheme.bodySmall,
),
const SizedBox(height: 25),
Text(
context.strings.housekeeping_page_cleaning,
style: theme.textTheme.headlineMedium,
),
const SizedBox(height: 12),
SelectableService(
key: ValueKey(HouseKeepingService.cleaning.name),
service: HouseKeepingService.cleaning,
),
const SizedBox(height: 22),
Text(context.strings.housekeeping_page_supplies,
style: theme.textTheme.headlineMedium),
const SizedBox(height: 12),
...cubit.servicesSupplies.map((service) {
return Column(
children: [
SelectableService(service: service),
const SizedBox(height: 12)
],
);
}),
const SizedBox(height: 40)
],
),
),
);
}),
);
}
}