Skip to content

Commit

Permalink
[#90] 모달 레이아웃 os 대응 완료(color 속성 o)
Browse files Browse the repository at this point in the history
  • Loading branch information
CJiu01 committed Nov 28, 2024
1 parent 252a5c5 commit 3f8655d
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,40 @@ final class LoginView: BaseUIView {
}
}
}

/*
@objc
private func rightBarButtonTapped() {
if RealmService.shared.isAccessTokenPresent() {
let nextVC = MyPageViewController()
self.navigationController?.pushViewController(nextVC, animated: true)
} else {
// showAlertControllerWithCancel(title: "로그인이 필요한 서비스입니다", message: "로그인 하시겠습니까?", confirmStyle: .default) {
// self.changeIntoLoginViewController()
// }

let modalVC = LoginPromptViewController()
modalVC.modalPresentationStyle = .pageSheet

// Check if UISheetPresentationController is available (iOS 15+)
if let sheet = modalVC.sheetPresentationController {
let small = UISheetPresentationController.Detent.Identifier("small")
// let smallDetent = UISheetPresentationController.Detent.custom(identifier: smallId) { context in
// return 270
// }
// sheet.detents = [smallDetent]
sheet.detents = [
.custom(identifier: small) { context in
0.3 * context.maximumDetentValue
}
]

// sheet.prefersGrabberVisible = true
sheet.prefersScrollingExpandsWhenScrolledToEdge = false
sheet.preferredCornerRadius = 30
}
present(modalVC, animated: true, completion: nil)

}
}
*/
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,41 @@ final class HomeViewController: BaseViewController {

@objc
private func rightBarButtonTapped() {
/// 로그인 되어있는 경우
if RealmService.shared.isAccessTokenPresent() {
let nextVC = MyPageViewController()
self.navigationController?.pushViewController(nextVC, animated: true)
} else {
showAlertControllerWithCancel(title: "로그인이 필요한 서비스입니다", message: "로그인 하시겠습니까?", confirmStyle: .default) {
self.changeIntoLoginViewController()
}
/// 로그인 되어있지 않은 경우
else {
let loginPromptVC = LoginPromptViewController()
loginPromptVC.modalPresentationStyle = .pageSheet

// Check if iOS 16+
if #available(iOS 16.0, *) {
if let sheet = loginPromptVC.sheetPresentationController {
let small = UISheetPresentationController.Detent.Identifier("small")
sheet.detents = [
.custom(identifier: small) { context in
0.34 * context.maximumDetentValue
}
]

sheet.prefersScrollingExpandsWhenScrolledToEdge = false
sheet.preferredCornerRadius = 30
}
present(loginPromptVC, animated: true, completion: nil)
}





// showAlertControllerWithCancel(title: "로그인이 필요한 서비스입니다", message: "로그인 하시겠습니까?", confirmStyle: .default) {
// self.changeIntoLoginViewController()
// }


}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ final class LoginPromptViewController: BaseViewController {
private let loginAlertLabel = UILabel()
private let appleLoginButton = UIButton()
private let kakaoLoginButton = UIButton()
private let buttonStackView = UIStackView()
private let loginPromptStackView = UIStackView()
private let buttonView = UIView()

// MARK: - Life Cycles

Expand All @@ -31,40 +34,63 @@ final class LoginPromptViewController: BaseViewController {
$0.textAlignment = .left
$0.numberOfLines = 0
$0.font = EATSSUFontFamily.Pretendard.bold.font(size: 18)
$0.setContentHuggingPriority(.defaultHigh, for: .vertical)
$0.backgroundColor = .green
}

appleLoginButton.do {
$0.setImage(EATSSUAsset.Images.Version2.appleLoginButton.image, for: .normal)
$0.backgroundColor = .lightGray

}

kakaoLoginButton.do {
$0.setImage(EATSSUAsset.Images.Version2.kakaoLoginButton.image, for: .normal)
$0.backgroundColor = .purple
}

buttonView.do {
$0.backgroundColor = .red
}

buttonStackView.do {
$0.axis = .vertical
$0.spacing = 8
$0.backgroundColor = .blue

}

loginPromptStackView.do {
$0.axis = .vertical
$0.backgroundColor = .yellow
}
}

override func configureUI() {
view.addSubviews(
loginAlertLabel,
appleLoginButton,
kakaoLoginButton
view.addSubview(
loginPromptStackView
)
buttonView.addSubview(buttonStackView)

buttonStackView.addArrangedSubviews([appleLoginButton,
kakaoLoginButton])
loginPromptStackView.addArrangedSubviews([loginAlertLabel,
buttonView])
}

override func setLayout() {
loginAlertLabel.snp.makeConstraints {
$0.top.leading.equalTo(view.safeAreaLayoutGuide).offset(30.adjusted)
}

appleLoginButton.snp.makeConstraints {
// $0.top.equalTo(loginAlertLabel.snp.bottom).offset(44.adjusted)
$0.bottom.equalTo(kakaoLoginButton.snp.top).offset(8)
$0.centerX.equalToSuperview()
$0.top.equalToSuperview()

}

kakaoLoginButton.snp.makeConstraints {
$0.bottom.equalTo(view.safeAreaLayoutGuide).inset(30)
$0.centerX.equalToSuperview()
buttonStackView.snp.makeConstraints{
$0.center.equalToSuperview()
}

loginPromptStackView.snp.makeConstraints {
$0.horizontalEdges.equalToSuperview().inset(30)
$0.height.equalToSuperview().multipliedBy(0.7)
$0.bottom.equalToSuperview().multipliedBy(0.85)
}
}
}

0 comments on commit 3f8655d

Please sign in to comment.