Skip to content

Commit

Permalink
[Feat] #241 - RandomTopicSwiftUI View 구현 및 데이터 바인딩
Browse files Browse the repository at this point in the history
  • Loading branch information
joonBaek12 committed Dec 11, 2024
1 parent d6b6a33 commit 9ffc1be
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// RandomTopicViewSwiftUI.swift
// Smeem-iOS
//
// Created by Joon Baek on 12/11/24.
//

import SwiftUI

struct RandomTopicViewSwiftUI: View {

// MARK: - Properties

var contentText: String?

// MARK: - Body

var body: some View {
GeometryReader { geometry in
HStack(alignment: .firstTextBaseline, spacing: 3) {
Text("Q.")
.font(Font(UIFont.b1))
.foregroundColor(Color(UIColor.point))
.padding(.leading, 18.scaledByWidth())

Text(contentText ?? "")
.font(Font(UIFont.b4))
.foregroundColor(Color(UIColor.smeemBlack))
.lineLimit(2)
.fixedSize(horizontal: false, vertical: true)
.frame(maxWidth: .infinity, alignment: .leading)
.padding(.trailing, 30.scaledByWidth())
}
.padding(.top, 20.scaledByHeight())
.padding(.bottom, 20.scaledByHeight())
.background(Color(UIColor.gray100))
}
.frame(height: contentText?.count ?? 0 > 20 ? 84.scaledByHeight() : 62.scaledByHeight())
}
}

#Preview {
var text: String = "랜덤주제 한줄일 경우 "
RandomTopicViewSwiftUI(contentText: text)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import SwiftUI
import UIKit

struct DetailDiaryCoachedView: View {

// MARK: - Properties

@StateObject private var navigationViewModel = NavigationViewModel()
@State private var cancelBag = Set<AnyCancellable>()

Expand All @@ -33,8 +36,10 @@ struct DetailDiaryCoachedView: View {

private let detailDiaryService = DetailDiaryService.shared

// MARK: - Body

var body: some View {
VStack(spacing: 16.scaledByWidth()) {
VStack(spacing: 0) {
SwiftUINavigationView(navigationViewModel: navigationViewModel,
selectedIndex: $selectedIndex,
navigationbarType: navigationbarType
Expand Down Expand Up @@ -74,6 +79,12 @@ struct DetailDiaryCoachedView: View {
}
}

if let topic = response?.topic {
if topic != "" {
RandomTopicViewSwiftUI(contentText: response?.topic)
}
}

if let response = response {
ScrollableDiaryView(
diaryText: response.content,
Expand Down Expand Up @@ -102,7 +113,7 @@ struct DetailDiaryCoachedView: View {
corrections: $filteredCorrections
)
} else {
Spacer(minLength: 342.scaledByHeight())
Spacer()
}
}
.onAppear {
Expand Down

0 comments on commit 9ffc1be

Please sign in to comment.