diff --git a/RecordManagment/Assets.xcassets/Exercise/WEIGHT_TRAINING.imageset/Contents.json b/RecordManagment/Assets.xcassets/Exercise/WEIGHT_TRAINING.imageset/Contents.json index 5f47049..34350d9 100644 --- a/RecordManagment/Assets.xcassets/Exercise/WEIGHT_TRAINING.imageset/Contents.json +++ b/RecordManagment/Assets.xcassets/Exercise/WEIGHT_TRAINING.imageset/Contents.json @@ -1,7 +1,7 @@ { "images" : [ { - "filename" : "WEIGHTS.pdf", + "filename" : "WEIGHT_TRAINING.pdf", "idiom" : "universal" } ], diff --git a/RecordManagment/Assets.xcassets/Exercise/WEIGHT_TRAINING.imageset/WEIGHT_TRAINING.pdf b/RecordManagment/Assets.xcassets/Exercise/WEIGHT_TRAINING.imageset/WEIGHT_TRAINING.pdf new file mode 100644 index 0000000..0f79d0c Binary files /dev/null and b/RecordManagment/Assets.xcassets/Exercise/WEIGHT_TRAINING.imageset/WEIGHT_TRAINING.pdf differ diff --git a/RecordManagment/Domain/Entitiy/Calendar/CalendarDetail.swift b/RecordManagment/Domain/Entitiy/Calendar/CalendarDetail.swift index bd87f0f..e594772 100644 --- a/RecordManagment/Domain/Entitiy/Calendar/CalendarDetail.swift +++ b/RecordManagment/Domain/Entitiy/Calendar/CalendarDetail.swift @@ -61,7 +61,7 @@ struct ExerciseResponse: Decodable, Equatable, Hashable { let caloriesBurned: Int? let exerciseTimeMinutes: Int? let stepCount: Int? - let weight: Int? + let weight: Double? let dailyNote: String let imageUrls: [String] @@ -76,7 +76,7 @@ struct ExerciseResponse: Decodable, Equatable, Hashable { caloriesBurned: Int? = nil, exerciseTimeMinutes: Int? = nil, stepCount: Int? = nil, - weight: Int? = nil, + weight: Double? = nil, dailyNote: String, imageUrls: [String] = [] ) { @@ -103,7 +103,7 @@ struct ExerciseResponse: Decodable, Equatable, Hashable { let caloriesBurned = try container.decodeIfPresent(Int.self, forKey: .caloriesBurned) let exerciseTimeMinutes = try container.decodeIfPresent(Int.self, forKey: .exerciseTimeMinutes) let stepCount = try container.decodeIfPresent(Int.self, forKey: .stepCount) - let weight = try container.decodeIfPresent(Int.self, forKey: .weight) + let weight = try container.decodeIfPresent(Double.self, forKey: .weight) let dailyNote = try container.decode(String.self, forKey: .dailyNote) self.base = RecordResponse(id: id, type: type, recordDate: recordDate, recordTime: recordTime, createdAt: createdAt, updatedAt: updatedAt) self.exerciseType = exerciseType diff --git a/RecordManagment/Domain/Entitiy/Exercise/ExerciseDTO.swift b/RecordManagment/Domain/Entitiy/Exercise/ExerciseDTO.swift index c89b1f7..1e34eef 100644 --- a/RecordManagment/Domain/Entitiy/Exercise/ExerciseDTO.swift +++ b/RecordManagment/Domain/Entitiy/Exercise/ExerciseDTO.swift @@ -5,7 +5,7 @@ struct ExerciseBody: Codable { let caloriesBurned: Int let exerciseTimeMinutes: Int let stepCount: Int - let weight: Int + let weight: Double let dailyNote: String var imageUrls: [String] let recordDate: String? diff --git a/RecordManagment/Domain/Entitiy/Exercise/ExerciseObj.swift b/RecordManagment/Domain/Entitiy/Exercise/ExerciseObj.swift index a750a77..713a125 100644 --- a/RecordManagment/Domain/Entitiy/Exercise/ExerciseObj.swift +++ b/RecordManagment/Domain/Entitiy/Exercise/ExerciseObj.swift @@ -35,7 +35,7 @@ enum ExerciseObj: String, CaseIterable { "야구" case .yoga: "요가" - case .weight_training: + case .weight_training: "웨이트 트레이닝" case .cycling: "자전거" diff --git a/RecordManagment/Presentation/View/Exercise/ExerciseRecordView.swift b/RecordManagment/Presentation/View/Exercise/ExerciseRecordView.swift index cacaee4..825bf8f 100644 --- a/RecordManagment/Presentation/View/Exercise/ExerciseRecordView.swift +++ b/RecordManagment/Presentation/View/Exercise/ExerciseRecordView.swift @@ -94,7 +94,7 @@ struct ExerciseRecordView: View { inputGroup(title: "소모 칼로리", placeHolder: "0 kcal", number: $vm.kcal, focused: .kcal) inputGroup(title: "운동 시간", placeHolder: "0 분", number: $vm.time, focused: .time) inputGroup(title: "걸음 수", placeHolder: "0 걸음", number: $vm.step, focused: .step) - inputGroup(title: "몸무게", placeHolder: "0 Kg", number: $vm.weight, focused: .weight) + weightGroup(title: "몸무게", placeHolder: "0 Kg", number: $vm.weight, focused: .weight) Divider().foregroundStyle(Color.Gray._200()) inputGroup(title: "나의 하루", placeHolder: "NAN", isMultiField: true) ImagesHStack(selectedImages: $vm.selectedImages, selectedItems: $vm.selectedItems, isFocused: $isFocused) @@ -252,6 +252,58 @@ struct ExerciseRecordView: View { } } + // TODO: TextLabel Group 뷰 ( 몸무게 ) + private func weightGroup(title: String, placeHolder: String, number: Binding = .constant(0), isMultiField: Bool = false, focused: Field? = nil) -> some View { + + var numberText: Binding { + Binding( + get: { + if let focused = focused { + if isFocused == focused { + return number.wrappedValue == 0 ? "" : String(format: "%g", number.wrappedValue) + } else { + return number.wrappedValue == 0 ? "" : "\(String(format: "%g", number.wrappedValue)) \(focused.getName())" + } + } + return "" + }, + set: { newValue in + var filtered = "" + var decimalAdded = false + for char in newValue { + if char.isWholeNumber { + filtered.append(char) + } else if char == "." && !decimalAdded { + filtered.append(char) + decimalAdded = true + } + } + if let value = Double(filtered) { + number.wrappedValue = value + } else if isFocused == focused { + number.wrappedValue = 0 + } + } + ) + } + + return VStack(spacing: 10) { + Text(title) + .typography(.p14SemiBold) + .frame(maxWidth: .infinity, alignment: .leading) + if isMultiField { + MultiTextField(text: $vm.text, isFocused: $isFocused) + } else { + TextField(placeHolder, text: numberText) + .focused($isFocused, equals: focused) + .padding(14) + .background(Color.Gray._100()) + .clipShape(.rect(cornerRadius: 8)) + .keyboardType(.decimalPad) + } + } + } + // TODO: Exercise ReSelection View private var exerciseReSelectionView: some View { NavigationStack { @@ -295,3 +347,4 @@ struct ExerciseRecordView: View { } } + diff --git a/RecordManagment/Presentation/ViewModel/ExerciseRecordView+ViewModel.swift b/RecordManagment/Presentation/ViewModel/ExerciseRecordView+ViewModel.swift index 6d57340..220af62 100644 --- a/RecordManagment/Presentation/ViewModel/ExerciseRecordView+ViewModel.swift +++ b/RecordManagment/Presentation/ViewModel/ExerciseRecordView+ViewModel.swift @@ -9,7 +9,7 @@ extension ExerciseRecordView { @Published var kcal: Int = 0 @Published var time: Int = 0 @Published var step: Int = 0 - @Published var weight: Int = 0 + @Published var weight: Double = 0 @Published var text: String = "" @Published var selectedItems: [PhotosPickerItem] = [] @Published var selectedImages: [PhotoTransfer] = []