Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ByeBoo-iOS/ByeBoo-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.heartz.ByeBoo-iOS";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match AppStore com.heartz.ByeBoo-iOS";
"PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "match Development com.heartz.ByeBoo-iOS";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
Expand Down
78 changes: 51 additions & 27 deletions ByeBoo-iOS/ByeBoo-iOS/Data/Persistence/Service/TokenService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,37 @@ import Foundation

import Alamofire

protocol TokenService {
protocol TokenService: Sendable {
func reissue() async throws
}

final class DefaultTokenService: TokenService {

actor DefaultTokenService: TokenService {
private var tokenTask: Task<Void, Error>?
private let keychainService: KeychainService

init(
keychainService: KeychainService
) {

init(keychainService: KeychainService) {
self.keychainService = keychainService
}

func reissue() async throws {

if let task = tokenTask {
return try await task.value
}

let task = Task {
try await fetchAuthReissue()
}

tokenTask = task
defer { tokenTask = nil }

return try await task.value
}

private func fetchAuthReissue() async throws {
let header: HeaderType = .withAuth(acessToken: keychainService.load(key: .refreshToken))
ByeBooLogger.debug("토큰 재발급 시작")

Expand All @@ -39,46 +56,53 @@ final class DefaultTokenService: TokenService {
.validate()
.responseDecodable(of: BaseResponse<TokenReissueResponseDTO>.self) { [weak self] response in
guard let self else { return }
ByeBooLogger.debug("💡Reissue \(response)")

switch response.result {
case .success(let data):
guard let data = data.data else {
ByeBooLogger.error(ByeBooError.noData)
continuation.resume(throwing: ByeBooError.noData)
return
}
ByeBooLogger.debug("토큰 재발급 완료")
self.keychainService.save(key: .accessToken, token: data.accessToken)
self.keychainService.save(key: .refreshToken, token: data.refreshToken)
continuation.resume(returning: ())
case .failure(let error):
ByeBooLogger.debug("토큰 재발급 실패, 키체인 삭제 후 로그인으로 이동")
self.clearKeychain()
DispatchQueue.main.async {
NotificationCenter.default.post(name: .navigateLoginViewController, object: nil)

Task {
await self.debugTokenReissueSuccess(data)
continuation.resume(returning: ())
}
if let data = response.data,
let statusCode = response.response?.statusCode,
let errorResponse = try? JSONDecoder().decode(EmptyResponse.self, from: data) {
ByeBooLogger.error(error)

case .failure(let error):
Task {
await self.debugTokenReissueFailure()
continuation.resume(throwing: error)
} else {
ByeBooLogger.error(ByeBooError.decodingError)
continuation.resume(throwing: ByeBooError.decodingError)
}
}
}
}
}
}

extension DefaultTokenService {

private func debugTokenReissueSuccess(_ data: TokenReissueResponseDTO) {
ByeBooLogger.debug("토큰 재발급 완료")
self.keychainService.save(key: .accessToken, token: data.accessToken)
self.keychainService.save(key: .refreshToken, token: data.refreshToken)
}

private func debugTokenReissueFailure() {
ByeBooLogger.debug("토큰 재발급 실패, 키체인 삭제 후 로그인으로 이동")
clearKeychain()
DispatchQueue.main.async {
NotificationCenter.default.post(name: .navigateLoginViewController, object: nil)
}
}

private func clearKeychain() {
for key in KeyType.allCases {
let token = keychainService.load(key: key)
if !token.isEmpty {
keychainService.delete(key: key)
ByeBooLogger.debug("\(key) 삭제")
if !token.isEmpty {
keychainService.delete(key: key)
ByeBooLogger.debug("\(key) 삭제")
}
}
}

}
4 changes: 2 additions & 2 deletions ByeBoo-iOS/ByeBoo-iOS/Data/Repository/AuthRepository.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ struct DefaultAuthRepository: AuthInterface {

func autoLogin() async throws -> Bool {
let isOnboardingCompleted: Bool = userDefaultsService.load(key: .isOnboardingCompleted) ?? false
ByeBooLogger.debug(isOnboardingCompleted)
ByeBooLogger.debug("온보딩 여부 \(isOnboardingCompleted)")

if !keychainService.load(key: .accessToken).isEmpty
&& !keychainService.load(key: .refreshToken).isEmpty
Expand Down Expand Up @@ -214,7 +214,7 @@ final class MockAuthRepository: AuthInterface {
func appleLogin(platform: LoginPlatform) async throws {
appleLoginCalled = true

var (identityToken, authorizationCode) = try await network.appleRequest()
let (identityToken, authorizationCode) = try await network.appleRequest()
let _ = userDefaultsService.save("APPLE", key: .loginPlatform)
keychainService.save(key: .authorization, token: identityToken)
keychainService.save(key: .authorizationCode, token: authorizationCode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum ByeBooButtonType {
case .enabled:
.primary300
case .disabled:
.white10
.white5
case .disabled2:
.black50
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final class ByeBooNicknameTextField: BaseView {

override func setStyle() {
nicknameField.do {
$0.backgroundColor = .white10
$0.backgroundColor = .white5
$0.layer.cornerRadius = 12.adjustedW
$0.attributedPlaceholder = NSAttributedString(
string: "닉네임을 입력해주세요",
Expand All @@ -79,7 +79,7 @@ final class ByeBooNicknameTextField: BaseView {
$0.autocapitalizationType = .none
}
deleteAllTextButton.do {
$0.backgroundColor = .white10
$0.backgroundColor = .white5
$0.setImage(.union.withTintColor(.white).resize(newWidth: 10.adjustedW), for: .normal)
$0.layer.cornerRadius = 9
$0.isHidden = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class EmotionBottomSheetView: BaseView {
private let emotionChipFirstStackView = UIStackView()
private let emotionChipSecondStackView = UIStackView()

let confirmButton = ByeBooButton(titleText: "완료", type: .disabled)
let confirmButton = ByeBooButton(titleText: "완료하기", type: .disabled)
var emotionChips: [ByeBooEmotionChip] = []

override func setUI() {
Expand Down Expand Up @@ -49,13 +49,13 @@ final class EmotionBottomSheetView: BaseView {
override func setStyle() {
backgroundColor = .grayscale900

titleLabel.do {
$0.text = "퀘스트를 완료한 후,\n어떤 감정이 느껴지시나요?"
$0.numberOfLines = 2
$0.font = FontManager.head1M24.font
$0.textColor = .grayscale50
$0.textAlignment = .center
}
titleLabel.applyByeBooFont(
style: .head2M22,
text: "퀘스트를 완료한 후,\n어떤 감정이 느껴지시나요?",
color: .grayscale50,
textAlignment: .center,
numberOfLines: 2
)

warningStackView.do {
$0.axis = .horizontal
Expand All @@ -67,11 +67,11 @@ final class EmotionBottomSheetView: BaseView {
$0.contentMode = .scaleAspectFit
}

warningLabel.do {
$0.text = "퀘스트 완료 후에는 감정을 수정할 수 없어요"
$0.font = FontManager.cap2R12.font
$0.textColor = .grayscale400
}
warningLabel.applyByeBooFont(
style: .cap2R12,
text: "퀘스트 완료 후에는 감정을 수정할 수 없어요",
color: .grayscale400
)

[emotionChipFirstStackView, emotionChipSecondStackView].forEach {
$0.do {
Expand All @@ -85,7 +85,7 @@ final class EmotionBottomSheetView: BaseView {
titleLabel.snp.makeConstraints {
$0.top.equalToSuperview().offset(53.adjustedH)
$0.centerX.equalToSuperview()
$0.height.equalTo(62.adjustedH)
// $0.height.equalTo(62.adjustedH)
}

warningStackView.snp.makeConstraints {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ enum EmotionChipState {
case .selected:
return .primary30020
case .unselected, .defaultState:
return .white10
return .white5
}
}

Expand Down Expand Up @@ -52,6 +52,15 @@ enum EmotionChipState {
return 0.5
}
}

var font: FontManager {
switch self {
case .selected:
return FontManager.body4Sb14
case .defaultState, .unselected:
return FontManager.body5M14
}
}
}

final class ByeBooEmotionChip: BaseView {
Expand Down Expand Up @@ -88,11 +97,11 @@ final class ByeBooEmotionChip: BaseView {
$0.isUserInteractionEnabled = true
}

emotionTag.do {
$0.textAlignment = .center
$0.textColor = chipState.textColor
$0.font = FontManager.body4Sb14.font
}
emotionTag.applyByeBooFont(
style: chipState.font,
color: chipState.textColor,
textAlignment: .center
)
}

override func setLayout() {
Expand Down Expand Up @@ -126,11 +135,20 @@ extension ByeBooEmotionChip {
func updateEmotion(_ emotionType: ByeBooEmotion) {
self.emotionType = emotionType
self.emotionImage.image = emotionType.emotionImage.image
self.emotionTag.text = emotionType.emotionText
emotionTag.applyByeBooFont(
style: chipState.font,
text: emotionType.emotionText,
color: chipState.textColor,
textAlignment: .center
)
}

func updateChipUI() {
self.emotionTag.textColor = chipState.textColor
emotionTag.applyByeBooFont(
style: chipState.font,
color: chipState.textColor,
textAlignment: .center
)
self.backgroundColor = chipState.backgroundColor
self.layer.borderColor = chipState.borderColor.cgColor
self.layer.opacity = chipState.backgroundOpacity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,24 @@ final class ConfirmModalView: BaseView, ModalProtocol {
$0.backgroundColor = .grayscale90080
$0.layer.cornerRadius = 12
}
titleLabel.do {
$0.font = FontManager.sub3M18.font
$0.textColor = .grayscale50
$0.textAlignment = .center
}
descriptionLabel.do {
$0.font = FontManager.body3R16.font
$0.textColor = .grayscale400
$0.textAlignment = .center
}

titleLabel.applyByeBooFont(
style: .sub3M18,
color: .grayscale50,
textAlignment: .center
)

descriptionLabel.applyByeBooFont(
style: .body3R16,
color: .grayscale400,
textAlignment: .center
)

buttonStackView.do {
$0.axis = .horizontal
$0.spacing = 16
}

setBlurEffect()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,35 @@ final class CongrateModalView: BaseView, ModalProtocol {
private let secondDescriptionLabel = UILabel()

override func setStyle() {
backgroundColor = .grayscale90080
backgroundColor = .grayscale900
layer.cornerRadius = 12

descriptionLabel.applyByeBooFont(
style: .body3R16,
text: "축하드려요!",
color: .grayscale400,
textAlignment: .center
)

titleLabel.applyByeBooFont(
style: .sub2Sb18,
text: "감정 직면 여정을\n모두 마무리 했어요",
color: .grayscale50,
textAlignment: .center,
numberOfLines: 2
)

descriptionLabel.do {
$0.text = "축하드려요!"
$0.textAlignment = .center
$0.textColor = .grayscale400
$0.font = FontManager.body3R16.font
}
titleLabel.do {
$0.text = "감정 직면 여정을\n모두 마무리 했어요"
$0.numberOfLines = 2
$0.textAlignment = .center
$0.textColor = .grayscale50
$0.font = FontManager.sub2Sb18.font
}
imageView.do {
$0.image = .clover
}
secondDescriptionLabel.do {
$0.text = "보리가 하츠핑님께\n하고싶은 말이 있다고 해요."
$0.numberOfLines = 2
$0.textAlignment = .center
$0.textColor = .grayscale400
$0.font = FontManager.body3R16.font
}

setBlurEffect()
secondDescriptionLabel.applyByeBooFont(
style: .body3R16,
text: "보리가 하츠핑님께\n하고싶은 말이 있다고 해요.",
color: .grayscale400,
textAlignment: .center,
numberOfLines: 2
)
}

override func setUI() {
Expand Down
Loading
Loading