Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] #97 - 스파크 보내기 뷰 구현 및 사진인증 서버 연결 #105

Merged
merged 11 commits into from
Jan 18, 2022
Merged
20 changes: 19 additions & 1 deletion Spark-iOS/Spark-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
EBA93A82279082A5009AE771 /* CodeJoin.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EBA93A81279082A5009AE771 /* CodeJoin.storyboard */; };
EBA93A84279082B0009AE771 /* JoinCheck.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EBA93A83279082B0009AE771 /* JoinCheck.storyboard */; };
EBE90FCE2795C23A00157075 /* MyRoomCerti.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBE90FCD2795C23A00157075 /* MyRoomCerti.swift */; };
EBE90FD42795D67500157075 /* AuthUpload.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBE90FD32795D67500157075 /* AuthUpload.swift */; };
EBE90FDA2796128800157075 /* SendSparkVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBE90FD92796128800157075 /* SendSparkVC.swift */; };
EBE90FDC279612CA00157075 /* SendSpark.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EBE90FDB279612CA00157075 /* SendSpark.storyboard */; };
EBE90FDE2796C45900157075 /* StatusButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBE90FDD2796C45900157075 /* StatusButton.swift */; };
EBEA381D279441E000B5736A /* splash_iOS.json in Resources */ = {isa = PBXBuildFile; fileRef = EBEA381B279441DF00B5736A /* splash_iOS.json */; };
EBEA381F279450B900B5736A /* illust_confetti.json in Resources */ = {isa = PBXBuildFile; fileRef = EBEA381E279450B800B5736A /* illust_confetti.json */; };
EBEA382327945F5A00B5736A /* icHeartActive.json in Resources */ = {isa = PBXBuildFile; fileRef = EBEA382127945F5A00B5736A /* icHeartActive.json */; };
EBEA382D27947C9100B5736A /* MyRoomAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBEA382C27947C9100B5736A /* MyRoomAPI.swift */; };
Expand Down Expand Up @@ -192,6 +197,11 @@
EBA93A81279082A5009AE771 /* CodeJoin.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = CodeJoin.storyboard; sourceTree = "<group>"; };
EBA93A83279082B0009AE771 /* JoinCheck.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = JoinCheck.storyboard; sourceTree = "<group>"; };
EBE90FCD2795C23A00157075 /* MyRoomCerti.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyRoomCerti.swift; sourceTree = "<group>"; };
EBE90FD32795D67500157075 /* AuthUpload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthUpload.swift; sourceTree = "<group>"; };
EBE90FD92796128800157075 /* SendSparkVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SendSparkVC.swift; sourceTree = "<group>"; };
EBE90FDB279612CA00157075 /* SendSpark.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = SendSpark.storyboard; sourceTree = "<group>"; };
EBE90FDD2796C45900157075 /* StatusButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusButton.swift; sourceTree = "<group>"; };
EBEA381B279441DF00B5736A /* splash_iOS.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = splash_iOS.json; sourceTree = "<group>"; };
EBEA381E279450B800B5736A /* illust_confetti.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = illust_confetti.json; sourceTree = "<group>"; };
EBEA382127945F5A00B5736A /* icHeartActive.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = icHeartActive.json; sourceTree = "<group>"; };
EBEA382C27947C9100B5736A /* MyRoomAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyRoomAPI.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -378,8 +388,8 @@
2BE5D80927930A0F007A544D /* AuthTimer */ = {
isa = PBXGroup;
children = (
2BE5D80727930A06007A544D /* AuthTimerVC.swift */,
2BE5D81527932F31007A544D /* ResetPopupVC.swift */,
2BE5D80727930A06007A544D /* AuthTimerVC.swift */,
);
path = AuthTimer;
sourceTree = "<group>";
Expand Down Expand Up @@ -416,6 +426,7 @@
2BF3AB4B27947C50001A9042 /* WaitingRoom.swift */,
2BBED12C279539B90052CA5C /* WaitingMember.swift */,
EBEA38362794B34300B5736A /* CodeJoinCheck.swift */,
EBE90FD32795D67500157075 /* AuthUpload.swift */,
);
path = Room;
sourceTree = "<group>";
Expand Down Expand Up @@ -465,6 +476,7 @@
EB625E89278F29D300C43DE9 /* CarouselLayout.swift */,
EB9C507C27922F2E00588155 /* LineAnimationView.swift */,
2BE5D80D2793203C007A544D /* Stopwatch.swift */,
EBE90FDD2796C45900157075 /* StatusButton.swift */,
F86C68B627955ABA009A5296 /* SparkFlake.swift */,
);
path = Classes;
Expand Down Expand Up @@ -509,6 +521,7 @@
children = (
EB9C50832792A61D00588155 /* HabitAuthVC.swift */,
EB9C50892792A86D00588155 /* CompleteAuthVC.swift */,
EBE90FD92796128800157075 /* SendSparkVC.swift */,
);
path = HabitRoom;
sourceTree = "<group>";
Expand All @@ -518,6 +531,7 @@
children = (
EB9C50872792A67B00588155 /* HabitAuth.storyboard */,
EB9C508B2792A90400588155 /* CompleteAuth.storyboard */,
EBE90FDB279612CA00157075 /* SendSpark.storyboard */,
);
path = HabitRoom;
sourceTree = "<group>";
Expand Down Expand Up @@ -949,6 +963,7 @@
2B947204278CB00E005484C5 /* Futura Medium Italic.otf in Resources */,
2B9C6BCB279277D600CD914F /* GoalWriting.storyboard in Resources */,
F82B2E0E278ED01F00219628 /* Splash.storyboard in Resources */,
EBE90FDC279612CA00157075 /* SendSpark.storyboard in Resources */,
F80A3E51278C1BCE00728E07 /* Feed.storyboard in Resources */,
EBEA383527948C2D00B5736A /* ticket_welcome.json in Resources */,
F8FAA9772790346000C4190F /* HomeWaitingCVC.xib in Resources */,
Expand Down Expand Up @@ -1074,6 +1089,7 @@
2BBED1372795CDFE0052CA5C /* FeedEmptyCVC.swift in Sources */,
2B9C6BCE2792781F00CD914F /* GoalWritingVC.swift in Sources */,
F80A3E4F278C18BA00728E07 /* MainTBC.swift in Sources */,
EBE90FDA2796128800157075 /* SendSparkVC.swift in Sources */,
EBEA383927953BC700B5736A /* Lottie.swift in Sources */,
F82F57FD2792847D003E4174 /* GenericResponse.swift in Sources */,
2BBED1392795F4500052CA5C /* FeedCellDelegate.swift in Sources */,
Expand All @@ -1088,6 +1104,8 @@
EB9C507D27922F2E00588155 /* LineAnimationView.swift in Sources */,
EB625E7B278F271400C43DE9 /* DoingStorageCVC.swift in Sources */,
F816F125278E1C920008ED00 /* LoginVC.swift in Sources */,
EBE90FDE2796C45900157075 /* StatusButton.swift in Sources */,
EBE90FD42795D67500157075 /* AuthUpload.swift in Sources */,
F8096F3E2784213700B71D38 /* UIFont+.swift in Sources */,
F82F580A279289C4003E4174 /* HomeService.swift in Sources */,
EB625E95278F8E7200C43DE9 /* MoreStorageCVC.swift in Sources */,
Expand Down
1 change: 1 addition & 0 deletions Spark-iOS/Spark-iOS/Resource/Constants/Storyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extension Const {
static let authUpload = "AuthUpload"
static let authTimer = "AuthTimer"
static let resetPopup = "ResetPopup"
static let sendSpark = "SendSpark"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ extension Const {
static let authUpload = "AuthUploadVC"
static let authTimer = "AuthTimerVC"
static let resetPopup = "ResetPopupVC"
static let sendSpark = "SendSparkVC"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="19162" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="19144"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="System colors in document resources" minToolsVersion="11.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<customFonts key="customFonts">
<array key="NotoSansKR-Medium.otf">
<string>NotoSansKR-Medium</string>
</array>
<array key="NotoSansKR-Regular.otf">
<string>NotoSansKR-Regular</string>
</array>
</customFonts>
<scenes>
<!--Send SparkVC-->
<scene sceneID="s0d-6b-0kx">
<objects>
<viewController storyboardIdentifier="SendSparkVC" useStoryboardIdentifierAsRestorationIdentifier="YES" id="Y6W-OH-hqX" customClass="SendSparkVC" customModule="Spark_iOS" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="5EZ-qb-Rvc">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ELg-0t-yft">
<rect key="frame" x="0.0" y="485.5" width="414" height="410.5"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="친구에게 스파크 보내기" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="mx8-nr-Syp">
<rect key="frame" x="119" y="32" width="176" height="26.5"/>
<fontDescription key="fontDescription" name="NotoSansKR-Medium" family="Noto Sans KR" pointSize="18"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="메시지를 선택해 바로 보낼 수 있어요!" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Qix-as-tzS">
<rect key="frame" x="98.5" y="66.5" width="217.5" height="21"/>
<fontDescription key="fontDescription" name="NotoSansKR-Regular" family="Noto Sans KR" pointSize="14"/>
<color key="textColor" name="sparkDarkGray"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="mx8-nr-Syp" firstAttribute="top" secondItem="ELg-0t-yft" secondAttribute="top" constant="32" id="EMb-5y-4tF"/>
<constraint firstItem="Qix-as-tzS" firstAttribute="centerX" secondItem="ELg-0t-yft" secondAttribute="centerX" id="F0o-BF-BuN"/>
<constraint firstItem="mx8-nr-Syp" firstAttribute="centerX" secondItem="ELg-0t-yft" secondAttribute="centerX" id="fgL-l5-akU"/>
<constraint firstItem="Qix-as-tzS" firstAttribute="top" secondItem="mx8-nr-Syp" secondAttribute="bottom" constant="8" id="ov0-ev-f6s"/>
<constraint firstAttribute="width" secondItem="ELg-0t-yft" secondAttribute="height" multiplier="375:372" id="pUx-3e-Fnw"/>
</constraints>
</view>
</subviews>
<viewLayoutGuide key="safeArea" id="vDu-zF-Fre"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="ELg-0t-yft" secondAttribute="trailing" id="Ne1-Cs-Xfc"/>
<constraint firstItem="ELg-0t-yft" firstAttribute="leading" secondItem="vDu-zF-Fre" secondAttribute="leading" id="o3p-Yi-XMw"/>
<constraint firstAttribute="bottom" secondItem="ELg-0t-yft" secondAttribute="bottom" id="vzi-05-wVY"/>
</constraints>
</view>
<connections>
<outlet property="guideLabel" destination="Qix-as-tzS" id="jx6-iS-3sa"/>
<outlet property="popUpView" destination="ELg-0t-yft" id="AYr-Pm-aTG"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="76.811594202898561" y="132.58928571428572"/>
</scene>
</scenes>
<resources>
<namedColor name="sparkDarkGray">
<color red="0.45100000500679016" green="0.45100000500679016" blue="0.46299999952316284" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</systemColor>
</resources>
</document>
4 changes: 0 additions & 4 deletions Spark-iOS/Spark-iOS/Source/Classes/CarouselLayout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,3 @@ class CarouselLayout: UICollectionViewFlowLayout {
return CGPoint(x: proposedContentOffset.x + offsetAdjustment, y: proposedContentOffset.y)
}
}

class MyButton: UIButton {
public var statusCV: Int?
}
12 changes: 12 additions & 0 deletions Spark-iOS/Spark-iOS/Source/Classes/StatusButton.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// StatusButton.swift
// Spark-iOS
//
// Created by Junho Lee on 2022/01/18.
//

import UIKit

class StatusButton: UIButton {
public var status: Int = -1
}
29 changes: 29 additions & 0 deletions Spark-iOS/Spark-iOS/Source/NetworkModels/Room/AuthUpload.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// AuthUpload.swift
// Spark-iOS
//
// Created by Junho Lee on 2022/01/18.
//

import Foundation

// MARK: - AuthUpload
struct AuthUpload: Codable {
let userID: Int
let nickname: String
let profileImg: String?
let roomID: Int
let roomName: String
let recordID, day: Int
let certifyingImg: String?
let timerRecord: String?

enum CodingKeys: String, CodingKey {
case userID = "userId"
case nickname, profileImg
case roomID = "roomId"
case roomName
case recordID = "recordId"
case day, certifyingImg, timerRecord
}
}
34 changes: 34 additions & 0 deletions Spark-iOS/Spark-iOS/Source/NetworkServices/Room/RoomAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation

import Moya
import UIKit

public class RoomAPI {

Expand Down Expand Up @@ -147,4 +148,37 @@ public class RoomAPI {
return .networkFail
}
}

func authUpload(roomID: Int, timer: String, image: UIImage, completion: @escaping(NetworkResult<Any>) -> Void) {
roomProvider.request(.authUpload(roomID: roomID, timer: timer, image: image)) { result in
switch result {
case .success(let response):
let statusCode = response.statusCode
let data = response.data
let networkResult = self.judgeAuthUploadStatus(by: statusCode, data)
completion(networkResult)

case .failure(let err):
print(err)
}
}
}

private func judgeAuthUploadStatus(by statusCode: Int, _ data: Data) -> NetworkResult<Any> {
let decoder = JSONDecoder()
guard let decodedData = try?
decoder.decode(GenericResponse<AuthUpload>.self, from: data)
else { return .pathErr }

switch statusCode {
case 200:
return .success(decodedData.data ?? "None-Data")
case 400..<500:
return .requestErr(decodedData.message)
case 500:
return .serverErr
default:
return .networkFail
}
}
}
21 changes: 19 additions & 2 deletions Spark-iOS/Spark-iOS/Source/NetworkServices/Room/RoomService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum RoomService {
case waitingMemberFetch(roomID: Int)
case codeJoinCheckFetch(code: String)
case enterRoom(roomID: Int)
case authUpload(roomID: Int, timer: String, image: UIImage)
}

