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

[3주차] 기본과제 구현 #9

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

[3주차] 기본과제 구현 #9

wants to merge 19 commits into from

Conversation

meltsplit
Copy link
Contributor

@meltsplit meltsplit commented Apr 22, 2023

🔥 Pull requests

🌴 작업한 브랜치

✅ 작업한 내용

  • 마이페이지 구현
  • ScrollView에 스크롤 안되는 tableView 쌓는 방식
  • footerView 한 파일만 만들고 내부에서 seperator 보여줄지 logout버튼 보여줄지 결정함!
  • ProfileView에서 stackView 많이 활용해봤음!
  • footerView의 사이즈는 intrincsContentSize를 통해 알아서 계산함

❗️PR Point

  • 킁!

📸 스크린샷

asdf

@meltsplit meltsplit self-assigned this Apr 22, 2023
@meltsplit meltsplit changed the title [3주차] LinkedList 점검 [3주차] 기본과제 구현 Apr 28, 2023
@meltsplit meltsplit added the 📝 과제 주차별 과제 이슈를 생성합니다. label Apr 28, 2023
Copy link
Contributor Author

@meltsplit meltsplit left a comment

Choose a reason for hiding this comment

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

뷰모델까지 짜긴 어려워서 일단은 MVC로 구현했습니다! MyPage 관련 파일만 봐주시면 감사하겠습니당

Comment on lines +13 to +15

private let isLastSection: Bool

Copy link
Contributor Author

Choose a reason for hiding this comment

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

해당 bool을 통해 마지막 섹션이라면 로그아웃 버튼을 아니라면 구분선을 띄움!

Comment on lines +33 to +40

private lazy var vStackView: UIStackView = {
let stackView = UIStackView(arrangedSubviews: [seperatorView,logoutButton])
stackView.axis = .vertical
stackView.alignment = .center
return stackView
}()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

구분선과 로그아웃버튼은 스택뷰로 묶여져있고 둘중 하나를 히든 처리하면 스택뷰 사이즈도 작아짐

Comment on lines +70 to +83
vStackView.snp.makeConstraints {
$0.top.bottom.equalToSuperview().inset(20)
$0.leading.trailing.equalToSuperview()
}

seperatorView.snp.makeConstraints {
$0.width.equalToSuperview().inset(10)
$0.height.equalTo(1)
}

