Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#13] HandyFab 생성 #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

[#13] HandyFab 생성 #16

wants to merge 1 commit into from

Conversation

wjdalswl
Copy link
Member

@wjdalswl wjdalswl commented Aug 8, 2024

📌 Summary

HandyFab를 생성했습니다.

✍️ Description

💡 PR Point

다른 브랜치에서 HandyIcon 파일을 만드셨길래, 아직 icon 작업은 하지 않았습니다!

지금은 setConfiguration() 안에 size설정, cornerRadius 설정, 아이콘 설정, state변화에 따른 색상변화 등을 모두 한 곳에 넣어두었는데, 분리를 하는게 좋을지 고민입니다.

    private func setConfiguration() {
        NSLayoutConstraint.activate([
            widthAnchor.constraint(equalToConstant: size.fabSize),
            heightAnchor.constraint(equalToConstant: size.fabSize)
        ])
        self.layer.cornerRadius = size.fabSize / 2
        self.layer.borderWidth = type == .secondary ? 1 : 0

        var configuration = UIButton.Configuration.plain()

        let iconConfig = UIImage.SymbolConfiguration(pointSize: 24, weight: .regular)
        let iconImage = iconImage == nil ? UIImage(
            systemName: size.icon,
            withConfiguration: iconConfig
        ): iconImage
        
//        TODO: - HandyIcon으로 아이콘 변경, pointSize 삭제, resize 적용(아래 코드로 교체)
//        var iconConfig = iconImage == nil ? UIImage(systemName: size.icon): iconImage
//        iconConfig = iconConfig?.resize(to: 24)
        

        var iconColor: UIColor = type == .secondary ? HandySemantic.iconBasicSecondary : HandySemantic.iconBasicWhite
        switch (isDisabled, isHighlighted) {
        case (true, _):
            self.backgroundColor = type.disabledColor
            self.layer.borderColor = type.borderColor.cgColor
            iconColor = type == .secondary ? HandySemantic.iconBasicDisabled : HandySemantic.iconBasicWhite
            removeShadow()

        case (false, true):
            self.backgroundColor = type.highlightedColor
            self.layer.borderColor = type.borderColor.cgColor
            applyShadow()

        case (false, false):
            self.backgroundColor = type.backgroundColor
            self.layer.borderColor = type.borderColor.cgColor
            applyShadow()
        }
        
        configuration.image = iconImage?.withTintColor(iconColor, renderingMode: .alwaysOriginal)
        
        self.isEnabled = !isDisabled
        self.configuration = configuration
    }

🔥 Test

2024-08-09.7.09.48.mov

작업 내용 피그마
스크린샷 2024-08-09 오전 7 23 11 스크린샷 2024-08-09 오전 7 22 56

icon 컬러로 HandySemantic.iconBasicSecondary를 사용하였는데, 피그마와 색상이 다른 것 같다고 느꼈습니다! 변경이 필요한 부분이라면 말씀해주세요!

@wjdalswl wjdalswl added the feat 💜 새로운 기능 구현 label Aug 8, 2024
@wjdalswl wjdalswl self-assigned this Aug 8, 2024
@wjdalswl wjdalswl linked an issue Aug 8, 2024 that may be closed by this pull request
1 task
@LeeJoEun-01
Copy link
Contributor

@wjdalswl 마이님!

제가 피그마 확인해보니 icon 색상이 icon/basic/tertiary으로 되어있던데 혹시 이 색상이 이상하다고 하신건가요??
image

Comment on lines +16 to +46
*/
@Invalidating(.layout, .display) public var isDisabled: Bool = false {
didSet {
setConfiguration()
}
}

/**
Fab 버튼의 Pressed / Hover 여부를 나타낼 때 사용합니다.
*/
public override var isHighlighted: Bool {
didSet { setConfiguration() }
}

/**
Fab 버튼의 타입을 결정할 때 사용합니다.
*/
@Invalidating(.layout, .display) public var type: FabType = .primary {
didSet {
setConfiguration()
}
}

/**
Fab 버튼의 크기를 결정할 때 사용합니다.
*/
@Invalidating(.layout, .display) public var size: FabSize = .large {
didSet {
setConfiguration()
}
}
Copy link
Member

@lygon55555 lygon55555 Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Invalidating은 왜 사용하셨는지 궁금합니다!

@jysuhr
Copy link

jysuhr commented Sep 9, 2024

수고하셨습니다 :) 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 💜 새로운 기능 구현
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] Component - Fab
4 participants