6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 91a08ee6

AuthorEdmir Suljic<esu@dwarf.dk>
Date2025-06-06 14:03:00 +0200
Mid fix

Changed files

.../components/hotel_information_menu.dart         |  8 +---
 .../hotel_information/components/image_widget.dart | 47 ++++++++++++++++++++++
 .../components/parking_facility_page.dart          | 13 ++----
 .../components/restaurant_page.dart                |  9 +----
 .../components/spa_facility_page.dart              |  9 +----
 .../cubit/hotel_information_cubit.dart             |  1 +
 6 files changed, 58 insertions(+), 29 deletions(-)

Diff

diff --git a/comwell_key_app/lib/hotel_information/components/hotel_information_menu.dart b/comwell_key_app/lib/hotel_information/components/hotel_information_menu.dart
index 17420f22..43cbefd3 100644
--- a/comwell_key_app/lib/hotel_information/components/hotel_information_menu.dart
+++ b/comwell_key_app/lib/hotel_information/components/hotel_information_menu.dart
@@ -1,3 +1,4 @@
+import 'package:comwell_key_app/hotel_information/components/image_widget.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -17,12 +18,7 @@ class HotelInformationMenu extends StatelessWidget {
final height = MediaQuery.of(context).size.height;
return Column(
children: [
- Image.network(
- hotel.image,
- height: height * 0.4,
- width: double.infinity,
- fit: BoxFit.cover,
- ),
+ ImageWidget(image: hotel.image),
Expanded(
child: SingleChildScrollView(
child: Padding(
diff --git a/comwell_key_app/lib/hotel_information/components/image_widget.dart b/comwell_key_app/lib/hotel_information/components/image_widget.dart
new file mode 100644
index 00000000..c1afec8c
--- /dev/null
+++ b/comwell_key_app/lib/hotel_information/components/image_widget.dart
@@ -0,0 +1,47 @@
+import 'package:flutter/material.dart';
+
+class ImageWidget extends StatelessWidget {
+ final String image;
+ const ImageWidget({super.key, required this.image});
+
+ @override
+ Widget build(BuildContext context) {
+ final height = MediaQuery.of(context).size.height;
+ final theme = Theme.of(context);
+
+ return Container(
+ height: height * 0.4,
+ width: double.infinity,
+ child: Image.network(
+ image,
+ fit: BoxFit.cover,
+ errorBuilder: (context, error, stackTrace) {
+ return Container(
+ color: theme.colorScheme.surfaceVariant,
+ child: Center(
+ child: Icon(
+ Icons.image_not_supported_outlined,
+ size: 48,
+ color: theme.colorScheme.onSurfaceVariant,
+ ),
+ ),
+ );
+ },
+ loadingBuilder: (context, child, loadingProgress) {
+ if (loadingProgress == null) return child;
+ return Container(
+ color: theme.colorScheme.surfaceVariant,
+ child: Center(
+ child: CircularProgressIndicator(
+ value: loadingProgress.expectedTotalBytes != null
+ ? loadingProgress.cumulativeBytesLoaded /
+ loadingProgress.expectedTotalBytes!
+ : null,
+ ),
+ ),
+ );
+ },
+ ),
+ );
+ }
+}
\ No newline at end of file
diff --git a/comwell_key_app/lib/hotel_information/components/parking_facility_page.dart b/comwell_key_app/lib/hotel_information/components/parking_facility_page.dart
index 6edce327..b49deb22 100644
--- a/comwell_key_app/lib/hotel_information/components/parking_facility_page.dart
+++ b/comwell_key_app/lib/hotel_information/components/parking_facility_page.dart
@@ -1,3 +1,4 @@
+import 'package:comwell_key_app/hotel_information/components/image_widget.dart';
import 'package:comwell_key_app/hotel_information/models/parking_info.dart';
import 'package:flutter/material.dart';
@@ -8,7 +9,6 @@ class ParkingFacilityPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
- final height = MediaQuery.of(context).size.height;
final theme = Theme.of(context);
return Scaffold(
@@ -17,12 +17,7 @@ class ParkingFacilityPage extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
- Image.asset(
- 'assets/images/parking.png',
- height: height * 0.4,
- width: double.infinity,
- fit: BoxFit.cover,
- ),
+ const ImageWidget(image: 'assets/images/parking.png'),
Expanded(
child: SingleChildScrollView(
child: Padding(
@@ -48,8 +43,8 @@ class ParkingFacilityPage extends StatelessWidget {
style: block.type == "headerBlock"
? theme.textTheme.headlineSmall
: theme.textTheme.bodySmall?.copyWith(
- color: Colors.black.withValues(alpha: 0.65),
- ),
+ color: Colors.black.withValues(alpha: 0.65),
+ ),
),
);
}).toList(),
diff --git a/comwell_key_app/lib/hotel_information/components/restaurant_page.dart b/comwell_key_app/lib/hotel_information/components/restaurant_page.dart
index 0fba113f..b41faf90 100644
--- a/comwell_key_app/lib/hotel_information/components/restaurant_page.dart
+++ b/comwell_key_app/lib/hotel_information/components/restaurant_page.dart
@@ -1,4 +1,5 @@
import 'package:comwell_key_app/hotel_information/components/contact_hotel_button.dart';
+import 'package:comwell_key_app/hotel_information/components/image_widget.dart';
import 'package:comwell_key_app/hotel_information/components/maps_bottom_modal.dart';
import 'package:comwell_key_app/hotel_information/models/restaurant.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
@@ -14,18 +15,12 @@ class RestaurantPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
- final height = MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor: Colors.white,
body: Column(
children: [
- Image.network(
- restaurant.image,
- height: height * 0.4,
- width: double.infinity,
- fit: BoxFit.cover,
- ),
+ ImageWidget(image: restaurant.image),
Expanded(
child: SingleChildScrollView(
child: Padding(
diff --git a/comwell_key_app/lib/hotel_information/components/spa_facility_page.dart b/comwell_key_app/lib/hotel_information/components/spa_facility_page.dart
index d73098fa..a12b2e17 100644
--- a/comwell_key_app/lib/hotel_information/components/spa_facility_page.dart
+++ b/comwell_key_app/lib/hotel_information/components/spa_facility_page.dart
@@ -1,3 +1,4 @@
+import 'package:comwell_key_app/hotel_information/components/image_widget.dart';
import 'package:comwell_key_app/hotel_information/cubit/hotel_information_cubit.dart';
import 'package:comwell_key_app/hotel_information/models/spa.dart';
import 'package:comwell_key_app/themes/light_theme.dart';
@@ -14,7 +15,6 @@ class SpaFacilityPage extends StatelessWidget {
final cubit = context.read<HotelInformationCubit>();
final isLoading = cubit.state.spaButtonIsLoading;
final theme = Theme.of(context);
- final height = MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor: Colors.white,
@@ -73,12 +73,7 @@ class SpaFacilityPage extends StatelessWidget {
}),
body: Column(
children: [
- Image.network(
- spa.image,
- height: height * 0.4,
- width: double.infinity,
- fit: BoxFit.cover,
- ),
+ ImageWidget(image: spa.image),
Expanded(
child: SingleChildScrollView(
child: Padding(
diff --git a/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart b/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart
index 1ef90bf4..f624a460 100644
--- a/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart
+++ b/comwell_key_app/lib/hotel_information/cubit/hotel_information_cubit.dart
@@ -26,6 +26,7 @@ class HotelInformationCubit extends Cubit<HotelInformationState> {
try {
hotel = await hotelInformationRepository
.fetchHotelInformation(booking.hotelCode, culture);
+ print("hotel=${hotel.toJson()}");
emit(state.hotelSuccess());
} catch (e) {
debugPrint("error fetching hotel information for ${booking.hotelCode}: $e");