Skip to content

Commit

Permalink
๐ŸŽจ :: [#68] Edit ๋‚ ์งœ ํ˜•์‹ yyyy.mm.dd -> yyyy-mm-dd๋กœ ๋ณ€๊ฒฝ
Browse files Browse the repository at this point in the history
  • Loading branch information
Xixn2 committed Dec 7, 2024
1 parent 04674eb commit 5d45bf5
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ struct ExpoCreateView: View {
@State private var scaleXTextField: Float = 0.0
@State private var scaleYTextField: Float = 0.0
@State private var date: [String] = ["", ""]
@State private var trainingCount: [String] = []
@State private var trainingCount: [String] = [""]
@State private var programCount: [String] = [""]
@State private var selectedImage: UIImage? = nil
@State private var isImagePickerPresented = false
@StateObject var viewModel: ExpoCreateViewModel
Expand Down Expand Up @@ -110,7 +111,7 @@ struct ExpoCreateView: View {
HStack(spacing: 6) {
ExpoIOSAsset.Assets.warning.swiftUIImage

Text("์‹œ์ž‘์ผ๊ณผ ๋งˆ๊ฐ์ผ ์ž…๋ ฅ์‹œ โ€˜ yyyy.mm.dd โ€˜ ํ˜•์‹์œผ๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
Text("์‹œ์ž‘์ผ๊ณผ ๋งˆ๊ฐ์ผ ์ž…๋ ฅ์‹œ โ€˜ yyyy-mm-dd โ€˜ ํ˜•์‹์œผ๋กœ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”")
.expoFont(.caption2R)
.expoColor(ExpoColor.gray300)
}
Expand Down Expand Up @@ -138,7 +139,58 @@ struct ExpoCreateView: View {
.expoColor(ExpoColor.main)
}

Text("์—ฐ์ˆ˜ ์ข…๋ฅ˜")
Text("์ผ๋ฐ˜ ํ”„๋กœ๊ทธ๋žจ")
.expoFont(.body2B)
.padding(.leading, 14)
.padding(.top, 28)
.padding(.bottom, 8)

VStack(spacing: 0) {
ForEach(programCount.indices, id: \.self) { index in
HStack(spacing: 0) {
Text("\(index + 1)")
.padding(.leading, 32)
.expoColor(ExpoColor.gray500)

TextField("์—ฐ์ˆ˜ ์ž…๋ ฅํ•˜์„ธ์š”.", text: $trainingCount[index])
.padding(.leading, 12)

Spacer()

Button {
if programCount.count > 1 {
programCount.remove(at: index)
}
} label: {
ExpoIOSAsset.Assets.grayXButton.swiftUIImage
.padding(.trailing, 32)
}
}
.expoFont(.body2R)
.padding(.bottom, 34)
}

Button {
trainingCount.append("")
} label: {
HStack(spacing: 8) {
ExpoIOSAsset.Assets.plusBlue.swiftUIImage
Text("์ถ”๊ฐ€ํ•˜๊ธฐ")
.expoFont(.caption1B)
.expoColor(ExpoColor.main300)
}
.padding(.bottom, 26)
}
}
.padding(.top, 26)
.overlay {
RoundedRectangle(cornerRadius: 8)
.strokeBorder(ExpoColor.gray300.swiftUIColor)
.padding(.horizontal, 16)

}

Text("์—ฐ์ˆ˜์ž ํ”„๋กœ๊ทธ๋žจ")
.expoFont(.body2B)
.padding(.leading, 14)
.padding(.top, 28)
Expand All @@ -151,7 +203,7 @@ struct ExpoCreateView: View {
.padding(.leading, 32)
.expoColor(ExpoColor.gray500)

TextField("์—ฐ์ˆ˜๋ฅผ ์ž…๋ ฅํ•ด์ฃผ์„ธ์š”.", text: $trainingCount[index])
TextField("์—ฐ์ˆ˜ ์ž…๋ ฅํ•˜์„ธ์š”.", text: $trainingCount[index])
.padding(.leading, 12)

Spacer()
Expand Down Expand Up @@ -232,12 +284,14 @@ struct ExpoCreateView: View {
viewModel.setupFinishedDay(finishedDay: date[1])
viewModel.setupLocation(location: locationTextField)
if let selectedImage = selectedImage, let base64ImageString = convertImageToBase64String(image: selectedImage) {
viewModel.setupCoverImage(coverImage: base64ImageString)
viewModel.setupCoverImage(coverImageBase64: base64ImageString)
} else {
print("์ด๋ฏธ์ง€๊ฐ€ ์œ ํšจํ•˜์ง€ ์•Š๊ฑฐ๋‚˜ Base64๋กœ ๋ณ€ํ™˜ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.")
}
viewModel.setupScaleX(scaleX: scaleXTextField)
viewModel.setupScaleY(scaleY: scaleYTextField)
//viewModel.setupScaleX(scaleX: scaleXTextField)
//viewModel.setupScaleY(scaleY: scaleYTextField)
viewModel.setupScaleX(x: scaleXTextField)
viewModel.setupScaleY(y: scaleYTextField)
viewModel.expoCreate { success in
if success {
print("๋ฐ•๋žŒํšŒ ์ƒ์„ฑ ์„ฑ๊ณต(Success)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright ยฉ 2024 SchoolofCompany. All rights reserved.
//

import UIKit
import Moya
import Domain
import Foundation
Expand All @@ -19,9 +20,9 @@ public final class ExpoCreateViewModel: ObservableObject {
private var startedDay: String = ""
private var finishedDay: String = ""
private var location: String = ""
private var coverImage: String = ""
private var scaleX: Float = 0.0
private var scaleY: Float = 0.0
private var coverImage: String = "" // Base64 ๋ฌธ์ž์—ด๋กœ ์ €์žฅ๋  ์˜ˆ์ •
private var x: Float = 0.0
private var y: Float = 0.0

private var passwordServe: String = ""

Expand All @@ -45,28 +46,53 @@ public final class ExpoCreateViewModel: ObservableObject {
self.location = location
}

func setupCoverImage(coverImage: String) {
self.coverImage = coverImage
// UIImage๋ฅผ Base64๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
func convertImageToBase64String(image: UIImage) -> String? {
if let imageData = image.jpegData(compressionQuality: 1.0) {
return imageData.base64EncodedString()
}
return nil
}

// Base64 ๋ฌธ์ž์—ด์„ UIImage๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ•จ์ˆ˜
func convertBase64ToUIImage(base64String: String) -> UIImage? {
if let imageData = Data(base64Encoded: base64String) {
return UIImage(data: imageData)
}
return nil
}

// setupCoverImage ํ•จ์ˆ˜ (Base64 ๋ฌธ์ž์—ด์„ ๋ฐ›์Œ)
func setupCoverImage(coverImageBase64: String) {
self.coverImage = coverImageBase64 // Base64 ๋ฌธ์ž์—ด์„ ์ง์ ‘ ์ €์žฅ
print("Cover Image (Base64): \(coverImageBase64)") // Base64 ์ถœ๋ ฅ
}

func setupScaleX(scaleX: Float) {
self.scaleX = scaleX
func setupScaleX(x: Float) {
self.x = x
}

func setupScaleY(scaleY: Float) {
self.scaleY = scaleY
func setupScaleY(y: Float) {
self.y = y
}

func expoCreate(completion: @escaping (Bool) -> Void) {
// coverImage๊ฐ€ ์ด๋ฏธ Base64 ๋ฌธ์ž์—ด๋กœ ์„ค์ •๋˜์—ˆ์Œ์„ ์ „์ œ๋กœ ํ•ฉ๋‹ˆ๋‹ค.
if coverImage.isEmpty {
print("Cover image is empty, cannot proceed.")
completion(false)
return
}

authProvider.request(.expoCreate(param: ExpoCreateRequest(
title: title,
description: description,
startedDay: startedDay,
finishedDay: finishedDay,
location: location,
coverImage: coverImage,
scaleX: scaleX,
scaleY: scaleY
coverImage: coverImage, // ์ด๋ฏธ Base64๋กœ ๋ณ€ํ™˜๋œ coverImage ์‚ฌ์šฉ
x: x,
y: y
))) { response in
switch response {
case .success(let result):
Expand All @@ -77,7 +103,6 @@ public final class ExpoCreateViewModel: ObservableObject {
print("Server message: \(message)")
} else {
print("Response data could not be parsed or 'message' key is missing")

}

switch statusCode {
Expand Down Expand Up @@ -108,3 +133,6 @@ public final class ExpoCreateViewModel: ObservableObject {
}
}
}



Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public struct ExpoCreateRequest: Codable {
var finishedDay: String
var location: String
var coverImage: String
var scaleX: Float
var scaleY: Float
var x: Float
var y: Float

public init(
title: String,
Expand All @@ -25,16 +25,16 @@ public struct ExpoCreateRequest: Codable {
finishedDay: String,
location: String,
coverImage: String,
scaleX: Float,
scaleY: Float
x: Float,
y: Float
) {
self.title = title
self.description = description
self.startedDay = startedDay
self.finishedDay = finishedDay
self.location = location
self.coverImage = coverImage
self.scaleX = scaleX
self.scaleY = scaleY
self.x = x
self.y = y
}
}
2 changes: 1 addition & 1 deletion Projects/Domain/Sources/Services/Expo/ExpoAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ extension ExpoAPI: TargetType {
}

public var sampleData: Data {
return "@@".data(using: .utf8)!
return "{}".data(using: .utf8)!
}

public var task: Task {
Expand Down
27 changes: 26 additions & 1 deletion Scripts/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -1 +1,26 @@
# Empty
excluded:
- fastlane
- Dependencies

disabled_rules:
- void_function_in_ternary

identifier_name:
min_length: 1
max_length: 60
allowed_symbols: [_]

large_tuple:
warning: 3
error: 4

line_length:
warning: 120
error: 200
ignores_urls: true
ignores_comments: true

type_name:
min_length: 2
max_length: 60
allowed_symbols: [_]

0 comments on commit 5d45bf5

Please sign in to comment.