-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
어디까지 했는지 기억이 안나서 합치겠습니다.
- Loading branch information
Showing
26 changed files
with
1,434 additions
and
637 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
Common/Resources/Asset.xcassets/link.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "link.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
Common/Resources/Asset.xcassets/report.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "report.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
Common/Resources/Asset.xcassets/seeMore.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "seeMore.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
// | ||
// RecordyToggle.swift | ||
// Common | ||
// | ||
// Created by 한지석 on 7/10/24. | ||
// Copyright © 2024 com.recordy. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
import SnapKit | ||
import Then | ||
|
||
public enum ToggleState { | ||
case all | ||
case following | ||
} | ||
|
||
public class ViskitToggle: UIButton { | ||
|
||
var toggleState: ToggleState = .following { | ||
didSet { | ||
self.update() | ||
} | ||
} | ||
|
||
public var toggleAction: ((ToggleState) -> Void)? | ||
|
||
private let backgroundView = UIStackView() | ||
private let leftStateView = UIView() | ||
private let rightStateView = UIView() | ||
private let leftStateLabel = UILabel() | ||
private let rightStateLabel = UILabel() | ||
|
||
public override init(frame: CGRect) { | ||
super.init(frame: frame) | ||
setStyle() | ||
setUI() | ||
setAutolayout() | ||
setState(state: .following) | ||
} | ||
|
||
required init?(coder aDecoder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
|
||
public override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { | ||
super.touchesEnded(touches, with: event) | ||
toggle() | ||
toggleAction?(toggleState) | ||
} | ||
|
||
private func setStyle() { | ||
backgroundView.do { | ||
$0.axis = .horizontal | ||
$0.layer.backgroundColor = (UIColor.black.cgColor).copy(alpha: 0.2) | ||
$0.isLayoutMarginsRelativeArrangement = true | ||
$0.cornerRadius(15) | ||
$0.isUserInteractionEnabled = false | ||
} | ||
|
||
leftStateView.do { | ||
$0.cornerRadius(15) | ||
$0.backgroundColor = CommonAsset.viskitGray10.color | ||
$0.isUserInteractionEnabled = false | ||
} | ||
|
||
rightStateView.do { | ||
$0.cornerRadius(15) | ||
$0.isUserInteractionEnabled = false | ||
} | ||
|
||
leftStateLabel.do { | ||
$0.text = "전체" | ||
$0.textColor = .white | ||
$0.font = ViskitFont.body2.font | ||
} | ||
|
||
rightStateLabel.do { | ||
$0.text = "팔로잉" | ||
$0.textColor = .white | ||
$0.font = ViskitFont.body2.font | ||
} | ||
} | ||
|
||
private func setUI() { | ||
backgroundView.addArrangedSubview(leftStateView) | ||
backgroundView.addArrangedSubview(rightStateView) | ||
leftStateView.addSubview(leftStateLabel) | ||
rightStateView.addSubview(rightStateLabel) | ||
addSubview(backgroundView) | ||
} | ||
|
||
private func setAutolayout() { | ||
backgroundView.snp.makeConstraints { | ||
$0.top.equalTo(snp.top) | ||
$0.bottom.equalTo(snp.bottom) | ||
$0.leading.equalTo(snp.leading) | ||
$0.trailing.equalTo(snp.trailing) | ||
} | ||
leftStateView.snp.makeConstraints { | ||
$0.width.equalTo(snp.width).multipliedBy(0.5) | ||
$0.height.equalTo(snp.height) | ||
} | ||
rightStateView.snp.makeConstraints { | ||
$0.width.equalTo(snp.width).multipliedBy(0.5) | ||
$0.height.equalTo(snp.height) | ||
} | ||
leftStateLabel.snp.makeConstraints { | ||
$0.centerX.equalToSuperview() | ||
$0.centerY.equalToSuperview() | ||
} | ||
rightStateLabel.snp.makeConstraints { | ||
$0.centerX.equalToSuperview() | ||
$0.centerY.equalToSuperview() | ||
} | ||
} | ||
|
||
func update() { | ||
UIView.animate(withDuration: 0.3) { [weak self] in | ||
guard let self else { return } | ||
if self.toggleState == .all { | ||
self.leftStateView.backgroundColor = CommonAsset.recordyGrey08.color | ||
self.rightStateView.backgroundColor = .clear | ||
} else { | ||
self.leftStateView.backgroundColor = .clear | ||
self.rightStateView.backgroundColor = CommonAsset.recordyGrey08.color | ||
} | ||
} | ||
} | ||
|
||
public func toggle() { | ||
toggleState == .all ? setState(state: .following) : setState(state: .all) | ||
} | ||
|
||
func setState(state: ToggleState) { | ||
toggleState = state | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.