Skip to content

Commit

Permalink
feat #51: 원 콘텐츠 뷰 분리
Browse files Browse the repository at this point in the history
  • Loading branch information
enebin committed Aug 18, 2023
1 parent 952041a commit 3803207
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 25 deletions.
36 changes: 36 additions & 0 deletions Projects/DSKit/Sources/MyPage/CircleContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// CircleContentView.swift
// DSKit
//
// Created by Young Bin on 2023/08/15.
// Copyright © 2023 team.humanwave. All rights reserved.
//

import Domain
import SwiftUI

public struct CircleContentView: View {
private let metadata: CircleMetadata

public init(metadata: CircleMetadata) {
self.metadata = metadata
}

public var body: some View {
VStack(spacing: 13) {
metadata.icon
.resizable()
.frame(width: 48, height: 48)
.scaledToFit()

VStack(spacing: 0) {
Text(metadata.keyword)
.font(.Keyme.body3Semibold)

Text(String(format: "%.1f", metadata.score))
.font(.Score.mypage)
}
}
.foregroundColor(.white)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,15 @@ extension FocusedCircleView: GeometryAnimatableCircle {
.overlay {
Circle().stroke(DSKitAsset.Color.keymeWhite.swiftUIColor.opacity(0.3), lineWidth: 2)
}
.frame(width: calculatedInnerCircleRaduis(
with: CircleData(color: .clear, xPoint: 0, yPoint: 0, radius: 0.9)))
.frame(width: calculatedInnerCircleRaduis(with: CircleData.emptyCircle(radius: 0.9)))

Circle()
.fill(DSKitAsset.Color.keymeWhite.swiftUIColor.opacity(0.3))
.overlay {
Circle().stroke(DSKitAsset.Color.keymeWhite.swiftUIColor.opacity(0.3), lineWidth: 2)
}
.frame(width: calculatedInnerCircleRaduis(
with: CircleData(color: .clear, xPoint: 0, yPoint: 0, radius: 0.9 * 0.6)))
with: CircleData.emptyCircle(radius: 0.9 * 0.6)))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import SwiftUI
import Domain
import DSKit
import Foundation

/// 마이페이지 들어가자 마자 나오는 CirclePack 그래프를 이루는 원을 만들 때 쓰는 뷰
Expand All @@ -20,8 +21,6 @@ struct SubCircleView: View {

private let onTapGesture: () -> Void

@State private var isPressed = false

// outboundLength는 총 그래프 크기
// circleData.radius는 총 그래프 크기에 대한 반지름 비율
// circleData.xPoint, yPoint는 그래프 크기에 대한 좌표를 -1 ~ +1 사이로 나타낸 것
Expand Down Expand Up @@ -57,20 +56,11 @@ struct SubCircleView: View {
y: -circleData.yPoint * outboundLength / 2)

.onTapGesture(perform: onTapGesture)
.animation(.spring(), value: isPressed)
}
}
}

extension SubCircleView: GeometryAnimatableCircle {
var icon: Image {
Image(systemName: "person.fill")
}

var character: String {
"인싸력"
}

var designedCircleShape: some View {
Circle()
.fill(circleData.color)
Expand All @@ -90,16 +80,10 @@ extension SubCircleView: GeometryAnimatableCircle {
}

var circleContentView: some View {
VStack {
icon
.foregroundColor(isPressed ? .white : .black.opacity(0.4))
Text(character)
.foregroundColor(isPressed ? .white : .black.opacity(0.4))
.font(.system(size: 14))
}
.matchedGeometryEffect(
id: contentEffectID,
in: namespace,
anchor: .center)
CircleContentView(metadata: circleData.metadata)
.matchedGeometryEffect(
id: contentEffectID,
in: namespace,
anchor: .center)
}
}

0 comments on commit 3803207

Please sign in to comment.