Created
May 5, 2024 04:17
-
-
Save jwson-automation/75ebfac88ea04e0adfbc7ef3214c48f4 to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Hotel Booking App', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
visualDensity: VisualDensity.adaptivePlatformDensity, | |
), | |
home: HotelBookingPage(), | |
debugShowCheckedModeBanner: false, | |
); | |
} | |
} | |
class HotelBookingPage extends StatelessWidget { | |
final List<ItemDTO> items = [ | |
ItemDTO( | |
itemId: '1', | |
title: '스탠다드 더블', | |
originalPrice: 215000, | |
discountedPrice: 151000, | |
description: 'Room Only', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-G64Zy6ZCVtJSG5hP3i3JsYQb.png%3Fst%3D2024-05-05T03%253A17%253A08Z%26se%3D2024-05-05T05%253A17%253A08Z%26sp%3Dr%26sv%3D2021-08-06%26sr%3Db%26rscd%3Dinline%26rsct%3Dimage%2Fpng%26skoid%3D6aaadede-4fb3-4698-a8f6-684d7786b067%26sktid%3Da48cca56-e6da-484e-a814-9c849652bcb3%26skt%3D2024-05-04T21%253A15%253A49Z%26ske%3D2024-05-05T21%253A15%253A49Z%26sks%3Db%26skv%3D2021-08-06%26sig%3D0301H6mZ5i9eNdlhKB51CfOVfgxK8xwd0hhZ1FlalyY%253D', | |
category: '객실형태', | |
isMain: true, | |
productTitle: '스탠다드 더블', | |
productDescription: '기준 2인 - 최대 2인', | |
), | |
ItemDTO( | |
itemId: '2', | |
title: '스위트 더블', | |
originalPrice: 309760, | |
discountedPrice: 267000, | |
description: 'Room Only', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-l396Rk4Cw2jdY9eBhNuk3aaC.png%3Fst%3D2024-05-05T03%253A17%253A08Z%26se%3D2024-05-05T05%253A17%253A08Z%26sp%3Dr%26sv%3D2021-08-06%26sr%3Db%26rscd%3Dinline%26rsct%3Dimage%2Fpng%26skoid%3D6aaadede-4fb3-4698-a8f6-684d7786b067%26sktid%3Da48cca56-e6da-484e-a814-9c849652bcb3%26skt%3D2024-05-04T21%253A14%253A48Z%26ske%3D2024-05-05T21%253A14%253A48Z%26sks%3Db%26skv%3D2021-08-06%26sig%3DezGo18vnkYQVL8VtietyBE6Ltb2WoWswGrzPdPS5S5U%253D', | |
category: '객실형태', | |
isMain: false, | |
productTitle: '스위트 더블', | |
productDescription: '기준 2인 - 최대 2인', | |
), | |
ItemDTO( | |
itemId: '3', | |
title: '스위트 트윈', | |
originalPrice: 290000, | |
discountedPrice: 267000, | |
description: 'Room Only', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-5eRW03K0Y5L5eBCZbXyhdry1.png%3Fst%3D2024-05-05T03%253A17%253A05Z%26se%3D2024-05-05T05%253A17%253A05Z%26sp%3Dr%26sv%3D2021-08-06%26sr%3Db%26rscd%3Dinline%26rsct%3Dimage%2Fpng%26skoid%3D6aaadede-4fb3-4698-a8f6-684d7786b067%26sktid%3Da48cca56-e6da-484e-a814-9c849652bcb3%26skt%3D2024-05-04T21%253A27%253A45Z%26ske%3D2024-05-05T21%253A27%253A45Z%26sks%3Db%26skv%3D2021-08-06%26sig%3DuVOBp%252Bl0KcAvrFzL6QcKBYIo6rQt5NqhB1oTq%2FCi6V4%253D', | |
category: '객실형태', | |
isMain: false, | |
productTitle: '스위트 트윈', | |
productDescription: '기준 2인 - 최대 2인', | |
), | |
// Repeat for each item | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
leading: Icon(Icons.arrow_back), | |
actions: [Icon(Icons.favorite_border)], | |
backgroundColor: Colors.white, | |
iconTheme: IconThemeData(color: Colors.black), | |
elevation: 0, | |
), | |
body: ListView.builder( | |
itemCount: items.length, | |
itemBuilder: (context, index) { | |
final item = items[index]; | |
return Card( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Image.network(item.imageUrl, fit: BoxFit.cover), | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Text( | |
item.productTitle, | |
style: TextStyle( | |
fontSize: 18.0, | |
fontWeight: FontWeight.bold, | |
), | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 8.0), | |
child: Text( | |
item.productDescription, | |
style: TextStyle( | |
fontSize: 14.0, | |
color: Colors.grey, | |
), | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.all(8.0), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
Text( | |
'${item.discountedPrice}원', | |
style: TextStyle( | |
fontSize: 22.0, | |
fontWeight: FontWeight.bold, | |
color: Colors.red, | |
), | |
), | |
Text( | |
'8,000원 적립금', | |
style: TextStyle( | |
fontSize: 14.0, | |
color: Colors.blue, | |
), | |
), | |
], | |
), | |
), | |
Padding( | |
padding: const EdgeInsets.symmetric(horizontal: 8.0), | |
child: Text( | |
'체크인 15:00 이후 체크아웃 12:00', | |
style: TextStyle( | |
fontSize: 12.0, | |
color: Colors.grey, | |
), | |
), | |
), | |
], | |
), | |
); | |
}, | |
), | |
); | |
} | |
} | |
class ItemDTO { | |
final String itemId; | |
final String title; | |
final num originalPrice; | |
final num discountedPrice; | |
final String description; | |
final String imageUrl; | |
final String category; | |
final bool isMain; | |
final String productTitle; | |
final String productDescription; | |
final num viewCount; | |
final List<String> isSelled; | |
final List<String> selled; | |
final List<String> isLiked; | |
final List<ItemDTO> recommendedItems; | |
final DateTime createdAt; | |
ItemDTO({ | |
required this.itemId, | |
required this.title, | |
required this.originalPrice, | |
required this.discountedPrice, | |
required this.description, | |
required this.imageUrl, | |
required this.category, | |
required this.isMain, | |
required this.productTitle, | |
required this.productDescription, | |
DateTime? createdAt, | |
num? viewCount, | |
List<String>? isSell, | |
List<String>? totalSell, | |
List<String>? isLiked, | |
List<ItemDTO>? recommendedItems, | |
}) : createdAt = createdAt ?? DateTime.now(), | |
viewCount = viewCount ?? 0, | |
isSelled = isSell ?? [], | |
selled = totalSell ?? [], | |
isLiked = isLiked ?? [], | |
recommendedItems = recommendedItems ?? []; | |
Map<String, dynamic> toMap() { | |
return { | |
'itemId': itemId, | |
'title': title, | |
'originalPrice': originalPrice, | |
'discountedPrice': discountedPrice, | |
'description': description, | |
'imageUrl': imageUrl, | |
'category': category, | |
'createdAt': createdAt.toIso8601String(), | |
'isMain': isMain, | |
'productTitle': productTitle, | |
'productDescription': productDescription, | |
}; | |
} | |
factory ItemDTO.fromMap(Map<String, dynamic> map) { | |
return ItemDTO( | |
itemId: map['itemId'], | |
title: map['title'], | |
originalPrice: map['originalPrice'], | |
discountedPrice: map['discountedPrice'], | |
description: map['description'], | |
imageUrl: map['imageUrl'], | |
category: map['category'], | |
isMain: map['isMain'], | |
productTitle: map['productTitle'], | |
productDescription: map['productDescription'], | |
createdAt: DateTime.parse(map['createdAt']), | |
viewCount: map['viewCount'] as num?, | |
isSell: List<String>.from(map['isSelled'] ?? []), | |
totalSell: List<String>.from(map['selled'] ?? []), | |
isLiked: List<String>.from(map['isLiked'] ?? []), | |
recommendedItems: (map['recommendedItems'] as List?) | |
?.map((item) => ItemDTO.fromMap(item)) | |
.toList() ?? | |
[], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment