Skip to content

Commit

Permalink
Merge pull request #221 from Team-Smeme/feat/#220-TextView
Browse files Browse the repository at this point in the history
[Feat] #220 - 코칭뷰 구현
  • Loading branch information
cchanmi authored Nov 19, 2024
2 parents baa96f7 + 1992edd commit 5319573
Show file tree
Hide file tree
Showing 36 changed files with 1,260 additions and 126 deletions.
106 changes: 97 additions & 9 deletions Smeem-iOS/Smeem-iOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"originHash" : "99709ba202d733413a5b5e700df68598b8adb35c0caba72b75c444e7c75164a5",
"pins" : [
{
"identity" : "abseil-cpp-binary",
Expand Down Expand Up @@ -45,6 +46,15 @@
"version" : "10.19.2"
}
},
{
"identity" : "combine-schedulers",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/combine-schedulers",
"state" : {
"revision" : "9fa31f4403da54855f1e2aeaeff478f4f0e40b13",
"version" : "1.0.2"
}
},
{
"identity" : "firebase-ios-sdk",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -144,6 +154,24 @@
"version" : "1.22.5"
}
},
{
"identity" : "lottie-spm",
"kind" : "remoteSourceControl",
"location" : "https://github.com/airbnb/lottie-spm.git",
"state" : {
"revision" : "b842598f1295f3ffa1475b1580672d1fe5b83580",
"version" : "4.5.0"
}
},
{
"identity" : "lottieui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/tfmart/LottieUI",
"state" : {
"revision" : "dd5b2f16213f89ab996a55fc2f51b56236da4bbe",
"version" : "1.3.3"
}
},
{
"identity" : "moya",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -198,6 +226,96 @@
"revision" : "58320fe80522414bf3a7e24c88123581dc586752"
}
},
{
"identity" : "swift-case-paths",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "bc92c4b27f9a84bfb498cdbfdf35d5a357e9161f",
"version" : "1.5.6"
}
},
{
"identity" : "swift-clocks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-clocks",
"state" : {
"revision" : "b9b24b69e2adda099a1fa381cda1eeec272d5b53",
"version" : "1.0.5"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections",
"state" : {
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
"version" : "1.1.4"
}
},
{
"identity" : "swift-composable-architecture",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-composable-architecture",
"state" : {
"revision" : "69247baf7be2fd6f5820192caef0082d01849cd0",
"version" : "1.16.1"
}
},
{
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "163409ef7dae9d960b87f34b51587b6609a76c1f",
"version" : "1.3.0"
}
},
{
"identity" : "swift-custom-dump",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-custom-dump",
"state" : {
"revision" : "82645ec760917961cfa08c9c0c7104a57a0fa4b1",
"version" : "1.3.3"
}
},
{
"identity" : "swift-dependencies",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-dependencies",
"state" : {
"revision" : "96eecd47660e8307877acb8c41cc5295ba7350a7",
"version" : "1.5.2"
}
},
{
"identity" : "swift-identified-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-identified-collections",
"state" : {
"revision" : "2f5ab6e091dd032b63dacbda052405756010dc3b",
"version" : "1.1.0"
}
},
{
"identity" : "swift-navigation",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-navigation",
"state" : {
"revision" : "16a27ab7ae0abfefbbcba73581b3e2380b47a579",
"version" : "2.2.2"
}
},
{
"identity" : "swift-perception",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-perception",
"state" : {
"revision" : "dccdf5aed1db969afa11d6fbd36b96a4932ebe8c",
"version" : "1.4.0"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
Expand All @@ -206,7 +324,25 @@
"revision" : "d57a5aecf24a25b32ec4a74be2f5d0a995a47c4b",
"version" : "1.27.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swiftlang/swift-syntax",
"state" : {
"revision" : "0687f71944021d616d34d922343dcef086855920",
"version" : "600.0.1"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "770f990d3e4eececb57ac04a6076e22f8c97daeb",
"version" : "1.4.2"
}
}
],
"version" : 2
"version" : 3
}
2 changes: 2 additions & 0 deletions Smeem-iOS/Smeem-iOS/Global/Constants/Constant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,7 @@ extension Constant {
static let icnToolTip = UIImage(named: "icnToolTip")

static let splashImage = UIImage(named: "splash")

static let icnCrownMono = UIImage(named: "icnCrownMono")
}
}
64 changes: 64 additions & 0 deletions Smeem-iOS/Smeem-iOS/Global/Extensions/MoyaProvier+.swift
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)
}
}
}
}
}
30 changes: 30 additions & 0 deletions Smeem-iOS/Smeem-iOS/Global/Extensions/SwiftUI/View+.swift
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
})
}
}
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
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Smeem-iOS/Smeem-iOS/Global/Resources/smeemLoading.json

Large diffs are not rendered by default.

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()
//}
Loading

0 comments on commit 5319573

Please sign in to comment.