Skip to content

Commit

Permalink
Merge pull request #11 from TheClimeet/CIOS-26-RootSelection
Browse files Browse the repository at this point in the history
Feature/Cios 26/Root Selection (구현 중, 기획 변경으로 인한 조기 PR)
  • Loading branch information
iOS-Woong authored Jun 14, 2024
2 parents 60d6d79 + 0efbc99 commit 45672c8
Show file tree
Hide file tree
Showing 12 changed files with 359 additions and 145 deletions.
32 changes: 32 additions & 0 deletions Climeet-iOS/Climeet-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
D4EE0CFD2BD14AFB004C6688 /* ResponseDTO.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EE0CFC2BD14AFB004C6688 /* ResponseDTO.swift */; };
D4EE0CFF2BD14B59004C6688 /* ExampleAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EE0CFE2BD14B59004C6688 /* ExampleAPI.swift */; };
D4EE0D032BD14BAB004C6688 /* Encodable + toDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4EE0D022BD14BAB004C6688 /* Encodable + toDictionary.swift */; };
D4F161782C1AAB6300BF4392 /* RootSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F161772C1AAB6300BF4392 /* RootSelectionView.swift */; };
D4F1617A2C1AFE1D00BF4392 /* ActivityRecordHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F161792C1AFE1C00BF4392 /* ActivityRecordHeader.swift */; };
D4F1617C2C1B1F5000BF4392 /* ClimbingSetupButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F1617B2C1B1F5000BF4392 /* ClimbingSetupButton.swift */; };
D4F1617E2C1B1F8B00BF4392 /* ClimbingSetupView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D4F1617D2C1B1F8B00BF4392 /* ClimbingSetupView.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -97,6 +101,10 @@
D4EE0CFC2BD14AFB004C6688 /* ResponseDTO.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseDTO.swift; sourceTree = "<group>"; };
D4EE0CFE2BD14B59004C6688 /* ExampleAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleAPI.swift; sourceTree = "<group>"; };
D4EE0D022BD14BAB004C6688 /* Encodable + toDictionary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Encodable + toDictionary.swift"; sourceTree = "<group>"; };
D4F161772C1AAB6300BF4392 /* RootSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootSelectionView.swift; sourceTree = "<group>"; };
D4F161792C1AFE1C00BF4392 /* ActivityRecordHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ActivityRecordHeader.swift; sourceTree = "<group>"; };
D4F1617B2C1B1F5000BF4392 /* ClimbingSetupButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClimbingSetupButton.swift; sourceTree = "<group>"; };
D4F1617D2C1B1F8B00BF4392 /* ClimbingSetupView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClimbingSetupView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -189,6 +197,8 @@
children = (
D44FF1F42C145872005E9EB1 /* ActivityRecordView.swift */,
D44FF1F62C145E66005E9EB1 /* ActivityRecordReducer.swift */,
D4F161742C1AAB4200BF4392 /* View */,
D4F161732C1AAB2300BF4392 /* Model */,
);
path = ActivityRecord;
sourceTree = "<group>";
Expand Down Expand Up @@ -346,6 +356,24 @@
path = Repository;
sourceTree = "<group>";
};
D4F161732C1AAB2300BF4392 /* Model */ = {
isa = PBXGroup;
children = (
);
path = Model;
sourceTree = "<group>";
};
D4F161742C1AAB4200BF4392 /* View */ = {
isa = PBXGroup;
children = (
D4F161772C1AAB6300BF4392 /* RootSelectionView.swift */,
D4F161792C1AFE1C00BF4392 /* ActivityRecordHeader.swift */,
D4F1617B2C1B1F5000BF4392 /* ClimbingSetupButton.swift */,
D4F1617D2C1B1F8B00BF4392 /* ClimbingSetupView.swift */,
);
path = View;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -462,6 +490,7 @@
D473920C2C193C090059AE45 /* SheetType.swift in Sources */,
D4EE0D032BD14BAB004C6688 /* Encodable + toDictionary.swift in Sources */,
D4B75EEE2C0B3CAA0074870D /* AppError.swift in Sources */,
D4F1617A2C1AFE1D00BF4392 /* ActivityRecordHeader.swift in Sources */,
04CFB9EE2C007F4900580395 /* test.swift in Sources */,
D47A3AB02C0CAD810031DCAA /* GymSearchResult.swift in Sources */,
D47A3AB52C0CAF750031DCAA /* ResponseDTO + mapping.swift in Sources */,
Expand All @@ -472,10 +501,12 @@
D4930E312C0F3EE2002E138B /* Text + init.swift in Sources */,
D47A3AAD2C0CAC4B0031DCAA /* SearchReducer.swift in Sources */,
D4EE0CF82BD149EF004C6688 /* Router.swift in Sources */,
D4F1617C2C1B1F5000BF4392 /* ClimbingSetupButton.swift in Sources */,
D4E282052C0D4A7400567B92 /* UserRepository.swift in Sources */,
D47A3AAB2C0CAC400031DCAA /* SearchView.swift in Sources */,
D44FF1F52C145872005E9EB1 /* ActivityRecordView.swift in Sources */,
D4EE0CFD2BD14AFB004C6688 /* ResponseDTO.swift in Sources */,
D4F1617E2C1B1F8B00BF4392 /* ClimbingSetupView.swift in Sources */,
B94EC2262BD13CBB00DC3FDB /* Climeet_iOSApp.swift in Sources */,
D44FF2282C183574005E9EB1 /* DateTimePickerReducer.swift in Sources */,
D442A3E12BF9D3F400A58F92 /* SearchRequestModel.swift in Sources */,
Expand All @@ -486,6 +517,7 @@
D44FF1F72C145E66005E9EB1 /* ActivityRecordReducer.swift in Sources */,
D442A3DE2BF9D36500A58F92 /* SearchAPI.swift in Sources */,
D4B75EF02C0B3D540074870D /* Error + toAppError.swift in Sources */,
D4F161782C1AAB6300BF4392 /* RootSelectionView.swift in Sources */,
D47A3AB32C0CAE2D0031DCAA /* SearchUsecase.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
Binary file modified Climeet-iOS/Climeet-iOS/.DS_Store
Binary file not shown.
22 changes: 11 additions & 11 deletions Climeet-iOS/Climeet-iOS/Common/Extension/DateFormatter + .swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ extension DateFormatter {

// MARK: 2023년 12월 12일 (화)
static let koreanFullDateWithDayFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy년 MM월 dd일 (E)"
formatter.timeZone = TimeZone(identifier: "Asia/Seoul")
formatter.locale = Locale(identifier: "ko_KR")
return formatter
let formatter = DateFormatter()
formatter.dateFormat = "yyyy년 MM월 dd일 (E)"
formatter.timeZone = TimeZone(identifier: "Asia/Seoul")
formatter.locale = Locale(identifier: "ko_KR")
return formatter
}()

// MARK: AM 9:00
static let amTimeFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "a h:mm"
formatter.timeZone = TimeZone(identifier: "Asia/Seoul")
formatter.locale = Locale(identifier: "en_US_POSIX") // AM/PM 표기를 위해 영어 로케일 사용
return formatter
}()
let formatter = DateFormatter()
formatter.dateFormat = "a h:mm"
formatter.timeZone = TimeZone(identifier: "Asia/Seoul")
formatter.locale = Locale(identifier: "en_US_POSIX") // AM/PM 표기를 위해 영어 로케일 사용
return formatter
}()
}
16 changes: 16 additions & 0 deletions Climeet-iOS/Climeet-iOS/Domain/GymSearchResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ struct Gym: Identifiable {
let follower: Int
let profileImageUrl: String
let isFollow: Bool?

init(
gymId: Int? = nil,
name: String = "",
managerId: Int? = nil,
follower: Int = 0,
profileImageUrl: String = "",
isFollow: Bool? = nil)
{
self.gymId = gymId
self.name = name
self.managerId = managerId
self.follower = follower
self.profileImageUrl = profileImageUrl
self.isFollow = isFollow
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct ActivityRecordReducer {
struct State {
var screenSize = CGSize(width: 0, height: 0)
var bottomSheetHeight: CGFloat = 0.0
var selectedGymName = ""
var selectedGym = Gym()
var selectedDate = ""
var selectedTime = ""
@Presents var destination: Destination.State?
Expand All @@ -44,26 +44,40 @@ struct ActivityRecordReducer {
state.screenSize = viewSize

return .none

case .selectDateButtonTapped:
state.bottomSheetHeight = state.screenSize.height * SheetType.datePicker.displaySizeRatio
state.destination = .selectDateTime(
DateTimePickerReducer.State(
sheetType: .datePicker
)

var reducer = DateTimePickerReducer.State(
sheetType: .datePicker
)
if !state.selectedDate.isEmpty {
reducer.selectedDate = parseKoreanFullToDate(
dateString: state.selectedDate
)
}
state.destination = .selectDateTime(reducer)

return .none

case .selectTimeButtonTapped:
state.bottomSheetHeight = state.screenSize.height * SheetType.timePicker.displaySizeRatio
state.destination = .selectDateTime(
DateTimePickerReducer.State(
sheetType: .timePicker
)

var reducer = DateTimePickerReducer.State(
sheetType: .timePicker
)

if !state.selectedTime.isEmpty {
let times = parseTimeRange(timeRange: state.selectedTime)
reducer.selectedStartTime = times.start
reducer.selectedEndTime = times.end
}
state.destination = .selectDateTime(reducer)

return .none

case let .path(.element(_, action: .delegate(.selectGym(selectedGym)))):
state.selectedGymName = selectedGym.name
state.selectedGym = selectedGym

return .none

Expand All @@ -81,8 +95,8 @@ struct ActivityRecordReducer {

// MARK: tacocat 사용 Delegate
case let .destination(.presented(.searchGyms(.delegate(.selectGym(selectedGym))))):
state.selectedGymName = selectedGym.name
print(state.selectedGymName)
state.selectedGym = selectedGym
print(state.selectedGym)

return .none

Expand All @@ -98,3 +112,34 @@ struct ActivityRecordReducer {
}
}
}

extension ActivityRecordReducer {

/// AM 9:00 ~ AM 11:00 -> `(Date, Date)`
private func parseTimeRange(timeRange: String) -> (start: Date, end: Date) {
let dateFormatter = DateFormatter.amTimeFormatter

let times = timeRange
.split(separator: "~")
.map { $0.trimmingCharacters(in: .whitespaces) }

guard times.count == 2,
let startTime = dateFormatter.date(from: String(times[0])),
let endTime = dateFormatter.date(from: String(times[1])) else {
return (Date(), Date())
}

return (startTime, endTime)
}

/// 2023년 12월 12일 (화) -> `Date`
private func parseKoreanFullToDate(dateString: String) -> Date {
guard
let date = DateFormatter.koreanFullDateWithDayFormatter.date(
from: dateString) else {
return Date()
}

return date
}
}
Loading

0 comments on commit 45672c8

Please sign in to comment.