Skip to content

Commit

Permalink
feat: 개인정보처리 방침 웹뷰 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
jongnan committed Aug 2, 2024
1 parent ec10b84 commit 7b940ba
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 34 deletions.
28 changes: 28 additions & 0 deletions Projects/Core/DesignSystem/Sources/View/WebView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// WebView.swift
// DesignSystem
//
// Created by 김종윤 on 8/2/24.
//

import SwiftUI
import WebKit

public struct WebView: UIViewRepresentable {
let url: URL?

public init(url: URL?) {
self.url = url
}

public func makeUIView(context: Context) -> some WKWebView {
return WKWebView()
}

public func updateUIView(_ webView: UIViewType, context: Context) {
if let url = url {
let request = URLRequest(url: url)
webView.load(request)
}
}
}
73 changes: 53 additions & 20 deletions Projects/Features/Setting/Sources/SettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,54 @@ import DesignSystem
public struct SettingView: View {
@ObservedObject private var viewModel: SettingViewModel

@State private var tapType: SettingType?

public init(viewModel: SettingViewModel) {
self.viewModel = viewModel
}

public var body: some View {
VStack{
Divider()
.padding(.top, 50)
memeLogoImage
appNameAndVersion
.padding(.bottom, 50)
Divider()
.padding(.horizontal, 10)
.padding(.bottom, 20)
settingListView
Spacer()
if let tapType {
VStack {
Divider()
.padding(.top, 50)

WebView(url: URL(string: tapType.url))
}
.plainNavigationBar(
backHandler: {
self.tapType = nil
},
rightActionHandler: nil,
hasConfigureButton: false,
title: tapType.title
)
} else {
VStack{
Divider()
.padding(.top, 50)

memeLogoImage
appNameAndVersion
.padding(.bottom, 50)

Divider()
.padding(.horizontal, 10)
.padding(.bottom, 20)

settingListView

Spacer()
}
.plainNavigationBar(
backHandler: {
viewModel.dispatch(type: .naviBackButtonTapped)
},
rightActionHandler: nil,
hasConfigureButton: false,
title: "설정"
)
}
.plainNavigationBar(
backHandler: { viewModel.dispatch(type: .naviBackButtonTapped) },
rightActionHandler: nil,
hasConfigureButton: false,
title: "설정"
)
}

var memeLogoImage: some View {
Expand All @@ -58,17 +83,22 @@ public struct SettingView: View {

var settingListView: some View {
ForEach(viewModel.state.settingList) { settingType in
SettingListItemView(title: settingType.title)
SettingListItemView(
type: settingType,
tapType: $tapType
)
}
}
}

struct SettingListItemView: View {
let title: String
let type: SettingType

@Binding var tapType: SettingType?

var body: some View {
HStack {
Text(title)
Text(type.title)
.font(Font.Body.Xlarge.semiBold)
.padding(.vertical, 20)
.padding(.leading, 20)
Expand All @@ -79,6 +109,9 @@ struct SettingListItemView: View {
.frame(width: 16, height: 16, alignment: .center)
.foregroundStyle(Color.Icon.assistive)
.padding(.trailing, 20)
.onTapGesture {
self.tapType = type
}
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions Projects/Features/Setting/Sources/SettingViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,6 @@ final public class SettingViewModel: ViewModelType, ObservableObject {
var settingList: [SettingType] = []
}

struct SettingType: Identifiable {
let id = UUID()
let url: String
let title: String

init(
url: String,
title: String
) {
self.url = url
self.title = title
}
}

// MARK: - Properties
weak var router: SettingRouting?
@Published public var state: State
Expand Down Expand Up @@ -97,3 +83,17 @@ final public class SettingViewModel: ViewModelType, ObservableObject {
return nil
}
}

public struct SettingType: Identifiable {
public let id = UUID()
public let url: String
public let title: String

init(
url: String,
title: String
) {
self.url = url
self.title = title
}
}

0 comments on commit 7b940ba

Please sign in to comment.