logoutButton.snp.makeConstraints {
$0.width.equalToSuperview()
$0.height.equalTo(54)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

스택뷰는 슈퍼뷰와 제약조건 잡고
구분선과 로그아웃버튼은 크기만 지정

Comment on lines +223 to +233
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
switch section {
case 0:
return MyPageSettingFooterView(isLastSection: false).intrinsicContentSize.height
case 1:
return MyPageSettingFooterView(isLastSection: true).intrinsicContentSize.height
default:
return 0

}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

푸터 높이는 해당 푸터인스턴스 만든 후 인스턴스의 intrincsSize 계산하여 반환

Comment on lines +235 to +246
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {

switch section {
case 0:
return MyPageSettingFooterView(isLastSection: false)
case 1:
return MyPageSettingFooterView(isLastSection: true)
default:
return nil
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

마지막 섹션일때만 인자에 true를 넣어준다

Comment on lines +21 to +38
private let nameButton: UIButton = {
var config = UIButton.Configuration.filled()
config.buttonSize = .small
config.baseBackgroundColor = .clear
config.image = UIImage(systemName: "pencil")
config.imagePlacement = .trailing
config.imagePadding = 5
config.imageColorTransformer = .init({ _ in
return .tvingLightGray
})
var subtitleAttr = AttributedString.init("장석우")
subtitleAttr.font = .tvingSemiBold(ofSize: 23)
config.attributedTitle = subtitleAttr

let button = UIButton(configuration: config)

return button
}()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

버튼 configuration 사용하기 넘 어렵..ㄷ

private var currentNode : Node<String>? {
didSet{ mainTitle = currentNode?.data }
}
private var dataLinkedList = LinkedList<String>()

Choose a reason for hiding this comment

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

삽입삭제가 자주 필요한 곳에 썻다면 굳

Copy link
Contributor Author

Choose a reason for hiding this comment

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

캐로우셀에 적용시키려니까 너무 어렵네여으 ㅠㅜ 그냥 배열로 할까봐요...

Copy link
Member

@Zoe0929 Zoe0929 left a comment

Choose a reason for hiding this comment

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

복잡한 제 코드 보다가 잠시 쉬러 왔습니다.. 깔끔한 코드 힐링이네요.. 😵‍💫🌿 석우님 코드 너무 궁금해요~~~

Comment on lines +167 to +175
memberShipStackView.addArrangedSubViews(memberShipImageView,
memberShipLabel,
myMemberShipButton)

cashStackView.addArrangedSubViews(cashImageView,
cashLabel,
myCashButton)

darkStackView.addArrangedSubViews(memberShipStackView, cashStackView)
Copy link
Member

Choose a reason for hiding this comment

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

저는 보통 stackView를 생성할 때 lazy var로 선언한 뒤 생성할 때 .addArrangedSubViews를 하는 편인데, 혹시 이렇게 하면 조금 비효율적일까요..? 요렇게 밖에 빠져 있는 걸 보니까 급 의문이 드네오.. 🤔🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

저도 처음에 조이님 방법처럼 작성했다가 다른분들이 제 코드를 볼때, 뷰의 계층구조는 모두 layout() 함수에 모아져 있는 것이 가독성 측면에 좋아보일 것 같아서 밖으로 뺐습니다.


rightImageView.snp.makeConstraints {
$0.centerY.equalToSuperview()
$0.trailing.equalToSuperview().offset(-5)
Copy link
Member

Choose a reason for hiding this comment

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

이것도 그냥 궁금해진건데 코드에서 이런 식으로 insetoffset을 혼합해서 쓰면 가독성이 조금 떨어질까요?

circleProfileButton.snp.makeConstraints{
            $0.top.equalToSuperview().offset(55)
            $0.trailing.equalToSuperview().inset(11)
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

저는 가독성보단 offset과 inset의 역할이 뭔지에 따라 offset으로 할지 inset으로 할지 결정하는데여
한 Constraints만 수정할때는 offset을 사용하고
하나이상의 constraints를 조정할 때는 inset을 사용합니다.

circleProfileButton.snp.makeConstraints{
            $0.top.equalToSuperview().offset(55)
            $0.trailing.equalToSuperview().offset(-11)
        }
circleProfileButton.snp.makeConstraints{
            $0.top.equalToSuperview().offset(55)
            $0.leading.trailing.equalToSuperview().inset(11)
        }

Copy link
Member

Choose a reason for hiding this comment

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

오호.. 감사합니다! 제가 혹시 잘못 사용하고 있나 싶어서 질문드렸어요..ㅎㅎ

let view = UIScrollView()
view.bounces = false
view.showsVerticalScrollIndicator = false
view.contentInsetAdjustmentBehavior = .never
Copy link
Member

Choose a reason for hiding this comment

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

오.. 검색해봤는데 이해가 잘 안돼요.. ㅜ,ㅜ 혹시 설명 부탁드려도 될까요?!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

스크롤뷰를 어떻게 구현했는지가 궁금하신걸까여 아니면
bounces,
showsVerticalScrollIndicator,
contentInsetAdjustmentBehavior가 궁금하신건가엽?

Copy link
Member

Choose a reason for hiding this comment

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

앗 범위를 잘못 설정했네요.. 🥲 contentInsetAdjustmentBehavior 요 속성이 무슨 역할을 하는지 궁금했어요!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

scrollview가 top을 superview와 일치시켜도 safearea를 넘지 못하는 오류해결하려고 추가했어욥!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📝 과제 주차별 과제 이슈를 생성합니다.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants