Skip to content

Commit

Permalink
Merge pull request #141 from Team-Recordy/refactor/#140
Browse files Browse the repository at this point in the history
[Refactor] Signup 뷰 책임 분리
  • Loading branch information
Chandrarla authored Oct 1, 2024
2 parents 74cd0c2 + 39ef32f commit 4571b85
Show file tree
Hide file tree
Showing 19 changed files with 419 additions and 551 deletions.
53 changes: 53 additions & 0 deletions Common/Sources/Components/AgreeAllTermButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// AgreeToAllButton.swift
// Common
//
// Created by Chandrala on 7/11/24.
// Copyright © 2024 com.recordy. All rights reserved.
//

import UIKit

import SnapKit
import Then

import UIKit
import SnapKit
import Then

public class AgreeAllTermButton: RecordyTermButton {

public override init(frame: CGRect) {
super.init(frame: frame)
setStyle()
setAutolayout()
}

required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

private func setStyle() {
backgroundColor = CommonAsset.recordyGrey09.color
layer.cornerRadius = 8

agreeLabel.do {
$0.text = "전체동의"
$0.font = RecordyFont.subtitle.font
$0.textColor = CommonAsset.recordyGrey01.color
}
}

private func setAutolayout() {
self.agreeImageView.snp.makeConstraints {
$0.leading.equalTo(snp.leading).offset(20)
$0.centerY.equalToSuperview()
$0.width.height.equalTo(24)
}

self.agreeLabel.snp.makeConstraints {
$0.leading.equalTo(agreeImageView.snp.trailing).offset(16)
$0.centerY.equalToSuperview()
}
}
}
82 changes: 0 additions & 82 deletions Common/Sources/Components/AgreeToAllButton.swift

This file was deleted.

6 changes: 3 additions & 3 deletions Common/Sources/Components/RecordyButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class RecordyButton: UIButton {

public var buttonState: ButtonState = .inactive {
didSet {
updateButtonAppearance()
updateButtonStyle()
}
}

Expand All @@ -35,10 +35,10 @@ public class RecordyButton: UIButton {
private func setUI() {
layer.cornerRadius = 12
titleLabel?.font = RecordyFont.button1.font
updateButtonAppearance()
updateButtonStyle()
}

private func updateButtonAppearance() {
private func updateButtonStyle() {
switch buttonState {
case .active:
backgroundColor = CommonAsset.recordyMain.color
Expand Down
26 changes: 14 additions & 12 deletions Common/Sources/Components/RecordyProgressView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import UIKit

import SnapKit
import Then

Expand All @@ -8,25 +9,26 @@ protocol RecordyProgressViewDelegate: AnyObject {

public final class RecordyProgressView: UIView {

weak var delegate: RecordyProgressViewDelegate?
public static let shared = RecordyProgressView()

private var totalPages: Int = 0
private var currentPage: Int = 0

var ratio: CGFloat = 0.0 {
didSet {
self.progressBarView.snp.remakeConstraints {
progressBarView.snp.remakeConstraints {
$0.leading.equalToSuperview()
$0.top.equalToSuperview().offset(-2)
$0.bottom.equalToSuperview().offset(2)
$0.width.equalToSuperview().multipliedBy(self.ratio)
$0.centerY.equalToSuperview()
$0.height.equalTo(6)
$0.width.equalToSuperview().multipliedBy(ratio)
}

UIView.animate(
withDuration: 0.5,
delay: 0,
options: .curveEaseInOut,
animations: {
self.layoutIfNeeded()
layoutIfNeeded()
},
completion: nil
)
Expand All @@ -48,20 +50,20 @@ public final class RecordyProgressView: UIView {
}

func setStyle() {
self.isUserInteractionEnabled = false
self.backgroundColor = CommonAsset.recordySub01.color
self.layer.cornerRadius = 4
self.clipsToBounds = true
isUserInteractionEnabled = false
backgroundColor = CommonAsset.recordySub01.color
layer.cornerRadius = 4
clipsToBounds = true
progressBarView.layer.cornerRadius = 6
progressBarView.clipsToBounds = true
}

func setUI() {
self.addSubview(progressBarView)
addSubview(progressBarView)
}

public func updateProgress(currentPage: Int, totalPages: Int) {
let newRatio = CGFloat(currentPage + 1) / CGFloat(totalPages)
self.ratio = newRatio
ratio = newRatio
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@
// Copyright © 2024 com.recordy. All rights reserved.
//

public enum TermButtonState {
case agree
case disagree
}


import UIKit

import SnapKit
import Then

public class TermButton: UIButton {
public enum ToggleButtonState {
case activate
case deactivate
}

public class RecordyTermButton: UIButton {

public let agreeImageView = UIImageView()
public let agreeLabel = UILabel()

public var currentState: TermButtonState = .disagree
public var currentState: ToggleButtonState = .deactivate

public override init(frame: CGRect) {
super.init(frame: frame)
Expand All @@ -47,37 +46,26 @@ public class TermButton: UIButton {
}

private func setUI() {
self.addSubviews(
addSubviews(
agreeImageView,
agreeLabel
)
}

private func setAutolayout() {
self.agreeImageView.snp.makeConstraints {
agreeImageView.snp.makeConstraints {
$0.leading.equalToSuperview().offset(24)
$0.width.height.equalTo(16)
$0.centerY.equalToSuperview()
}

self.agreeLabel.snp.makeConstraints {
agreeLabel.snp.makeConstraints {
$0.leading.equalTo(agreeImageView.snp.trailing).offset(20)
$0.centerY.equalToSuperview()
}
}

public func toggleState() {
currentState = (currentState == .agree) ? .disagree : .agree
updateAgreeToggleButton()
}

public func updateAgreeToggleButton() {
self.agreeImageView.image = (currentState == .agree) ? CommonAsset.activateCheck.image : CommonAsset.deactivateCheck.image
}

public func updateState(_ state: TermButtonState) {
currentState = state
updateAgreeToggleButton()
public func updateUI(_ state: ToggleButtonState) {
agreeImageView.image = (state == .activate) ? CommonAsset.activateCheck.image : CommonAsset.deactivateCheck.image
}
}

Loading

0 comments on commit 4571b85

Please sign in to comment.