import 'package:comwell_key_app/hotel_information/models/structured_text.dart';
import 'package:comwell_key_app/hotel_information/components/address.dart';
import 'package:comwell_key_app/hotel_information/components/phone_number.dart';
import 'package:comwell_key_app/hotel_information/components/contact_hotel_button.dart';
import 'package:comwell_key_app/themes/dark_theme.dart';
import 'package:comwell_key_app/utils/l10n_utils.dart';
import 'package:flutter/material.dart';
import 'package:comwell_key_app/hotel_information/components/image_widget.dart';
import 'package:comwell_key_app/hotel_information/components/spa_booking_link.dart';
import 'package:comwell_key_app/hotel_information/components/hotel_information_list_tile.dart';
import 'package:comwell_key_app/hotel_information/components/maps_bottom_modal.dart';
import 'package:comwell_key_app/hotel_information/components/opening_hours.dart';
import 'package:comwell_key_app/hotel_information/components/page_title.dart';
import 'package:comwell_key_app/hotel_information/components/email.dart';
import 'package:comwell_key_app/utils/launch_util.dart';
class StructuredText extends StatelessWidget {
final List<StructuredTextBlock> blocks;
const StructuredText({super.key, required this.blocks});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: blocks.map((block) {
return switch (block) {
HeaderStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Text(
b.header,
style: theme.textTheme.headlineMedium,
),
),
TextModelStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Text(
b.text,
style: theme.textTheme.bodySmall?.copyWith(
color: colorHeadlineText,
),
),
),
AddressStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Address(address: b.address),
),
EmailContactStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: ContactHotelButton(
title: b.headline,
subtitle: b.email,
iconPath: "assets/icons/ic_send.svg",
onClick: () async {
await launchEmail(context, b.email,
errorMessage: context.strings.email_launch_error);
},
),
),
PhoneContactStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: PhoneNumber(phoneNumber: b.phoneNumber),
),
ImageWidgetStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: ImageWidget(image: b.image),
),
SpaBookingLinkStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: SpaBookingLink(link: b.link),
),
HotelInformationListTileStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: HotelInformationListTile(
iconPath: b.iconPath,
title: b.title,
onClick: () {}, // You may want to provide a callback
),
),
MapsBottomModalStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Builder(
builder: (context) => ElevatedButton(
onPressed: () => MapsBottomModal.show(context, b.address),
child: Text(b.address),
),
),
),
OpeningHoursStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: OpeningHours(openingHours: b.openingHours),
),
PageTitleStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: PageTitle(title: b.title),
),
PracticalInformationStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Text(
'Practical Information for Restaurant: \\${b.restaurantId}',
style: theme.textTheme.bodySmall?.copyWith(
color: colorHeadlineText,
),
),
),
EmailStructuredTextModel b => Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Email(email: b.email),
),
};
}).toList(),
);
}
}