extension RoomService: TargetType {
Expand All @@ -31,6 +32,8 @@ extension RoomService: TargetType {
return "/room/code/\(code)"
case .enterRoom(let roomID):
return "/room/\(roomID)/enter"
case .authUpload(let roomID, _, _):
return "/room/\(roomID)/record"
}
}

Expand All @@ -44,6 +47,8 @@ extension RoomService: TargetType {
return .get
case .enterRoom:
return .post
case .authUpload:
return .post
}
}

Expand All @@ -56,11 +61,21 @@ extension RoomService: TargetType {
case .waitingMemberFetch:
return .requestPlain
case .enterRoom(let roomID):
return .requestParameters(parameters:["roomId": roomID], encoding: JSONEncoding.default)
return .requestParameters(parameters: ["roomId": roomID], encoding: JSONEncoding.default)
case .authUpload(_, let timer, let image):
var multiPartData: [Moya.MultipartFormData] = []

let timerData = timer.data(using: .utf8) ?? Data()
multiPartData.append(MultipartFormData(provider: .data(timerData), name: "timerRecord"))

let imageData = MultipartFormData(provider: .data(image.jpegData(compressionQuality: 1) ?? Data()), name: "image", fileName: "image", mimeType: "image/jpeg")
multiPartData.append(imageData)

return .uploadMultipart(multiPartData)
}
}

var headers: [String : String]? {
var headers: [String: String]? {
switch self {
case .waitingFetch:
return Const.Header.authrizationHeader
Expand All @@ -70,6 +85,8 @@ extension RoomService: TargetType {
return Const.Header.authrizationHeader
case .waitingMemberFetch:
return Const.Header.authrizationHeader
case .authUpload:
return Const.Header.authrizationHeader
}
}
}
2 changes: 1 addition & 1 deletion Spark-iOS/Spark-iOS/Source/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {

window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
let rootViewController = UIStoryboard(name: Const.Storyboard.Name.splash, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.splash)
let rootViewController = UIStoryboard(name: Const.Storyboard.Name.sendSpark, bundle: nil).instantiateViewController(withIdentifier: Const.ViewController.Identifier.sendSpark)
window?.rootViewController = rootViewController
window?.makeKeyAndVisible()
}
Expand Down
Loading