Skip to content

Commit

Permalink
Merge pull request #323 from OMZigak/feat/#321-makePushView
Browse files Browse the repository at this point in the history
[feat] 웹뷰 로딩하기
  • Loading branch information
hooni0918 authored Aug 23, 2024
2 parents 61b8c50 + e242262 commit f44ac8a
Show file tree
Hide file tree
Showing 7 changed files with 472 additions and 78 deletions.
16 changes: 16 additions & 0 deletions KkuMulKum.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
784824F72C6E1C9900FE07A0 /* AuthServiceProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784824F62C6E1C9900FE07A0 /* AuthServiceProtocol.swift */; };
784824FC2C75BF7900FE07A0 /* MyPageViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784824FB2C75BF7900FE07A0 /* MyPageViewModel.swift */; };
784824FE2C75F25900FE07A0 /* MyPageEditViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784824FD2C75F25900FE07A0 /* MyPageEditViewController.swift */; };
784825012C77016400FE07A0 /* MyPageEditView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784825002C77016400FE07A0 /* MyPageEditView.swift */; };
784825032C77016F00FE07A0 /* MyPageEditViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784825022C77016F00FE07A0 /* MyPageEditViewModel.swift */; };
784825052C7716E900FE07A0 /* MyPageAskViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784825042C7716E900FE07A0 /* MyPageAskViewController.swift */; };
784825072C77215B00FE07A0 /* MyPageTermsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 784825062C77215B00FE07A0 /* MyPageTermsViewController.swift */; };
784E4D942C3B1C7F00BC943C /* KakaoSDK in Frameworks */ = {isa = PBXBuildFile; productRef = 784E4D932C3B1C7F00BC943C /* KakaoSDK */; };
784E4D962C3B1C7F00BC943C /* KakaoSDKAuth in Frameworks */ = {isa = PBXBuildFile; productRef = 784E4D952C3B1C7F00BC943C /* KakaoSDKAuth */; };
784E4D992C3B95A900BC943C /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 784E4D982C3B95A900BC943C /* KeychainAccess */; };
Expand Down Expand Up @@ -258,6 +262,10 @@
784824F62C6E1C9900FE07A0 /* AuthServiceProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthServiceProtocol.swift; sourceTree = "<group>"; };
784824FB2C75BF7900FE07A0 /* MyPageViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageViewModel.swift; sourceTree = "<group>"; };
784824FD2C75F25900FE07A0 /* MyPageEditViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageEditViewController.swift; sourceTree = "<group>"; };
784825002C77016400FE07A0 /* MyPageEditView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageEditView.swift; sourceTree = "<group>"; };
784825022C77016F00FE07A0 /* MyPageEditViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageEditViewModel.swift; sourceTree = "<group>"; };
784825042C7716E900FE07A0 /* MyPageAskViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageAskViewController.swift; sourceTree = "<group>"; };
784825062C77215B00FE07A0 /* MyPageTermsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyPageTermsViewController.swift; sourceTree = "<group>"; };
789196332C486F6B00FF8CDF /* KeychainAccessible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KeychainAccessible.swift; sourceTree = "<group>"; };
789196352C492F8600FF8CDF /* AuthTargetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthTargetType.swift; sourceTree = "<group>"; };
789196372C49697B00FF8CDF /* AuthError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthError.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -560,6 +568,7 @@
isa = PBXGroup;
children = (
784824FB2C75BF7900FE07A0 /* MyPageViewModel.swift */,
784825022C77016F00FE07A0 /* MyPageEditViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
Expand Down Expand Up @@ -1218,6 +1227,7 @@
DE0137D22C43C5E50088C777 /* MyPageView.swift */,
DE159D2B2C406E1600425101 /* MyPageContentView.swift */,
DE159D2C2C406E1600425101 /* MyPageEtcSettingView.swift */,
784825002C77016400FE07A0 /* MyPageEditView.swift */,
);
path = View;
sourceTree = "<group>";
Expand All @@ -1227,6 +1237,8 @@
children = (
DE159D2F2C406E1600425101 /* MyPageViewController.swift */,
784824FD2C75F25900FE07A0 /* MyPageEditViewController.swift */,
784825042C7716E900FE07A0 /* MyPageAskViewController.swift */,
784825062C77215B00FE07A0 /* MyPageTermsViewController.swift */,
);
path = ViewController;
sourceTree = "<group>";
Expand Down Expand Up @@ -1769,6 +1781,7 @@
DECB84622C44472F0022A003 /* FindPlaceViewModel.swift in Sources */,
789D73A72C46AF4900C7077D /* KeychainService.swift in Sources */,
DD43937C2C412F4500EC1799 /* InviteCodeViewController.swift in Sources */,
784825012C77016400FE07A0 /* MyPageEditView.swift in Sources */,
DD4393782C412F4500EC1799 /* CheckInviteCodeView.swift in Sources */,
DE6D4D102C3F14D80005584B /* InvitationCodePopUpView.swift in Sources */,
789196382C49697B00FF8CDF /* AuthError.swift in Sources */,
Expand Down Expand Up @@ -1805,6 +1818,7 @@
A3FB184F2C3BF4BC001483E5 /* MakeMeetingsResponseModel.swift in Sources */,
DEF725DB2C3F3BBF008C87C7 /* Toast.swift in Sources */,
DD43937A2C412F4500EC1799 /* CreateSuccessViewController.swift in Sources */,
784825032C77016F00FE07A0 /* MyPageEditViewModel.swift in Sources */,
DE254AAC2C31192400A4015E /* UILabel+.swift in Sources */,
DE254AB72C3119D000A4015E /* ReuseIdentifiable.swift in Sources */,
A3DD9C412C41BAD000E58A13 /* MeetingListViewModel.swift in Sources */,
Expand All @@ -1828,6 +1842,7 @@
A39F2B212C499CE5008DA5F5 /* SetReadyStatusInfoServiceType.swift in Sources */,
DE6D4D132C3F14D80005584B /* MeetingMemberCell.swift in Sources */,
DD3F9DD82C49C25D008E1FF7 /* PromiseServiceProtocol.swift in Sources */,
784825072C77215B00FE07A0 /* MyPageTermsViewController.swift in Sources */,
DDAF1C932C3D6E3D008A37D3 /* PromiseViewController.swift in Sources */,
789D73BE2C47FE0F00C7077D /* AuthInterceptor.swift in Sources */,
789D73B32C47CC6D00C7077D /* LocalNotificationManager.swift in Sources */,
Expand All @@ -1846,6 +1861,7 @@
DD3072142C3BF87A00416D9F /* NearestPromiseResponseModel.swift in Sources */,
782B407F2C3E44B7008B0CA7 /* WelcomeViewModel.swift in Sources */,
DD41BEFA2C41D4160095A068 /* TardyView.swift in Sources */,
784825052C7716E900FE07A0 /* MyPageAskViewController.swift in Sources */,
DD3072162C3BFE4E00416D9F /* UpcomingPromiseListResponseModel.swift in Sources */,
A3FB18572C3BF704001483E5 /* MeetingListResponseModel.swift in Sources */,
DE254AB22C31197B00A4015E /* UIButton+.swift in Sources */,
Expand Down
76 changes: 76 additions & 0 deletions KkuMulKum/Source/MyPage/View/MyPageEditView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// MyPageEditView.swift
// KkuMulKum
//
// Created by 이지훈 on 8/22/24.
//

