Skip to content

Commit

Permalink
💄 [#225] SMSPageControl / 이상한 부분 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsh153 committed Aug 23, 2023
1 parent 79e57bd commit d415f93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
41 changes: 18 additions & 23 deletions Projects/Core/DesignSystem/Sources/PageControl/SMSPageControl.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import UIKit

public struct SMSPageControl: View {
var pageCount: Int
Expand All @@ -10,32 +11,26 @@ public struct SMSPageControl: View {
}

public var body: some View {
ZStack(alignment: .leading) {
HStack(spacing: 40) {
ForEach(0..<pageCount, id: \.self) { _ in
Circle()
.fill(Color.sms(.neutral(.n20)))
.frame(width: 8, height: 8)
GeometryReader { geometry in
ZStack(alignment: .leading) {
let spacing = CGFloat((Int(geometry.size.width) - (pageCount * 8)) / (pageCount - 1))
HStack(spacing: spacing) {
ForEach(0..<pageCount, id: \.self) { _ in
Circle()
.fill(Color.sms(.neutral(.n20)))
.frame(width: 8, height: 8)
}
.frame(height: 12)
}
.frame(height: 12)
}

HStack(spacing: 0) {
ForEach(0..<selectedPage, id: \.self) { page in
let isInitial = page == 0
let endCorner: Corners = page == selectedPage ? [.topRight, .bottomRight] : []
let corners: Corners = isInitial ? [.topLeft, .bottomLeft] : endCorners

Rectacgle()
.fill(page <= selectedPage ? Color.sms(.primary(.p2)) : Color.sms(. neutral(.n20)))
.frame(height: 12)
.frame(maxWidth: .infinity)
.cornerRadius(6, corners: corners)
}
Capsule()
.fill(Color.sms(.primary(.p2)))
.frame(width: CGFloat(12 + Int(geometry.size.width) / (pageCount - 1) * selectedPage), height: 12)
}
.padding(2)
.background(Color.sms(.neutral(.n10)))
.cornerRadius(20)
}
.padding(2)
.background(Color.sms(.neutral(.n10)))
.cornerRadius(20)
.frame(height: 12)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public struct InputInformationPageTitleView: View {
public var body: some View {
VStack(spacing: 16) {
SMSPageControl(pageCount: pageCount, selectedPage: selectedPage)
.padding(.horizontal, 20)

SMSSeparator()

Expand Down

0 comments on commit d415f93

Please sign in to comment.