From b7b13409b8315357d890c2ace6188a636dbf3d9a Mon Sep 17 00:00:00 2001 From: MaraMincho <103064352+MaraMincho@users.noreply.github.com> Date: Mon, 20 Nov 2023 20:31:19 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20GWPageControl=20=ED=95=A8=EC=88=98=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DesignSystem/Sources/GWPageConrol.swift | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/iOS/Projects/Shared/DesignSystem/Sources/GWPageConrol.swift b/iOS/Projects/Shared/DesignSystem/Sources/GWPageConrol.swift index f1d01b15..d58a416b 100644 --- a/iOS/Projects/Shared/DesignSystem/Sources/GWPageConrol.swift +++ b/iOS/Projects/Shared/DesignSystem/Sources/GWPageConrol.swift @@ -27,7 +27,7 @@ public final class GWPageControl: UIView { count : UIPageControlDefaultProperty.numOfMinPage - super.init(frame: .init(origin: .zero, size: CGSize(width: 60, height: 10))) + super.init(frame: .zero) makePages() makePageConstraints() @@ -81,26 +81,25 @@ private extension GWPageControl { public extension GWPageControl { func select(at pageIndex: Int) { - if pageIndex >= pages.count { + if pageIndex >= pages.count || currentPageIndex <= 0 { return } updateDeselectPage(at: currentPageIndex) currentPageIndex = pageIndex updateSelectPage(at: currentPageIndex) + + startAnimation() } func next() { - if currentPageIndex >= pages.count { + if currentPageIndex >= pages.count || currentPageIndex <= 0 { return } updateDeselectPage(at: currentPageIndex) currentPageIndex += 1 updateSelectPage(at: currentPageIndex) - UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseInOut) { [weak self] in - guard let self else { return } - layoutIfNeeded() - } + startAnimation() } func back() { @@ -111,14 +110,18 @@ public extension GWPageControl { currentPageIndex -= 1 updateSelectPage(at: currentPageIndex) + startAnimation() + } +} + +private extension GWPageControl { + func startAnimation() { UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseInOut) { [weak self] in guard let self else { return } layoutIfNeeded() } } -} -private extension GWPageControl { func updateSelectPage(at pageIndex: Int) { guard 0 ..< pages.count ~= pageIndex else { return