APP-iOS3rd / PJ3T2_Mymory

멋쟁이사자처럼 iOS 앱스쿨 3기 팀 프로젝트
10 stars 3 forks source link

다크모드에서 안보이는 글씨와 SettingMenuCell 코드를 수정했어요 #159

Closed xohxe closed 7 months ago

xohxe commented 7 months ago

PR 가이드라인

PR Checklist

PR 날릴 때 체크 리스트

PR Type

연관되는 issue 정보를 알려주세요

Issue Number: N/A

어떻게 작동하나요? code 기반으로 설명해주세요

다크모드에서 일부 뷰의 색상이 보이지 않았던 문제는 개선했어요. 추가로 SettingView에서 사용되는 SettingMenuCell에서 링크를 부모 뷰에서 연결하기위해, chooseDestination() 함수에서 조건에 따라 page를 반환할 수 있게 했어요.

struct SettingMenuCell: View {
    var name: String
    var page: String = "" // 추가된 parameter

    var body: some View {

        NavigationLink {
            chooseDestination()
        } label: {
            HStack(alignment: .center) {
                Text(name)
                    .font(.regular18)
                Spacer()
            }
            .foregroundStyle(Color.textColor)
        }

    }

    @ViewBuilder
    func chooseDestination() -> some View {
        switch page {
        case "theme": ThemeView()
        case "login": LoginView()
        case "font": FontView()
        default: EmptyView()
        }
    }
}

상위 뷰에서는 아래와 같이 사용하면됩니다.

SettingMenuCell(name: "알림") // 연결할 뷰가 없을 때는 page 생략
SettingMenuCell(name: "테마", page: "theme") 

더 좋은 방법이 있다면, 의견을 나눠주세요!