Skip to content

Commit

Permalink
[Merge] sopt-makers#159 - 컨플릭트 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
0inn committed Apr 18, 2023
2 parents 3d15d26 + ff0420e commit c630310
Show file tree
Hide file tree
Showing 35 changed files with 317 additions and 119 deletions.
14 changes: 14 additions & 0 deletions SOPT-iOS/Projects/Core/Sources/Enum/ServiceType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ public enum ServiceType {
case member
case notice
case crew

public var serviceDomainLink: String {
switch self {
case .officialHomepage: return "https://sopt.org"
case .review: return "https://sopt.org/review"
case .project: return "https://playground.sopt.org/projects"
case .faq: return "https://sopt.org/FAQ"
case .youtube: return "https://m.youtube.com/@SOPTMEDIA"
case .attendance: return ""
case .member: return "https://playground.sopt.org/members"
case .notice: return ""
case .crew: return "https://playground.sopt.org/group"
}
}
}

public enum AppServiceType {
Expand Down
28 changes: 28 additions & 0 deletions SOPT-iOS/Projects/Core/Sources/Extension/Foundation+/Date+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// Date+.swift
// Core
//
// Created by sejin on 2023/04/17.
// Copyright © 2023 SOPT-iOS. All rights reserved.
//

import Foundation

public extension Date {
/// Create a date from specified parameters
///
/// - Parameters:
/// - year: The desired year
/// - month: The desired month
/// - day: The desired day
/// - Returns: A `Date` object
static func from(year: Int, month: Int, day: Int) -> Date? {
let calendar = Calendar(identifier: .gregorian)
var dateComponents = DateComponents()
dateComponents.timeZone = TimeZone.current
dateComponents.year = year
dateComponents.month = month
dateComponents.day = day
return calendar.date(from: dateComponents) ?? nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,50 @@ public class ShowAttendanceRepository {

extension ShowAttendanceRepository: ShowAttendanceRepositoryInterface {
public func fetchAttendanceScheduleModel() -> AnyPublisher<AttendanceScheduleModel, Error> {
return Future<AttendanceScheduleModel, Error> { promise in
// return Future<AttendanceScheduleModel, Error> { promise in
//// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
//// location: "단국대학교 혜당관",
//// name: "3차 세미나",
//// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "",
//// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
//// TodayAttendanceModel(status: "ABSENT", attendedAt:
//// "2023-04-13T14:10:04")])))
//
// promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
// location: "단국대학교 혜당관",
// name: "3차 세미나",
// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00", message: "",
// location: "한국대학교 혜당관",
// name: "2차 행사",
// startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00",
// message: "행사도 참여하고, 출석점수도 받고, 일석이조!",
// attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
// TodayAttendanceModel(status: "ABSENT", attendedAt:
// "2023-04-13T14:10:04")])))

promise(.success(AttendanceScheduleModel(type: "HAS_ATTENDANCE",
location: "한국대학교 혜당관",
name: "2차 행사",
startDate: "2023-04-06T14:14:00", endDate: "2023-04-06T18:00:00",
message: "행사도 참여하고, 출석점수도 받고, 일석이조!",
attendances: [TodayAttendanceModel(status: "ATTENDANCE", attendedAt: "2023-04-13T14:12:09"),
TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")])))

// promise(.success(AttendanceScheduleModel(type: "NO_SESSION",
// location: "",
// name: "",
// startDate: "", endDate: "", message: "",
// attendances: [TodayAttendanceModel(status: "", attendedAt: ""),
// TodayAttendanceModel(status: "", attendedAt: "")])))
}
.eraseToAnyPublisher()
// return self.attendanceService.fetchAttendanceSchedule()
// .map { $0.toDomain() }
// .eraseToAnyPublisher()
// TodayAttendanceModel(status: "ABSENT", attendedAt: "2023-04-13T14:10:04")])))
//
//// promise(.success(AttendanceScheduleModel(type: "NO_SESSION",
//// location: "",
//// name: "",
//// startDate: "", endDate: "", message: "",
//// attendances: [TodayAttendanceModel(status: "", attendedAt: ""),
//// TodayAttendanceModel(status: "", attendedAt: "")])))
// }
// .eraseToAnyPublisher()
return self.attendanceService.fetchAttendanceSchedule()
.compactMap { $0.data?.toDomain() }
.eraseToAnyPublisher()
}

public func fetchAttendanceScoreModel() -> AnyPublisher<Domain.AttendanceScoreModel, Error> {
return Future<AttendanceScoreModel, Error> { promise in
promise(.success(AttendanceScoreModel.init(part: "iOS",
generation: 31,
name: "윤수빈",
score: 2.0,
total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1),
attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"),
AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"),
AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"),
AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")])))
}.eraseToAnyPublisher()
// return self.attendanceService.fetchAttendanceScore()
// .map { $0.toDomain() }
// .eraseToAnyPublisher()
// return Future<AttendanceScoreModel, Error> { promise in
// promise(.success(AttendanceScoreModel.init(part: "iOS",
// generation: 31,
// name: "윤수빈",
// score: 2.0,
// total: TotalScoreModel(attendance: 2, absent: 0, tardy: 1, participate: 1),
// attendances: [AttendanceModel(attribute: "ETC", name: "솝커톤", status: "TARDY", date: "4월 22일"),
// AttendanceModel(attribute: "SEMINAR", name: "iOS 2차 세미나", status: "ATTENDANCE", date: "4월 15일"),
// AttendanceModel(attribute: "SEMINAR", name: "iOS 1차 세미나", status: "ATTENDANCE", date: "4월 8일"),
// AttendanceModel(attribute: "ETC", name: "OT", status: "PARTICIPATE", date: "4월 1일")])))
// }.eraseToAnyPublisher()
return self.attendanceService.fetchAttendanceScore()
.compactMap{ $0.data?.toDomain() }
.eraseToAnyPublisher()
}
}
15 changes: 11 additions & 4 deletions SOPT-iOS/Projects/Domain/Sources/Model/UserMainInfoModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
import Foundation

public struct UserMainInfoModel {
public let status, name, profileImage: String
public let status, name: String
public let profileImage: String?
public let historyList: [Int]
public let attendanceScore: Float
public let announcement: String
public let attendanceScore: Float?
public let announcement: String?
public let responseMessage: String?
public var withError: Bool = false

public init(status: String, name: String, profileImage: String, historyList: [Int], attendanceScore: Float, announcement: String, responseMessage: String?) {
public init(status: String, name: String, profileImage: String?, historyList: [Int], attendanceScore: Float?, announcement: String?, responseMessage: String?) {
self.status = status
self.name = name
self.profileImage = profileImage
Expand All @@ -24,4 +26,9 @@ public struct UserMainInfoModel {
self.announcement = announcement
self.responseMessage = responseMessage
}

public init(withError: Bool) {
self.init(status: "", name: "", profileImage: nil, historyList: [], attendanceScore: nil, announcement: nil, responseMessage: nil)
self.withError = withError
}
}
1 change: 1 addition & 0 deletions SOPT-iOS/Projects/Domain/Sources/UseCase/MainUseCase.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class DefaultMainUseCase {
extension DefaultMainUseCase: MainUseCase {
public func getUserMainInfo() {
repository.getUserMainInfo()
.replaceError(with: UserMainInfoModel.init(withError: true))
.sink { event in
print("MainUseCase: \(event)")
} receiveValue: { [weak self] userMainInfoModel in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension DefaultShowAttendanceUseCase: ShowAttendanceUseCase {
public func fetchAttendanceSchedule() {
self.repository.fetchAttendanceScheduleModel()
.sink(receiveCompletion: { event in
print("completion: \(event)")
print("completion: fetchAttendanceSchedule \(event)")
}, receiveValue: { model in
self.attendanceScheduleFetched.send(model)
})
Expand All @@ -43,7 +43,7 @@ extension DefaultShowAttendanceUseCase: ShowAttendanceUseCase {
public func fetchAttendanceScore() {
self.repository.fetchAttendanceScoreModel()
.sink(receiveCompletion: { event in
print("completion: \(event)")
print("completion: fetchAttendanceScore \(event)")
}, receiveValue: { model in
self.attendanceScoreFetched.send(model)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import UIKit

import Combine
import SafariServices
import SnapKit
import Then

Expand All @@ -33,17 +34,17 @@ public final class AppMyPageVC: UIViewController, AppMyPageViewControllable {
private let viewModel: AppMyPageViewModel
private let factory: SettingFeatureViewBuildable & AlertViewBuildable & AuthFeatureViewBuildable
private let userType: UserType

// MARK: Combine
private let resetButtonTapped = PassthroughSubject<Bool, Never>()
private let cancelBag = CancelBag()

// MARK: - Views
private lazy var navigationBar = OPNavigationBar(
self,
type: .oneLeftButton,
backgroundColor: DSKitAsset.Colors.black100.color
)
self,
type: .oneLeftButton,
backgroundColor: DSKitAsset.Colors.black100.color
)
.addMiddleLabel(title: I18N.MyPage.navigationTitle)

private let scrollView = UIScrollView()
Expand Down Expand Up @@ -158,7 +159,7 @@ public final class AppMyPageVC: UIViewController, AppMyPageViewControllable {
extension AppMyPageVC {
public override func viewDidLoad() {
super.viewDidLoad()

self.navigationController?.navigationBar.isHidden = true
self.view.backgroundColor = DSKitAsset.Colors.black100.color

Expand Down Expand Up @@ -206,7 +207,7 @@ extension AppMyPageVC {
$0.bottom.equalToSuperview()
}
}

// TODO: - (@승호): 적절히 객체에 위임하기
private func addTabGestureOnListItems() {
self.servicePolicySectionGroup.addTapGestureRecognizer {
Expand Down Expand Up @@ -292,7 +293,7 @@ extension AppMyPageVC {
UserDefaultKeyList.Auth.appAccessToken = nil
UserDefaultKeyList.Auth.appRefreshToken = nil
UserDefaultKeyList.Auth.playgroundToken = nil

SFSafariViewController.DataStore.default.clearWebsiteData()
}

private func showLoginViewController() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
//

import UIKit
import Combine
import SafariServices

import DSKit

import Core

import Domain

import Combine
import SnapKit
import Then

import AuthFeatureInterface
import MainFeatureInterface

import SnapKit
import Then

public class SignInVC: UIViewController, SignInViewControllable {

// MARK: - Properties
Expand Down Expand Up @@ -195,7 +194,9 @@ extension SignInVC {
)
let output = self.viewModel.transform(from: input, cancelBag: cancelBag)

output.isSignInSuccess.sink { [weak self] isSuccessed in
output.isSignInSuccess
.removeDuplicates()
.sink { [weak self] isSuccessed in
guard let self = self else { return }
if isSuccessed {
self.setRootViewToMain()
Expand All @@ -214,8 +215,9 @@ extension SignInVC {
dateFormatter.dateFormat = "yyyyMMddHHmmss"
let state = dateFormatter.string(from: Date())
UserDefaultKeyList.Auth.requestState = state
openExternalLink(urlStr: ExternalURL.Playground.login(state: state)) {
print("플레이그라운드 Open URL")
}
let safari = SFSafariViewController(url: URL(string: ExternalURL.Playground.login(state: state))!)
safari.modalPresentationStyle = .fullScreen
safari.playgroundStyle()
self.present(safari, animated: true)
}
}
Loading

0 comments on commit c630310

Please sign in to comment.