Skip to content

Commit

Permalink
Merge branch 'develop' into feat/SAPHY-163-my-page
Browse files Browse the repository at this point in the history
  • Loading branch information
devlwh0830 authored Oct 2, 2024
2 parents 3ba5bd1 + 31660fd commit 39b87b0
Show file tree
Hide file tree
Showing 17 changed files with 314 additions and 398 deletions.
10 changes: 5 additions & 5 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ PODS:
- flutter_inappwebview_ios (0.0.1):
- Flutter
- flutter_inappwebview_ios/Core (= 0.0.1)
- OrderedSet (~> 5.0)
- OrderedSet (~> 6.0.3)
- flutter_inappwebview_ios/Core (0.0.1):
- Flutter
- OrderedSet (~> 5.0)
- OrderedSet (~> 6.0.3)
- flutter_native_splash (0.0.1):
- Flutter
- flutter_secure_storage (6.0.0):
Expand Down Expand Up @@ -85,7 +85,7 @@ PODS:
- GTMSessionFetcher/Core
- kakao_flutter_sdk_common (1.9.2):
- Flutter
- OrderedSet (5.0.0)
- OrderedSet (6.0.3)
- os_info_plugin (0.0.1):
- Flutter
- path_provider_foundation (0.0.1):
Expand Down Expand Up @@ -181,7 +181,7 @@ SPEC CHECKSUMS:
FirebaseCore: 2322423314d92f946219c8791674d2f3345b598f
FirebaseCoreInternal: df84dd300b561c27d5571684f389bf60b0a5c934
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0
flutter_inappwebview_ios: 6f63631e2c62a7c350263b13fa5427aedefe81d4
flutter_native_splash: edf599c81f74d093a4daf8e17bd7a018854bc778
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
google_sign_in_ios: 07375bfbf2620bc93a602c0e27160d6afc6ead38
Expand All @@ -190,7 +190,7 @@ SPEC CHECKSUMS:
GTMAppAuth: f69bd07d68cd3b766125f7e072c45d7340dea0de
GTMSessionFetcher: 5aea5ba6bd522a239e236100971f10cb71b96ab6
kakao_flutter_sdk_common: 049c9341e325da17ac75751a35646dbbcfa06891
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94
os_info_plugin: d89ddf87e910a0d598fc4fc69d2b8f0f8239314f
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
Expand Down
6 changes: 3 additions & 3 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YHJ3Z89MUG;
DEVELOPMENT_TEAM = VNA63RRH7K;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Saphy;
Expand Down Expand Up @@ -761,7 +761,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YHJ3Z89MUG;
DEVELOPMENT_TEAM = VNA63RRH7K;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Saphy;
Expand Down Expand Up @@ -789,7 +789,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = YHJ3Z89MUG;
DEVELOPMENT_TEAM = VNA63RRH7K;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Saphy;
Expand Down
92 changes: 49 additions & 43 deletions lib/models/product.dart
Original file line number Diff line number Diff line change
@@ -1,53 +1,59 @@
class Product {
int? id;
String? brand;
String? name;
String? description;
String? color;
String? storage;
String? grade;
String? imageUrl;
double? price;
int? stock;
int id;
String deviceType;
String name;
String description;
double price;
int stock;
Map<String, String> images; // 이미지 정보를 Map<String, String>으로 저장
String brand;
String color;
String storage;
String grade;

Product({
this.id,
this.brand,
this.name,
this.description,
this.color,
this.storage,
this.grade,
this.imageUrl,
this.price,
this.stock,
required this.id,
required this.deviceType,
required this.name,
required this.description,
required this.price,
required this.stock,
required this.images,
required this.brand,
required this.color,
required this.storage,
required this.grade,
});

Product.fromJson(Map<String, dynamic> json) {
id = int.parse(json['id']);
brand = json['brand'];
name = json['name'];
description = json['description'];
color = json['color'];
storage = json['storage'];
grade = json['grade'];
imageUrl = json['imageUrl'];
price = double.parse(json['price']);
stock = int.parse(json['stock']);
factory Product.fromJson(Map<String, dynamic> json) {
return Product(
id: json['id'],
deviceType: json['deviceType'],
name: json['name'],
description: json['description'],
price: json['price'],
stock: json['stock'],
images: Map<String, String>.from(json['images']), // 직접 변환
brand: json['brand'],
color: json['color'],
storage: json['storage'],
grade: json['grade'],
);
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = {};
data['id'] = id;
data['brand'] = brand;
data['name'] = name;
data['description'] = description;
data['color'] = color;
data['storage'] = storage;
data['grade'] = grade;
data['imageUrl'] = imageUrl;
data['price'] = price;
data['stock'] = stock;
return data;
return {
'id': id,
'deviceType': deviceType,
'name': name,
'description': description,
'price': price,
'stock': stock,
'images': images, // 직접 저장
'brand': brand,
'color': color,
'storage': storage,
'grade': grade,
};
}
}
129 changes: 43 additions & 86 deletions lib/screens/main/main_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:dio/dio.dart';
import 'package:saphy/models/product.dart';
import 'package:saphy/utils/colors.dart';
import 'package:saphy/utils/textstyles.dart';
Expand All @@ -16,87 +19,25 @@ class MainScreen extends StatefulWidget {
class _MainScreenState extends State<MainScreen> {
final NumberFormat numberFormat = NumberFormat('###,###,###,###');
final int productLength = 6;
List<Product> productList = [
// 그냥 구현용 샘플 데이터
Product(
id: 1,
brand: "Apple",
name: "iPhone 13",
description: 'Latest iPhone model with A15 Bionic chip',
color: 'Black',
storage: '128GB',
grade: 'A',
imageUrl:
'https://i.pinimg.com/564x/f3/54/dc/f354dc1f040fc1fc4dfc4c436ad52159.jpg',
price: 250000,
stock: 50,
),
Product(
id: 2,
brand: "Apple",
name: "iPhone 13",
description: 'Latest iPhone model with A15 Bionic chip',
color: 'White',
storage: '128GB',
grade: 'A',
imageUrl:
'https://i.pinimg.com/564x/f3/54/dc/f354dc1f040fc1fc4dfc4c436ad52159.jpg',
price: 250000,
stock: 45,
),
Product(
id: 3,
brand: "Apple",
name: "iPhone 13",
description: 'Latest iPhone model with A15 Bionic chip',
color: 'Blue',
storage: '256GB',
grade: 'B',
imageUrl:
'https://i.pinimg.com/564x/f3/54/dc/f354dc1f040fc1fc4dfc4c436ad52159.jpg',
price: 270000,
stock: 40,
),
Product(
id: 4,
brand: "Apple",
name: "iPhone 13",
description: 'Latest iPhone model with A15 Bionic chip',
color: 'Red',
storage: '256GB',
grade: 'A',
imageUrl:
'https://i.pinimg.com/564x/f3/54/dc/f354dc1f040fc1fc4dfc4c436ad52159.jpg',
price: 280000,
stock: 35,
),
Product(
id: 5,
brand: "Apple",
name: "iPhone 13",
description: 'Latest iPhone model with A15 Bionic chip',
color: 'Green',
storage: '128GB',
grade: 'C',
imageUrl:
'https://i.pinimg.com/564x/f3/54/dc/f354dc1f040fc1fc4dfc4c436ad52159.jpg',
price: 240000,
stock: 30,
),
Product(
id: 6,
brand: "Apple",
name: "iPhone 13",
description: 'Latest iPhone model with A15 Bionic chip',
color: 'Pink',
storage: '512GB',
grade: 'B',
imageUrl:
// Future<List<Product>> getProduct = getProducts();

Product product = Product(
id: 1,
name: "iPhone 14",
brand: "Apple",
images: {
"name": "iPhone 14",
'url':
'https://i.pinimg.com/564x/f3/54/dc/f354dc1f040fc1fc4dfc4c436ad52159.jpg',
price: 290000,
stock: 20,
),
];
},
price: 130000.0,
description: "Latest model from Apple with advanced features.",
color: "Green",
storage: "128GB",
grade: "A",
deviceType: "phone",
stock: 10,
);

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -127,12 +68,9 @@ class _MainScreenState extends State<MainScreen> {
spacing: 15,
runSpacing: 15,
children: [
for (int i = 0; i < productLength; i++)
ProductCard(
brand: productList[i].brand ?? "",
name: productList[i].name ?? "",
imageUrl: productList[i].imageUrl ?? "",
price: productList[i].price ?? 0),
ProductCard(
product: product,
)
],
),
),
Expand All @@ -141,4 +79,23 @@ class _MainScreenState extends State<MainScreen> {
),
);
}

Future<List<Product>> getProducts() async {
final dio = Dio();
try {
final response = await dio.get('https://saphy.site/item-wishes');
if (response.statusCode == 200) {
List<Product> products = (response.data as List)
.map((item) => Product.fromJson(item))
.toList();
return products;
} else {
throw Exception('Failed to load products');
}
} catch (e) {
// ignore: avoid_print
print('Error: $e');
return []; // Return an empty list in case of error
}
}
}
Loading

0 comments on commit 39b87b0

Please sign in to comment.