Skip to content

Commit

Permalink
Merge pull request TeamDooRiBon#149 from Hansangjin98/fix/147-errorFix
Browse files Browse the repository at this point in the history
[FIX] TeamDooRiBon#147 - ์„ฑํ–ฅํ…Œ์ŠคํŠธ ๊ด€๋ จ ์ด์Šˆ ํ•ด๊ฒฐ
  • Loading branch information
Hansangjin98 authored Jul 16, 2021
2 parents a981610 + 738f124 commit bc96118
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 47 deletions.
8 changes: 8 additions & 0 deletions DooRiBon/DooRiBon.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
402E5205269DD67500635B41 /* AddTripPlanService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 402E5204269DD67500635B41 /* AddTripPlanService.swift */; };
40320989269F2F76003DCB8A /* StyleResultDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 40320988269F2F76003DCB8A /* StyleResultDataModel.swift */; };
4032098B269F2FB1003DCB8A /* StyleResultService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4032098A269F2FB1003DCB8A /* StyleResultService.swift */; };
4038127126A15E380013B266 /* MainStyleTestDataModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4038127026A15E380013B266 /* MainStyleTestDataModel.swift */; };
4038127326A15E6E0013B266 /* MainStyleTestService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4038127226A15E6E0013B266 /* MainStyleTestService.swift */; };
4057E82E269F0DAA00DE024D /* StyleTestService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4057E82D269F0DAA00DE024D /* StyleTestService.swift */; };
4073BC6526986A9B00C5C7B0 /* MemberOurStoryboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4073BC6426986A9B00C5C7B0 /* MemberOurStoryboard.storyboard */; };
4073BC6726986B9600C5C7B0 /* MemberOurViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4073BC6626986B9600C5C7B0 /* MemberOurViewController.swift */; };
Expand Down Expand Up @@ -228,6 +230,8 @@
402E5204269DD67500635B41 /* AddTripPlanService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddTripPlanService.swift; sourceTree = "<group>"; };
40320988269F2F76003DCB8A /* StyleResultDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleResultDataModel.swift; sourceTree = "<group>"; };
4032098A269F2FB1003DCB8A /* StyleResultService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleResultService.swift; sourceTree = "<group>"; };
4038127026A15E380013B266 /* MainStyleTestDataModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainStyleTestDataModel.swift; sourceTree = "<group>"; };
4038127226A15E6E0013B266 /* MainStyleTestService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainStyleTestService.swift; sourceTree = "<group>"; };
4057E82D269F0DAA00DE024D /* StyleTestService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StyleTestService.swift; sourceTree = "<group>"; };
4073BC6426986A9B00C5C7B0 /* MemberOurStoryboard.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = MemberOurStoryboard.storyboard; sourceTree = "<group>"; };
4073BC6626986B9600C5C7B0 /* MemberOurViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemberOurViewController.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -404,6 +408,7 @@
children = (
39F21BA5269BDB4100673511 /* StyleQuestionDataModel.swift */,
40320988269F2F76003DCB8A /* StyleResultDataModel.swift */,
4038127026A15E380013B266 /* MainStyleTestDataModel.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -591,6 +596,7 @@
children = (
4057E82D269F0DAA00DE024D /* StyleTestService.swift */,
4032098A269F2FB1003DCB8A /* StyleResultService.swift */,
4038127226A15E6E0013B266 /* MainStyleTestService.swift */,
);
path = Service;
sourceTree = "<group>";
Expand Down Expand Up @@ -1290,6 +1296,7 @@
4097AC94269B0F9F00E34CCC /* MemberCodeCopyTableViewCell.swift in Sources */,
40B5A092268EE35100A89875 /* AddTripViewController.swift in Sources */,
BD6074DB269F2C4100CA62F3 /* BottomSheetView.swift in Sources */,
4038127126A15E380013B266 /* MainStyleTestDataModel.swift in Sources */,
BDCC367F2695DEAA009AE274 /* NoDataTableViewCell.swift in Sources */,
BD75C2C8268B4B3800C4F233 /* AppDelegate.swift in Sources */,
BD6074D4269ED7B900CA62F3 /* TripPlanDataService.swift in Sources */,
Expand Down Expand Up @@ -1329,6 +1336,7 @@
40253C90269DB7250045620F /* UIImage+Extension.swift in Sources */,
BD75C2F8268B58B500C4F233 /* ProtocolEmpty.swift in Sources */,
40320989269F2F76003DCB8A /* StyleResultDataModel.swift in Sources */,
4038127326A15E6E0013B266 /* MainStyleTestService.swift in Sources */,
40EBD324269F5D9600DFC057 /* TripInfoDataModel.swift in Sources */,
BDCC367C2695DA66009AE274 /* PlanDataModel.swift in Sources */,
39E35957269EFF290077B946 /* MemberProfileDataModel.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.212",
"green" : "0.196",
"red" : "0.180"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
1 change: 1 addition & 0 deletions DooRiBon/DooRiBon/Resources/Constants/ColorConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal enum Colors {
internal static let subOrangeLight = ColorAsset(name: "subOrangeLight")
internal static let white8 = ColorAsset(name: "white8")
internal static let white9 = ColorAsset(name: "white9")
internal static let gray_black2 = ColorAsset(name: "gray/black2")
}
// swiftlint:enable identifier_name line_length nesting type_body_length type_name

Expand Down
1 change: 1 addition & 0 deletions DooRiBon/DooRiBon/Resources/Network/APIConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct APIConstants {
static let styleURL = baseURL + "/tendency"
static let styleQuestionURL = baseURL + "/tendency/question"
static let styleResultSaveURL = baseURL + "/tendency/:groupId"
static let styleTestMainURL = baseURL + "/tendency/result/main"

// MARK: - /image

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ extension MemberOurViewController: UITableViewDelegate, UITableViewDataSource {
nextVC.imgURL = myStyleData?.iOSResultImage ?? ""
nextVC.style = myStyleData?.title ?? ""
nextVC.hidesBottomBarWhenPushed = true
nextVC.popCount = 2
self.navigationController?.pushViewController(nextVC, animated: true)
}
} else {
Expand All @@ -191,7 +190,6 @@ extension MemberOurViewController: UITableViewDelegate, UITableViewDataSource {
nextVC.imgURL = memberStyleData[indexPath.row].iOSResultImage
nextVC.style = memberStyleData[indexPath.row].title
nextVC.hidesBottomBarWhenPushed = true
nextVC.popCount = 2
self.navigationController?.pushViewController(nextVC, animated: true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<rect key="frame" x="117" y="543" width="141" height="24"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="์ด๋ฏธ์ง€ ๊ฒฐ๊ณผ ์ €์žฅํ•˜๊ธฐ" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jme-JE-rJW">
<rect key="frame" x="0.0" y="4.5" width="105" height="15.5"/>
<rect key="frame" x="0.0" y="5" width="100.5" height="14"/>
<fontDescription key="fontDescription" name="SpoqaHanSansNeo-Medium" family="Spoqa Han Sans Neo" pointSize="12"/>
<color key="textColor" name="gray5"/>
<nil key="highlightedColor"/>
Expand Down Expand Up @@ -80,13 +80,13 @@
<rect key="frame" x="0.0" y="0.0" width="375" height="493"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aad-lh-i4u">
<rect key="frame" x="18" y="81" width="43.5" height="20.5"/>
<rect key="frame" x="18" y="81" width="39.5" height="19"/>
<fontDescription key="fontDescription" name="SpoqaHanSansNeo-Bold" family="Spoqa Han Sans Neo" pointSize="16"/>
<color key="textColor" name="white9"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wYJ-bt-rXC">
<rect key="frame" x="18" y="106.5" width="89.5" height="41.5"/>
<rect key="frame" x="18" y="105" width="81" height="38.5"/>
<constraints>
<constraint firstAttribute="height" constant="82" id="4zF-W7-Q1m"/>
<constraint firstAttribute="width" constant="126" id="JL7-dB-XNG"/>
Expand Down Expand Up @@ -126,7 +126,7 @@
</constraints>
</scrollView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="WUt-pM-i5b">
<rect key="frame" x="107" y="625" width="161" height="42"/>
<rect key="frame" x="107" y="620" width="161" height="42"/>
<color key="backgroundColor" name="white9"/>
<constraints>
<constraint firstAttribute="height" constant="42" id="2Bm-TH-X7g"/>
Expand Down Expand Up @@ -155,18 +155,28 @@
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="x3Z-1m-Gzx" secondAttribute="trailing" id="TsN-Yw-Nwt"/>
<constraint firstItem="x3Z-1m-Gzx" firstAttribute="top" secondItem="5EZ-qb-Rvc" secondAttribute="top" id="XE0-eV-xnK"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="bottom" secondItem="WUt-pM-i5b" secondAttribute="bottom" id="hi2-fD-MK1"/>
<constraint firstAttribute="bottom" secondItem="WUt-pM-i5b" secondAttribute="bottom" constant="5" id="j7r-BZ-mf8"/>
<constraint firstAttribute="bottom" secondItem="x3Z-1m-Gzx" secondAttribute="bottom" id="tvY-vx-hZx"/>
<constraint firstItem="vDu-zF-Fre" firstAttribute="trailing" secondItem="WUt-pM-i5b" secondAttribute="trailing" constant="107" id="xOM-v4-lJX"/>
<constraint firstItem="WUt-pM-i5b" firstAttribute="bottom" secondItem="vDu-zF-Fre" secondAttribute="bottom" constant="40" id="xdW-dW-204"/>
</constraints>
<variation key="default">
<mask key="constraints">
<exclude reference="hi2-fD-MK1"/>
<exclude reference="xdW-dW-204"/>
</mask>
</variation>
</view>
<connections>
<outlet property="backButton" destination="WUt-pM-i5b" id="idS-eQ-T7p"/>
<outlet property="nameLabel" destination="aad-lh-i4u" id="ayp-bC-4Lc"/>
<outlet property="resultImageView" destination="bit-KI-1mH" id="Kiu-JE-hku"/>
<outlet property="styleLabel" destination="wYJ-bt-rXC" id="CU5-HL-KbF"/>
<segue destination="yh2-HZ-Vzh" kind="unwind" identifier="unwindVC1" unwindAction="unwindVC1WithSegue:" id="PQc-h2-2Kk"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="Ief-a0-LHa" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
<exit id="yh2-HZ-Vzh" userLabel="Exit" sceneMemberID="exit"/>
</objects>
<point key="canvasLocation" x="-36" y="64.31784107946028"/>
</scene>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class StyleTestResultViewController: UIViewController {
var name: String = ""
var imgURL: String = ""
var style: String = ""
var popCount: Int = 3
var buttonText: String = "์—ฌํ–‰ ๊ทธ๋ฃน์œผ๋กœ ์ด๋™"
var mainOrMember = false

//MARK:- Life Cycle

Expand All @@ -38,7 +39,7 @@ class StyleTestResultViewController: UIViewController {
nameLabel.text = "\(name)๋‹˜์€"
let title = style.replacingOccurrences(of: " ", with: "\n")
styleLabel.text = title
print(title)
backButton.setTitle(buttonText, for: .normal)
}

func imageSet() {
Expand All @@ -55,21 +56,23 @@ class StyleTestResultViewController: UIViewController {
}

func shadowSet() {
backButton.layer.applyShadow(color: Colors.black2.color, alpha: 0.08, x: 0, y: 1, blur: 10, spread: 2)
backButton.layer.applyShadow(color: Colors.gray_black2.color, alpha: 0.08, x: 0, y: 1, blur: 10, spread: 2)
}

func backTwoWhenNavigationControllerUsed(){
let viewControllers : [UIViewController] = self.navigationController!.viewControllers as [UIViewController]
self.navigationController?.popToViewController(viewControllers[viewControllers.count - popCount ], animated: true)
self.navigationController?.popToViewController(viewControllers[viewControllers.count - 3 ], animated: true)


}

//MARK:- IBAction

@IBAction func backButtonClicked(_ sender: Any) {
backTwoWhenNavigationControllerUsed()
if mainOrMember {
performSegue(withIdentifier: "unwindVC1", sender: self)
} else {
backTwoWhenNavigationControllerUsed()
}
}


}
2 changes: 1 addition & 1 deletion DooRiBon/DooRiBon/Sources/Main/MainStoryboard.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
<connections>
<action selector="goStyleTestButtonClicked:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="Fgi-AF-E1n"/>
<action selector="goStyleTestButtonClicked:" destination="Y6W-OH-hqX" eventType="touchUpInside" id="8ou-ig-KbC"/>
</connections>
</button>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="์—ฌํ–‰๋งˆ๋‹ค ๋‹ค๋ฅธ ๋‚ด ์„ฑํ–ฅ,โ€จ์ด๋ฒˆ์—๋Š” ์–ด๋–ค ์—ฌํ–‰ ํ•˜๊ณ  ์‹ถ์œผ์„ธ์š”?" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6Ro-LA-BFJ">
Expand Down
3 changes: 3 additions & 0 deletions DooRiBon/DooRiBon/Sources/Main/MainViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ class MainViewController: UIViewController {

// MARK: - ์•ก์…˜

@IBAction func unwindVC1 (segue : UIStoryboardSegue) {}

@IBAction func nowTripClicked(_ sender: Any) {
let tripStortboard = UIStoryboard(name: "TripStoryboard", bundle: nil)
if let tripVC = tripStortboard.instantiateViewController(identifier: "TripViewController") as? TripViewController {
Expand All @@ -104,6 +106,7 @@ class MainViewController: UIViewController {
let testStortboard = UIStoryboard(name: "StyleQuestionStoryboard", bundle: nil)
if let testVC = testStortboard.instantiateViewController(identifier: "StyleQuestionViewController") as? StyleQuestionViewController {
testVC.modalPresentationStyle = .overFullScreen
testVC.disMissCheck = true
self.present(testVC, animated: true, completion: nil)
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//
// MainStyleTestDataModel.swift
// DooRiBon
//
// Created by ํ•œ์ƒ์ง„ on 2021/07/16.
//

import Foundation

struct MainStyleTestResponse: Codable {
let status: Int
let success: Bool
let message: String
let data: MainStyleTestData?
}

// MARK: - DataClass
struct MainStyleTestData: Codable {
let member, title: String
let tag: [String]
let iOSResultImage, aOSResultImage, thumbnail: String
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct StyleQuestionResponse: Codable {
let status: Int
let success: Bool
let message: String
let data: [StyleQuestionData]
let data: [StyleQuestionData]?
}

// MARK: - Datum
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct StyleResultResponse: Codable {
let status: Int
let success: Bool
let message: String
let data: StyleResultData
let data: StyleResultData?
}

// MARK: - DataClass
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// MainStyleTestService.swift
// DooRiBon
//
// Created by ํ•œ์ƒ์ง„ on 2021/07/16.
//

import Foundation
import Alamofire

struct MainStyleTestService{
static let shared = MainStyleTestService()

private func makeParameter(score: [Int]) -> Parameters
{
return ["score" : score]
}

func getData(score : [Int], completion : @escaping (NetworkResult<Any>) -> Void)
{
let url: String = APIConstants.styleTestMainURL
let header : HTTPHeaders = NetworkInfo.headerWithToken
let dataRequest = AF.request(url,
method: .post,
parameters: makeParameter(score: score),
encoding: JSONEncoding.default,
headers: header)
dataRequest.responseData { dataResponse in

dump(dataResponse)

switch dataResponse.result {
case .success:
guard let statusCode = dataResponse.response?.statusCode else {return}
guard let value = dataResponse.value else {return}
let networkResult = self.judgeStatus(by: statusCode, value)
completion(networkResult)
case .failure: completion(.pathErr)

}
}

}

private func judgeStatus(by statusCode: Int, _ data: Data) -> NetworkResult<Any> {

let decoder = JSONDecoder()
guard let decodedData = try? decoder.decode(MainStyleTestResponse.self, from: data)
else { return .pathErr}
switch statusCode {

case 200: return .success(decodedData)
case 400: return .requestErr(decodedData)
case 500: return .serverErr
default: return .networkFail
}
}
}
Loading

0 comments on commit bc96118

Please sign in to comment.