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

[Feat] #24 - segment control component #33

Merged
merged 8 commits into from
Jan 16, 2025

Conversation

HEHEEUN
Copy link
Collaborator

@HEHEEUN HEHEEUN commented Jan 15, 2025

🧩 작업 내용

  • segmentControl 제작 및 사용 테스트 완료.

🪁 PR Point

사용방법

    SegmentControlBar(segmentTitles: ["모임정보", "댓글"])
    SegmentControlBar(segmentTitles: ["내가 모집한", "내가 신청한"])

📱 스크린샷

구현 내용 스크린샷
구현내용입력 스크린샷 2025-01-15 오후 9 52 47

🔗 Issue

Resolved #24

@HEHEEUN HEHEEUN requested review from Nya128 and kms0233 January 15, 2025 12:54
@HEHEEUN HEHEEUN self-assigned this Jan 15, 2025
@HEHEEUN HEHEEUN changed the title Feat/#24 segment control component [Feat] #24 - segment control component Jan 15, 2025
Copy link
Collaborator

@kms0233 kms0233 left a comment

Choose a reason for hiding this comment

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

segmentControl 탭시 하단 뷰는 어떻게 전환한는지까지 pr에 써두면 나중에 편할 것 같아용!!
고봉밥 코리 먹고 체해라!
image

@HEHEEUN
Copy link
Collaborator Author

HEHEEUN commented Jan 16, 2025

segmentControl 탭시 하단 뷰는 어떻게 전환한는지까지 pr에 써두면 나중에 편할 것 같아용!! 고봉밥 코리 먹고 체해라! image

좋다! 아직 구현 안했어 ㅋㅋ

import SwiftUI

struct CustomSegmentControl: View {
let segments: [String]
Copy link
Collaborator

Choose a reason for hiding this comment

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

enum SegmentState에 타이틀 배열도 정의해놨으니 생성자에서 받을건 String 배열이 아니라 enum 타입을 받으면 될거같아요!! 😆

Comment on lines 26 to 30
ZStack(alignment: .bottom) {
Color(.gray02)
.frame(height: 2)
selected == segment ? Color(.gray09).frame(height: 4) : nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기는 ZStack은 안 써도 될 것 같아요! Color를 덮어씌우는 것보다 이미 만든 삼항연산자 하나에 합치는 건 어떨까요?!

Copy link
Collaborator

@Nya128 Nya128 left a comment

Choose a reason for hiding this comment

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

역시 뭐든지 직접 커스텀해서 컴포넌트 만들어서 쓰는 건 어렵네요.....🥺
Segmented Control 만든 거 자체가 대단한 거임 ㅜ.ㅜ
우리도 이제 @ViewBuilder 쓸 줄 안다~~ 성장했다.

Comment on lines 18 to 27
extension SegmentState {
var titles: [String] {
switch self {
case .detail:
return ["모임정보", "댓글"]
case .myfill:
return ["내가 모집한", "내가 신청한"]
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기 enum도 각각 모임상세, 채우기 화면별 세그먼트 타이틀도 다시 나누면 확장성에 좋을 것 같슴다

enum SegmentDetailType: String, CaseIterable {
    case meetingInfo = "모임정보"
    case comment = "댓글"
}

enum SegmentMyFillType: String, CaseIterable {
    case recruit = "내가 모집한"
    case apply = "내가 신청한"
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 몰랐는데 뷰빌더 기능을 쓰면 공통적인 부모 Container를 만드는데 유용하다고 해요!! 요런식으로 여러 개의 뷰를 조건마다 다르게 보여줘야 할 때도 쓰면 좋을 거 같네요 🤓

@ViewBuilder
    func view(at index: Int) -> some View {
        switch self {
        case .detail:
            switch SegmentDetailType.allCases[index] {
            case .meetingInfo: AddMeetingButton()
            case .comment: Text("민서 바부")
            }
        case .myfill:
            switch SegmentMyFillType.allCases[index] {
            case .recruit: Text("희은이 바부")
            case .apply: Text("나연이가 더 바보")
        }
    }
}

@HEHEEUN HEHEEUN merged commit 2c114fa into develop Jan 16, 2025
@HEHEEUN HEHEEUN deleted the feat/#24-SegmentControlComponent branch January 16, 2025 13:05
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.

[Feat] Segment Control Bar Component 생성
3 participants