Skip to content

Commit d8efa54

Browse files
committed
Update travel_carousel.dart
1 parent ab350c8 commit d8efa54

File tree

1 file changed

+104
-89
lines changed

1 file changed

+104
-89
lines changed

examples/travel_app/lib/src/catalog/travel_carousel.dart

Lines changed: 104 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import 'package:dart_schema_builder/dart_schema_builder.dart';
88
import 'package:flutter/material.dart';
99
import 'package:flutter_genui/flutter_genui.dart';
1010

11+
import '../tools/booking/booking_service.dart';
12+
import '../tools/booking/model.dart';
13+
1114
final _schema = S.object(
1215
properties: {
1316
'title': S.string(
@@ -77,95 +80,7 @@ final travelCarousel = CatalogItem(
7780
dispatchEvent: dispatchEvent,
7881
);
7982
},
80-
exampleData: [
81-
() => {
82-
'root': 'greece_inspiration_column',
83-
'widgets': [
84-
{
85-
'id': 'greece_inspiration_column',
86-
'widget': {
87-
'Column': {
88-
'children': ['inspiration_title', 'inspiration_carousel'],
89-
},
90-
},
91-
},
92-
{
93-
'id': 'inspiration_title',
94-
'widget': {
95-
'Text': {
96-
'text':
97-
"Let's plan your dream trip to Greece! "
98-
'What kind of experience'
99-
' are you looking for?',
100-
},
101-
},
102-
},
103-
{
104-
'widget': {
105-
'TravelCarousel': {
106-
'items': [
107-
{
108-
'title': 'Relaxing Beach Holiday',
109-
'imageChildId': 'santorini_beach_image',
110-
'listingSelectionId': '12345',
111-
},
112-
{
113-
'imageChildId': 'akrotiri_fresco_image',
114-
'title': 'Cultural Exploration',
115-
'listingSelectionId': '12346',
116-
},
117-
{
118-
'imageChildId': 'santorini_caldera_image',
119-
'title': 'Adventure & Outdoors',
120-
'listingSelectionId': '12347',
121-
},
122-
{'title': 'Foodie Tour', 'imageChildId': 'greece_food_image'},
123-
],
124-
},
125-
},
126-
'id': 'inspiration_carousel',
127-
},
128-
{
129-
'id': 'santorini_beach_image',
130-
'widget': {
131-
'Image': {
132-
'fit': 'cover',
133-
'assetName': 'assets/travel_images/santorini_panorama.jpg',
134-
},
135-
},
136-
},
137-
{
138-
'id': 'akrotiri_fresco_image',
139-
'widget': {
140-
'Image': {
141-
'fit': 'cover',
142-
'assetName':
143-
'assets/travel_images/akrotiri_spring_fresco_santorini.jpg',
144-
},
145-
},
146-
},
147-
{
148-
'id': 'santorini_caldera_image',
149-
'widget': {
150-
'Image': {
151-
'assetName': 'assets/travel_images/santorini_from_space.jpg',
152-
'fit': 'cover',
153-
},
154-
},
155-
},
156-
{
157-
'widget': {
158-
'Image': {
159-
'fit': 'cover',
160-
'assetName':
161-
'assets/travel_images/saffron_gatherers_fresco_santorini.jpg',
162-
},
163-
},
164-
'id': 'greece_food_image',
165-
},
166-
],
167-
},
168-
],
83+
exampleData: [_inspirationExample, _hotelExample],
16984
);
17085

17186
extension type _TravelCarouselData.fromMap(Map<String, Object?> _json) {
@@ -327,3 +242,103 @@ class _TravelCarouselItem extends StatelessWidget {
327242
);
328243
}
329244
}
245+
246+
JsonMap _hotelExample() {
247+
final hotels = BookingService.instance.listHotelsSync(
248+
HotelSearch(
249+
query: '',
250+
checkIn: DateTime.now(),
251+
checkOut: DateTime.now().add(Duration(days: 7)),
252+
guests: 2,
253+
),
254+
);
255+
return {};
256+
}
257+
258+
JsonMap _inspirationExample() => {
259+
'root': 'greece_inspiration_column',
260+
'widgets': [
261+
{
262+
'id': 'greece_inspiration_column',
263+
'widget': {
264+
'Column': {
265+
'children': ['inspiration_title', 'inspiration_carousel'],
266+
},
267+
},
268+
},
269+
{
270+
'id': 'inspiration_title',
271+
'widget': {
272+
'Text': {
273+
'text':
274+
"Let's plan your dream trip to Greece! "
275+
'What kind of experience'
276+
' are you looking for?',
277+
},
278+
},
279+
},
280+
{
281+
'widget': {
282+
'TravelCarousel': {
283+
'items': [
284+
{
285+
'title': 'Relaxing Beach Holiday',
286+
'imageChildId': 'santorini_beach_image',
287+
'listingSelectionId': '12345',
288+
},
289+
{
290+
'imageChildId': 'akrotiri_fresco_image',
291+
'title': 'Cultural Exploration',
292+
'listingSelectionId': '12346',
293+
},
294+
{
295+
'imageChildId': 'santorini_caldera_image',
296+
'title': 'Adventure & Outdoors',
297+
'listingSelectionId': '12347',
298+
},
299+
{'title': 'Foodie Tour', 'imageChildId': 'greece_food_image'},
300+
],
301+
},
302+
},
303+
'id': 'hotel_carousel',
304+
},
305+
{
306+
'id': 'santorini_beach_image',
307+
'widget': {
308+
'Image': {
309+
'fit': 'cover',
310+
'assetName': 'assets/travel_images/santorini_panorama.jpg',
311+
},
312+
},
313+
},
314+
{
315+
'id': 'akrotiri_fresco_image',
316+
'widget': {
317+
'Image': {
318+
'fit': 'cover',
319+
'assetName':
320+
'assets/travel_images/akrotiri_spring_fresco_santorini.jpg',
321+
},
322+
},
323+
},
324+
{
325+
'id': 'santorini_caldera_image',
326+
'widget': {
327+
'Image': {
328+
'assetName': 'assets/travel_images/santorini_from_space.jpg',
329+
'fit': 'cover',
330+
},
331+
},
332+
},
333+
{
334+
'widget': {
335+
'Image': {
336+
'fit': 'cover',
337+
'assetName':
338+
'assets/travel_images/saffron_gatherers_fresco_santorini.jpg',
339+
},
340+
},
341+
'id': 'greece_food_image',
342+
},
343+
],
344+
};

0 commit comments

Comments
 (0)