Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Style] 컴포넌트 부착 #52

Merged
merged 15 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "testImage.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "testImage2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "testImage3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// CardPlaceModel.swift
// Spoony-iOS
//
// Created by 이지훈 on 1/15/25.
//

import Foundation

struct CardPlace: Identifiable {
let id = UUID()
let name: String
let visitorCount: String
let address: String
let images: [String]
let title: String
let subTitle: String
let description: String
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// PageIndicator.swift
// Spoony-iOS
//
// Created by 이지훈 on 1/16/25.
//

import SwiftUI

struct PageIndicator: View {
let currentPage: Int
let pageCount: Int

var body: some View {
HStack(spacing: 8) {
ForEach(0..<pageCount, id: \.self) { index in
Circle()
.fill(currentPage == index ? Color.spoonBlack : Color.gray500)
.frame(width: 6, height: 6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjust

}
}
.padding(.vertical, 4)
.padding(.horizontal, 12)
.background(Color.gray200)
.cornerRadius(48)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
//
// PlaceCard.swift
// Spoony-iOS
//
// Created by 이지훈 on 1/15/25.
//

import SwiftUI

struct PlaceCard: View {
let placeName: String
let visitorCount: String
let address: String
let images: [String]
let title: String
let subTitle: String
let description: String

var body: some View {
VStack(spacing: 0) {
PlaceImagesLayout(images: images)

VStack(alignment: .leading) {
HStack(spacing: 6) {

Text(placeName)
.font(.body1b)

// TODO: 칩으로 대체
HStack(spacing: 4) {
Image(systemName: "mug.fill")
.font(.system(size: 12))
Text("카페")
.font(.system(size: 14.5))
}
.foregroundColor(.pink400)
.padding(.horizontal, 12)
.padding(.vertical, 4)
.background(Color.pink400.opacity(0.1))
.cornerRadius(16)

Spacer()
HStack(spacing: 4) {
Image(.icAddmapGray400)
Text(visitorCount)
.font(.caption2b)
}
}
}
.padding(15)

VStack(alignment: .leading, spacing: 6) {
HStack {
Text(title)
.font(.body2b)
Text(subTitle)
.font(.caption1m)
.foregroundColor(.gray600)

}
Text(description)
.font(.caption1m)
.foregroundColor(.spoonBlack)
}
.padding(15)
.frame(maxWidth: .infinity, alignment: .leading)
.background(Color.gray0)
.cornerRadius(10)
.padding(.horizontal, 15)
.padding(.bottom, 15)
}
.background(Color.white)
.cornerRadius(16)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// PlaceCardsContainer.swift
// Spoony-iOS
//
// Created by 이지훈 on 1/15/25.
//

import SwiftUI

struct PlaceCardsContainer: View {
let places: [CardPlace]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

외부에서 안쓰면 private 하세요.

@Binding var currentPage: Int

var body: some View {
TabView(selection: $currentPage) {
ForEach(Array(places.enumerated()), id: \.element.id) { index, place in
PlaceCard(
placeName: place.name,
visitorCount: place.visitorCount,
address: place.address,
images: place.images,
title: place.title,
subTitle: place.subTitle,
description: place.description
)
.padding(.horizontal, 16)
.tag(index)
}
}
.frame(height: 280)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjust

.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
}
}

#Preview {
Home()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//
// PlaceDetailCard.swift
// Spoony-iOS
//
// Created by 이지훈 on 1/15/25.
//

import SwiftUI

struct PlaceImagesLayout: View {
let images: [String]

var body: some View {
HStack(spacing: 1) {
switch images.count {
case 1:
Image(images[0])
.resizable()
.scaledToFill()
.frame(maxWidth: .infinity)
.frame(height: 132)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjust

.clipShape(RoundedCorner(radius: 12, corners: [.topLeft, .topRight]))

case 2:
ForEach(0..<2, id: \.self) { index in
Image(images[index])
.resizable()
.scaledToFill()
.frame(maxWidth: .infinity)
.frame(height: 132)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjust

.clipShape(
RoundedCorner(
radius: 12,
corners: index == 0 ? [.topLeft] : [.topRight]
)
)
}

case 3:
ForEach(0..<3, id: \.self) { index in
Image(images[index])
.resizable()
.scaledToFill()
.frame(maxWidth: .infinity)
.frame(height: 132)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adjust

.clipShape(
RoundedCorner(
radius: 12,
corners: index == 0 ? [.topLeft] : (index == 2 ? [.topRight] : [])
)
)
}

default:
EmptyView()
}
}
}
}

#Preview {
PlaceCardsContainer(places: [
CardPlace(
name: "스타벅스",
visitorCount: "45",
address: "서울특별시 마포구 어울마당로",
images: ["testImage1", "testImage2", "testImage3"],
title: "클레오가트라",
subTitle: "성동구 수제",
description: "포켓몬 중 하나의 이름을 가졌지만 카페에요"
),
CardPlace(
name: "스타벅스",
visitorCount: "45",
address: "서울특별시 마포구 어울마당로",
images: ["testImage1", "testImage2", "testImage3"],
title: "클레오가트라",
subTitle: "성동구 수제",
description: "포켓몬 중 하나의 이름을 가졌지만 카페에요"
),
CardPlace(
name: "스타벅스",
visitorCount: "45",
address: "서울특별시 마포구 어울마당로",
images: ["testImage1", "testImage2", "testImage3"],
title: "클레오가트라",
subTitle: "성동구 수제",
description: "포켓몬 중 하나의 이름을 가졌지만 카페에요"
)
], currentPage: .constant(0))
}
Loading