-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat] #220 - 코칭뷰 구현
- Loading branch information
Showing
36 changed files
with
1,260 additions
and
126 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// MoyaProvier+.swift | ||
// Smeem-iOS | ||
// | ||
// Created by 황찬미 on 11/17/24. | ||
// | ||
|
||
import Foundation | ||
import Moya | ||
|
||
class ServiceNetwork { | ||
|
||
static let shared = ServiceNetwork() | ||
|
||
private init() {} | ||
|
||
func request<T: Decodable, Target: TargetType>(_ target: Target) async throws -> T { | ||
let provider = MoyaProvider<Target>(plugins: [MoyaLoggingPlugin()]) | ||
|
||
return try await withCheckedThrowingContinuation { continuation in | ||
provider.request(target) { result in | ||
switch result { | ||
case .success(let response): | ||
do { | ||
try NetworkManager.statusCodeErrorHandling(statusCode: response.statusCode) | ||
if let data = try response.map(GeneralResponse<T>.self).data { | ||
continuation.resume(returning: data) | ||
} else { | ||
continuation.resume(throwing: SmeemError.clientError) | ||
} | ||
} catch { | ||
continuation.resume(throwing: SmeemError.clientError) | ||
} | ||
case .failure(let error): | ||
continuation.resume(throwing: error) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
extension MoyaProvider { | ||
func request<T: Decodable>(_ target: Target) async throws -> T { | ||
try await withCheckedThrowingContinuation { continuation in | ||
self.request(target) { result in | ||
switch result { | ||
case .success(let response): | ||
do { | ||
try NetworkManager.statusCodeErrorHandling(statusCode: response.statusCode) | ||
if let data = try response.map(GeneralResponse<T>.self).data { | ||
continuation.resume(returning: data) | ||
} else { | ||
continuation.resume(throwing: SmeemError.clientError) | ||
} | ||
} catch { | ||
continuation.resume(throwing: SmeemError.clientError) | ||
} | ||
case .failure(let error): | ||
continuation.resume(throwing: error) | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// View+.swift | ||
// Smeem-iOS | ||
// | ||
// Created by Joon Baek on 2024/10/16. | ||
// | ||
|
||
import SwiftUI | ||
|
||
extension View { | ||
var screenSize: CGRect { | ||
return UIScreen.main.bounds | ||
} | ||
|
||
var screenHeight: Double { | ||
return screenSize.height | ||
} | ||
|
||
var screenWidth: Double { | ||
return screenSize.width | ||
} | ||
|
||
func changeRootViewController(_ viewController: UIViewController) { | ||
guard let window = UIApplication.shared.windows.first else { return } | ||
UIView.transition(with: window, duration: 0.5, options: .transitionCrossDissolve, animations: { | ||
let rootVC = UINavigationController(rootViewController: viewController) | ||
window.rootViewController = rootVC | ||
}) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
Smeem-iOS/Smeem-iOS/Global/Resources/Assets.xcassets/icnCrownMono.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "icon-crown-mono.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+390 Bytes
...-iOS/Global/Resources/Assets.xcassets/icnCrownMono.imageset/icon-crown-mono.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+624 Bytes
...S/Global/Resources/Assets.xcassets/icnCrownMono.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+915 Bytes
...S/Global/Resources/Assets.xcassets/icnCrownMono.imageset/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
72 changes: 72 additions & 0 deletions
72
Smeem-iOS/Smeem-iOS/Global/UIComponents/CoachingComparisonView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// | ||
// CoachingComparisonView.swift | ||
// Smeem-iOS | ||
// | ||
// Created by 황찬미 on 11/1/24. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CoachingComparisonView: View { | ||
@Binding var coachingResponse: CoachingResponse | ||
@State private var textHeight: CGFloat = 0 // Text의 높이를 저장할 변수 | ||
|
||
var body: some View { | ||
VStack(spacing: 20) { | ||
VStack(alignment: .leading, spacing: 8) { | ||
HStack { | ||
Rectangle() | ||
.frame(width: 2, height: textHeight) | ||
.foregroundStyle(Color(UIColor.black)) | ||
|
||
Text("나의 일기") | ||
.font(Font.custom("Pretendard", size: 16).weight(.medium)) | ||
.foregroundColor(Color(UIColor.black)) | ||
.background(GeometryReader { geometry in | ||
Color.clear | ||
.preference(key: TextHeightPreferenceKey.self, value: geometry.size.height) | ||
}) | ||
} | ||
.onPreferenceChange(TextHeightPreferenceKey.self) { value in | ||
textHeight = value | ||
} | ||
|
||
Text(coachingResponse.original_sentence) | ||
.font(Font.custom("Pretendard", size: 14)).fontWeight(.regular) | ||
.frame(maxWidth: .infinity, alignment: .topLeading) | ||
} | ||
.padding(.leading, 18) | ||
.padding(.trailing, 18) | ||
|
||
VStack(alignment: .leading, spacing: 8) { | ||
HStack { | ||
Rectangle() | ||
.frame(width: 2, height: textHeight) | ||
.foregroundStyle(Color(UIColor.point)) | ||
|
||
Text("고친 문장") | ||
.font(Font.custom("Pretendard", size: 16).weight(.medium)) | ||
.foregroundColor(Color(UIColor.point)) | ||
} | ||
|
||
Text(coachingResponse.corrected_sentence) | ||
.font(Font.custom("Pretendard", size: 14)).fontWeight(.medium) | ||
.foregroundColor(Color(UIColor.point)) | ||
.frame(maxWidth: .infinity, alignment: .topLeading) | ||
} | ||
.padding(.leading, 18) | ||
.padding(.trailing, 18) | ||
} | ||
} | ||
} | ||
|
||
struct TextHeightPreferenceKey: PreferenceKey { | ||
static var defaultValue: CGFloat = 0 | ||
static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) { | ||
value = nextValue() | ||
} | ||
} | ||
|
||
//#Preview { | ||
// CoachingComparisonView() | ||
//} |
Oops, something went wrong.