import UIKit

import SnapKit
import Then

class MyPageEditView: BaseView {
let titleLabel = UILabel().then {
$0.setText("프로필을 설정해 주세요", style: .head01, color: .gray8)
$0.textAlignment = .left
}

let profileImageView = UIImageView().then {
$0.image = .imgProfile
$0.contentMode = .scaleAspectFill
$0.clipsToBounds = true
}

let cameraButton = UIButton().then {
$0.setImage(.iconCamera, for: .normal)
$0.tintColor = .white
$0.setLayer(borderWidth: 0, borderColor: .clear, cornerRadius: 15)
}

let skipButton = UIButton().then {
$0.setTitle("기본 프로필로 설정", style: .body05, color: .gray5)
$0.addUnderline()
}

let confirmButton = UIButton().then {
$0.setTitle("확인", style: .body03, color: .white)
$0.backgroundColor = .maincolor
$0.setLayer(borderWidth: 0, borderColor: .clear, cornerRadius: 8)
}

override func setupView() {
backgroundColor = .white

addSubviews(titleLabel, profileImageView, cameraButton, skipButton, confirmButton)
}

override func setupAutoLayout() {
titleLabel.snp.makeConstraints {
$0.top.equalTo(safeAreaLayoutGuide).offset(24)
$0.leading.trailing.equalToSuperview().inset(20)
}

profileImageView.snp.makeConstraints {
$0.top.equalTo(titleLabel.snp.bottom).offset(120)
$0.centerX.equalToSuperview()
$0.size.equalTo(Screen.width(150))
}

cameraButton.snp.makeConstraints {
$0.bottom.trailing.equalTo(profileImageView)
$0.size.equalTo(Screen.width(42))
}

skipButton.snp.makeConstraints {
$0.bottom.equalTo(confirmButton.snp.top).offset(-20)
$0.centerX.equalToSuperview()
}

confirmButton.snp.makeConstraints {
$0.bottom.equalTo(safeAreaLayoutGuide).offset(-20)
$0.leading.trailing.equalToSuperview().inset(20)
$0.height.equalTo(Screen.height(50))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// MyPageAskViewController.swift
// KkuMulKum
//
// Created by 이지훈 on 8/22/24.
//

import UIKit
import WebKit

class MyPageAskViewController: BaseViewController {

private let viewModel: MyPageViewModel
private var webView: WKWebView!

init(viewModel: MyPageViewModel) {
self.viewModel = viewModel
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}

override func viewDidLoad() {
super.viewDidLoad()

let myURL = URL(string: "https://docs.google.com/forms/d/e/1FAIpQLSdRR65ARe2M7JxQEAx8vpFz-I8tyEYwlpLwtSnJjniGOapPVQ/viewform")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}

override func setupView() {
super.setupView()
setupNavigationBarTitle(with: "문의하기")
setupNavigationBarBackButton()
}
}

extension MyPageAskViewController: WKUIDelegate {}
123 changes: 111 additions & 12 deletions KkuMulKum/Source/MyPage/ViewController/MyPageEditViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,122 @@

import UIKit

class MyPageEditViewController: BaseViewController {
import RxSwift
import RxCocoa

class MyPageEditViewController: BaseViewController {
private let rootView = MyPageEditView()
private let viewModel: MyPageEditViewModel
private let disposeBag = DisposeBag()

init(viewModel: MyPageEditViewModel) {
self.viewModel = viewModel
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func loadView() {
view = rootView
}

override func viewDidLoad() {
super.viewDidLoad()

view.backgroundColor = .white

setupNavigationBarTitle(with: "프로필 설정")
setupNavigationBarBackButton()
setupBindings()
}


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
private func setupBindings() {
let input = MyPageEditViewModel.Input(
profileImageTap: rootView.cameraButton.rx.tap.asObservable(),
confirmButtonTap: rootView.confirmButton.rx.tap.asObservable(),
newProfileImage: Observable.never() // This will be updated in imagePickerController
)

let output = viewModel.transform(input: input, disposeBag: DisposeBag())
output.profileImage
.drive(rootView.profileImageView.rx.image)
.disposed(by: disposeBag)

output.isConfirmButtonEnabled
.drive(rootView.confirmButton.rx.isEnabled)
.disposed(by: disposeBag)

output.isConfirmButtonEnabled
.map { $0 ? 1.0 : 0.5 }
.drive(rootView.confirmButton.rx.alpha)
.disposed(by: disposeBag)

output.serverResponse
.drive(onNext: { [weak self] response in
if let response = response {
self?.showAlert(message: response)
}
})
.disposed(by: disposeBag)

rootView.cameraButton.rx.tap
.subscribe(onNext: { [weak self] in
self?.showImagePicker()
})
.disposed(by: disposeBag)

navigationItem.leftBarButtonItem?.rx.tap
.subscribe(onNext: { [weak self] in
self?.navigateToMyPageViewController()
})
.disposed(by: disposeBag)
}
private func showImagePicker() {
let imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .photoLibrary
imagePicker.allowsEditing = true
present(imagePicker, animated: true)
}

private func showAlert(message: String) {
let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "확인", style: .default))
present(alert, animated: true)
}

private func navigateToMyPageViewController() {
navigationController?.popViewController(animated: true)
}
*/
}

extension MyPageEditViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
func imagePickerController(
_ picker: UIImagePickerController,
didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]
) {
if let editedImage = info[.editedImage] as? UIImage ?? info[.originalImage] as? UIImage {
let croppedImage = cropToCircle(image: editedImage)
let input = MyPageEditViewModel.Input(
profileImageTap: Observable.never(),
confirmButtonTap: Observable.never(),
newProfileImage: Observable.just(croppedImage)
)
_ = viewModel.transform(input: input, disposeBag: DisposeBag())
}
dismiss(animated: true)
}

private func cropToCircle(image: UIImage) -> UIImage {
let shorterSide = min(image.size.width, image.size.height)
let imageBounds = CGRect(x: 0, y: 0, width: shorterSide, height: shorterSide)
UIGraphicsBeginImageContextWithOptions(imageBounds.size, false, UIScreen.main.scale)
let context = UIGraphicsGetCurrentContext()!
context.addEllipse(in: imageBounds)
context.clip()
image.draw(in: imageBounds)
let circleImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
return circleImage
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// MyPageTermsViewController.swift
// KkuMulKum
//
// Created by 이지훈 on 8/22/24.
//

import UIKit
import WebKit

class MyPageTermsViewController: BaseViewController {

private let viewModel: MyPageViewModel
private var webView: WKWebView!

init(viewModel: MyPageViewModel) {
self.viewModel = viewModel
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}

override func viewDidLoad() {
super.viewDidLoad()

let myURL = URL(string: "https://arrow-frog-4b9.notion.site/a66033a3ff4a40bfaa6eff0a5bee737d")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}

override func setupView() {
super.setupView()
setupNavigationBarTitle(with: "이용약관")
setupNavigationBarBackButton()
}
}

extension MyPageTermsViewController: WKUIDelegate {}
Loading

0 comments on commit f44ac8a

Please sign in to comment.