-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feat/#15-on-view
- Loading branch information
Showing
88 changed files
with
6,171 additions
and
615 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,37 @@ | ||
// | ||
// Ext + Date.swift | ||
// On_off_iOS | ||
// | ||
// Created by 정호진 on 2/13/24. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Date { | ||
|
||
/** | ||
# dateCompare | ||
- Parameters: | ||
- fromDate: 비교 대상 Date | ||
- Note: 두 날짜간 비교해서 과거(Future)/현재(Same)/미래(Past) 반환 | ||
*/ | ||
public func dateCompare(fromDate: Date) -> String { | ||
var strDateMessage:String = "" | ||
let result: ComparisonResult = self.compare(fromDate) | ||
switch result { | ||
case .orderedAscending: | ||
strDateMessage = "Future" | ||
break | ||
case .orderedDescending: | ||
strDateMessage = "Past" | ||
break | ||
case .orderedSame: | ||
strDateMessage = "Same" | ||
break | ||
default: | ||
strDateMessage = "Error" | ||
break | ||
} | ||
return strDateMessage | ||
} | ||
} |
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
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
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 |
---|---|---|
|
@@ -8,6 +8,9 @@ | |
import Foundation | ||
|
||
struct DayInfo { | ||
/// 전체 날짜 | ||
let totalDate: String? | ||
|
||
/// 일, 숫자 | ||
let date: String? | ||
|
||
|
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,18 @@ | ||
// | ||
// WeekDay.swift | ||
// On_off_iOS | ||
// | ||
// Created by 정호진 on 2/13/24. | ||
// | ||
|
||
import Foundation | ||
|
||
struct WeekDay: Codable { | ||
let monday: String? | ||
let tuesday: String? | ||
let wednesday: String? | ||
let thursday: String? | ||
let friday: String? | ||
let saturday: String? | ||
let sunday: String? | ||
} |
122 changes: 122 additions & 0 deletions
122
On_off_iOS/On_off_iOS/Home/Base/Service/HomeViewService.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,122 @@ | ||
// | ||
// HomeViewService.swift | ||
// On_off_iOS | ||
// | ||
// Created by 정호진 on 2/13/24. | ||
// | ||
|
||
import Foundation | ||
import Alamofire | ||
import RxSwift | ||
|
||
final class HomeViewService { | ||
private let disposeBag = DisposeBag() | ||
|
||
/// 일주일 날짜 초기 가져오기 | ||
/// - Returns: Week Day | ||
func weekDayInit() -> Observable<WeekDay> { | ||
let url = Domain.RESTAPI + WeekDayPath.weekdayInit.rawValue | ||
let header = Header.header.getHeader() | ||
return Observable.create { observer in | ||
AF.request(url, | ||
method: .get, | ||
headers: header) | ||
.validate(statusCode: 200..<201) | ||
.responseDecodable(of: Response<WeekDay>.self) { response in | ||
print(#function, response) | ||
switch response.result { | ||
case .success(let data): | ||
observer.onNext(data.result) | ||
case .failure(let error): | ||
observer.onError(error) | ||
} | ||
} | ||
|
||
return Disposables.create() | ||
} | ||
} | ||
|
||
/// Get My Information | ||
/// - Returns: My Information | ||
func getMyNickName() -> Observable<String> { | ||
let url = Domain.RESTAPI + MyPage.myInfo.rawValue | ||
let header = Header.header.getHeader() | ||
|
||
return Observable.create { observer in | ||
AF.request(url, | ||
method: .get, | ||
headers: header) | ||
.validate(statusCode: 200..<201) | ||
.responseDecodable(of: Response<MyInfo>.self) { response in | ||
print(#function, response) | ||
switch response.result { | ||
case .success(let data): | ||
observer.onNext(data.result.nickname ?? "") | ||
case .failure(let error): | ||
observer.onError(error) | ||
} | ||
} | ||
|
||
return Disposables.create() | ||
} | ||
} | ||
|
||
/// 이전 일주일 날짜 가져오기 | ||
/// - Returns: Week Day | ||
/// - Parameter date: 선택한 날짜 | ||
func movePrevWeek(date: String) -> Observable<WeekDay> { | ||
let url = Domain.RESTAPI + WeekDayPath.prevWeek.rawValue | ||
let parameters: Parameters = ["date": date] | ||
let header = Header.header.getHeader() | ||
print(url, #function) | ||
return Observable.create { observer in | ||
AF.request(url, | ||
method: .get, | ||
parameters: parameters, | ||
encoding: URLEncoding.default, | ||
headers: header) | ||
.validate(statusCode: 200..<201) | ||
.responseDecodable(of: Response<WeekDay>.self) { response in | ||
print(#function, response) | ||
switch response.result { | ||
case .success(let data): | ||
observer.onNext(data.result) | ||
case .failure(let error): | ||
observer.onError(error) | ||
} | ||
} | ||
|
||
return Disposables.create() | ||
} | ||
} | ||
|
||
/// 다음 일주일 날짜 가져오기 | ||
/// - Returns: Week Day | ||
/// - Parameter date: 선택한 날짜 | ||
func moveNextWeek(date: String) -> Observable<WeekDay> { | ||
let url = Domain.RESTAPI + WeekDayPath.nextWeek.rawValue | ||
let parameters: Parameters = ["date": date] | ||
let header = Header.header.getHeader() | ||
print(url, #function) | ||
return Observable.create { observer in | ||
AF.request(url, | ||
method: .get, | ||
parameters: parameters, | ||
encoding: URLEncoding.default, | ||
headers: header) | ||
.validate(statusCode: 200..<201) | ||
.responseDecodable(of: Response<WeekDay>.self) { response in | ||
print(#function, response) | ||
switch response.result { | ||
case .success(let data): | ||
observer.onNext(data.result) | ||
case .failure(let error): | ||
observer.onError(error) | ||
} | ||
} | ||
|
||
return Disposables.create() | ||
} | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.