forked from sopt-makers/SOPT-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] sopt-makers#161 - MyPage 뷰 틀 구현 완료
- Loading branch information
Showing
10 changed files
with
636 additions
and
2 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
SOPT-iOS/Projects/Data/Sources/Repository/AppMyPageRepository.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// AppMyPageRepository.swift | ||
// Data | ||
// | ||
// Created by Ian on 2023/04/16. | ||
// Copyright © 2023 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
import Core | ||
import Domain | ||
import Network | ||
|
||
public final class AppMyPageRepository { | ||
private let stampService: StampService | ||
private let authService: AuthService | ||
private let userService: UserService | ||
|
||
public init( | ||
stampService: StampService, | ||
authService: AuthService, | ||
userService: UserService | ||
) { | ||
self.stampService = stampService | ||
self.authService = authService | ||
self.userService = userService | ||
} | ||
} | ||
|
||
extension AppMyPageRepository: AppMyPageRepositoryInterface { | ||
public func resetStamp() -> Driver<Bool> { | ||
stampService | ||
.resetStamp() | ||
.map { $0 == 200 } | ||
.asDriver() | ||
} | ||
|
||
public func editSoptampSentence(sentence: String) -> AnyPublisher<Bool, Never> { | ||
return userService.editSentence(sentence: sentence) | ||
.handleEvents(receiveOutput: { entity in | ||
UserDefaultKeyList.User.sentence = entity.toDomain() | ||
}) | ||
.map { _ in true } | ||
.replaceError(with: false) | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
public func editSoptampNickname(nickname: String) -> AnyPublisher<Bool, Never> { | ||
return userService.changeNickname(nickname: nickname) | ||
.map { _ in true } | ||
.replaceError(with: false) | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
public func withdrawalStamp() -> AnyPublisher<Bool, Never> { | ||
return authService.withdrawal() | ||
.handleEvents(receiveOutput: { status in | ||
if status == 200 { | ||
UserDefaultKeyList.Auth.appAccessToken = nil | ||
UserDefaultKeyList.Auth.appRefreshToken = nil | ||
UserDefaultKeyList.Auth.playgroundToken = nil | ||
UserDefaultKeyList.User.sentence = nil | ||
} | ||
}) | ||
.map { _ in true } | ||
.replaceError(with: false) | ||
.eraseToAnyPublisher() | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
SOPT-iOS/Projects/Domain/Sources/RepositoryInterface/AppMyPageRepositoryInterface.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// AppMyPageRepositoryInterface.swift | ||
// Domain | ||
// | ||
// Created by Ian on 2023/04/16. | ||
// Copyright © 2023 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
import Core | ||
|
||
public protocol AppMyPageRepositoryInterface { | ||
func resetStamp() -> Driver<Bool> | ||
func editSoptampSentence(sentence: String) -> AnyPublisher<Bool, Never> | ||
func editSoptampNickname(nickname: String) -> AnyPublisher<Bool, Never> | ||
func withdrawalStamp() -> AnyPublisher<Bool, Never> | ||
// func logout() -> AnyPublisher<Bool, Never> | ||
} |
16 changes: 16 additions & 0 deletions
16
SOPT-iOS/Projects/Domain/Sources/UseCase/AppMyPageUseCase.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// AppMyPageUseCase.swift | ||
// Domain | ||
// | ||
// Created by Ian on 2023/04/16. | ||
// Copyright © 2023 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
public protocol AppMyPageUseCase { | ||
|
||
} | ||
|
||
public final class DefaultAppMyPageUseCase { | ||
|
||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...ojects/Features/AppMyPageFeature/Sources/AppExtension/AssosiatedObject+UITabGesture.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// AssosiatedObject+UITabGesture.swift | ||
// AppMyPageFeature | ||
// | ||
// Created by Ian on 2023/04/16. | ||
// Copyright © 2023 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIView { | ||
typealias GestureHandler = (() -> Void)? | ||
|
||
private struct GestureAssociatedKey { | ||
fileprivate static var tapGestureKey = "_tabGestureKey" | ||
} | ||
|
||
private var tapGestureRecognizerHandler: GestureHandler? { | ||
get { | ||
return objc_getAssociatedObject( | ||
self, | ||
&GestureAssociatedKey.tapGestureKey | ||
) as? GestureHandler | ||
} | ||
set { | ||
if let newValue = newValue { | ||
objc_setAssociatedObject( | ||
self, | ||
&GestureAssociatedKey.tapGestureKey, | ||
newValue, | ||
.OBJC_ASSOCIATION_RETAIN_NONATOMIC | ||
) | ||
} | ||
} | ||
} | ||
|
||
public func addTapGestureRecognizer(_ handler: (() -> Void)?) { | ||
self.isUserInteractionEnabled = true | ||
self.tapGestureRecognizerHandler = handler | ||
let tapGestureRecognizer = UITapGestureRecognizer( | ||
target: self, | ||
action: #selector(handleTapGesture) | ||
) | ||
self.addGestureRecognizer(tapGestureRecognizer) | ||
} | ||
|
||
@objc private func handleTapGesture(sender: UITapGestureRecognizer) { | ||
if let action = self.tapGestureRecognizerHandler { | ||
action?() | ||
} | ||
} | ||
} | ||
|
196 changes: 196 additions & 0 deletions
196
...S/Projects/Features/AppMyPageFeature/Sources/AppMypageScene/AppMyPageViewController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
// | ||
// AppMyPageViewController.swift | ||
// AppMypageFeature | ||
// | ||
// Created by Ian on 2023/04/15. | ||
// Copyright © 2023 SOPT-iOS. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
import Core | ||
import DSKit | ||
|
||
import Combine | ||
import SnapKit | ||
import Then | ||
|
||
import AppMyPageFeatureInterface | ||
|
||
public final class AppMyPageViewController: UIViewController, AppMyPageViewControllerable { | ||
private enum Metric { | ||
static let firstSectionGroupTop = 13.f | ||
static let sectionGroupLeadingTrailing = 20.f | ||
|
||
static let sectionGroupSpacing = 16.f | ||
} | ||
|
||
|
||
private let viewModel: AppMyPageViewModel | ||
// private let factory // factory | ||
|
||
// MARK: - Views | ||
private var navigationBar: AppMyPageNavigationBar? | ||
|
||
private let scrollView = UIScrollView() | ||
private let contentStackView = UIStackView().then { | ||
$0.axis = .vertical | ||
$0.spacing = Metric.sectionGroupSpacing | ||
} | ||
|
||
// MARK: ServicePolicy | ||
private lazy var servicePolicySectionGroup = MypageSectionGroupView( | ||
headerTitle: "서비스 이용 방침", | ||
subviews: [ | ||
self.privacyPolicyListItem, | ||
self.termsOfUseListItem, | ||
self.sendFeedbackListItem | ||
], | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var privacyPolicyListItem = MyPageSectionListItemView( | ||
title: "개인정보 처리 방침", | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var termsOfUseListItem = MyPageSectionListItemView( | ||
title: "서비스 이용 약관", | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var sendFeedbackListItem = MyPageSectionListItemView( | ||
title: "의견 보내기", | ||
frame: self.view.frame | ||
) | ||
|
||
// MARK: Soptamp | ||
private lazy var soptampSectionGroup = MypageSectionGroupView( | ||
headerTitle: "솝탬프 설정", | ||
subviews: [ | ||
self.editOnelineSentenceListItem, | ||
self.editNickNameListItem, | ||
self.resetStampListItem | ||
], | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var editOnelineSentenceListItem = MyPageSectionListItemView( | ||
title: "한 마디 편집", | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var editNickNameListItem = MyPageSectionListItemView( | ||
title: "닉네임 변경", | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var resetStampListItem = MyPageSectionListItemView( | ||
title: "스탬프 초기화", | ||
frame: self.view.frame | ||
) | ||
|
||
// MARK: Etcs | ||
private lazy var etcSectionGroup = MypageSectionGroupView( | ||
headerTitle: "기타", | ||
subviews: [ | ||
self.logoutListItem, | ||
self.withDrawalListItem, | ||
], | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var logoutListItem = MyPageSectionListItemView( | ||
title: "로그아웃", | ||
frame: self.view.frame | ||
) | ||
|
||
private lazy var withDrawalListItem = MyPageSectionListItemView( | ||
title: "탈퇴하기", | ||
frame: self.view.frame | ||
) | ||
|
||
public init(viewModel: AppMyPageViewModel) { | ||
self.viewModel = viewModel | ||
|
||
super.init(nibName: nil, bundle: nil) | ||
} | ||
|
||
required init?(coder: NSCoder) { | ||
fatalError("init(coder:) has not been implemented") | ||
} | ||
} | ||
|
||
extension AppMyPageViewController { | ||
public override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
self.view.backgroundColor = DSKitAsset.Colors.black100.color | ||
|
||
self.setupLayouts() | ||
self.setupConstraints() | ||
self.addTabGestureOnListItems() | ||
} | ||
} | ||
|
||
extension AppMyPageViewController { | ||
private func setupLayouts() { | ||
self.navigationBar = AppMyPageNavigationBar(frame: self.view.frame) | ||
self.navigationItem.titleView = self.navigationBar | ||
|
||
self.view.addSubview(self.scrollView) | ||
self.scrollView.addSubview(self.contentStackView) | ||
self.contentStackView.addArrangedSubviews( | ||
self.servicePolicySectionGroup, | ||
self.soptampSectionGroup, | ||
self.etcSectionGroup | ||
) | ||
} | ||
|
||
private func setupConstraints() { | ||
self.scrollView.snp.makeConstraints { $0.edges.equalToSuperview() } | ||
self.contentStackView.snp.makeConstraints { | ||
$0.width.equalToSuperview() | ||
$0.top.equalToSuperview().inset(Metric.firstSectionGroupTop) | ||
$0.leading.trailing.bottom.equalToSuperview() | ||
} | ||
} | ||
|
||
private func addTabGestureOnListItems() { | ||
self.navigationBar?.leftChevronButton.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.servicePolicySectionGroup.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.termsOfUseListItem.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.termsOfUseListItem.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.editOnelineSentenceListItem.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.editNickNameListItem.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.resetStampListItem.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.logoutListItem.addTapGestureRecognizer { | ||
|
||
} | ||
|
||
self.withDrawalListItem.addTapGestureRecognizer { | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.