Skip to content

Commit

Permalink
#26 [Style] imagePlaceHolder 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
soletree committed May 16, 2024
1 parent 2cfbdcb commit d2a948c
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions Score/Score/Extension/Image+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// Image+.swift
// Score
//
// Created by sole on 4/27/24.
//

import SwiftUI

//MARK: - Image+imagePlaceHolder

extension Image {

//MARK: - imagePlaceHolder

/// image 플레이스 홀더가 필요한 사진의 경우에 사용합니다.
/// 플레이스 홀더를 원형의 size*size로 생성합니다.
@ViewBuilder
func imagePlaceHolder(size: CGFloat) -> some View {
self
.resizable()
.frame(width: 130,
height: 130)
.clipShape(Circle())
.background {
Circle()
.frame(width: size,
height: size)
.foregroundStyle(
Color.brandColor(color: .gray2)
)
}
.frame(width: size,
height: size)
}
}

extension Image? {

@ViewBuilder
func imagePlaceHolder(size: CGFloat) -> some View {
let image: Image = self ?? Image("")
image
.resizable()
.frame(width: 130,
height: 130)
.clipShape(Circle())
.background {
Circle()
.frame(width: size,
height: size)
.foregroundStyle(
Color.brandColor(color: .gray2)
)
}
.frame(width: size,
height: size)
}
}

0 comments on commit d2a948c

Please sign in to comment.