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

merge :: NoticeDetail UI #118

Merged
merged 10 commits into from
Nov 9, 2022
3 changes: 3 additions & 0 deletions Projects/App/Sources/Application/DI/AppComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,7 @@ public extension AppComponent {
var myPageComponent: MyPageComponent {
MyPageComponent(parent: self)
}
var noticeDetailComponent: NoticeDetailComponent {
NoticeDetailComponent(parent: self)
}
}
24 changes: 24 additions & 0 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ private class NoticeListDependency0e93eb53be8626c408e4Provider: NoticeListDepend
var fetchNoticeListUseCase: any FetchNoticeListUseCase {
return appComponent.fetchNoticeListUseCase
}
var noticeDetailComponent: NoticeDetailComponent {
return appComponent.noticeDetailComponent
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
Expand All @@ -318,6 +321,19 @@ private class NoticeListDependency0e93eb53be8626c408e4Provider: NoticeListDepend
private func factorye14e687c08985bdffcd0f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return NoticeListDependency0e93eb53be8626c408e4Provider(appComponent: parent1(component) as! AppComponent)
}
private class NoticeDetailDependency714af3aed40eaebda420Provider: NoticeDetailDependency {
var fetchDetailNoticeUseCase: any FetchDetailNoticeUseCase {
return appComponent.fetchDetailNoticeUseCase
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->NoticeDetailComponent
private func factory3db143c2f80d621d5a7ff47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return NoticeDetailDependency714af3aed40eaebda420Provider(appComponent: parent1(component) as! AppComponent)
}
private class FindIDDependencyb481fe947a844cc29913Provider: FindIDDependency {
var findIDUseCase: any FindIDUseCase {
return appComponent.findIDUseCase
Expand Down Expand Up @@ -366,6 +382,7 @@ extension AppComponent: Registration {
localTable["applyComponent-ApplyComponent"] = { self.applyComponent as Any }
localTable["noticeListComponent-NoticeListComponent"] = { self.noticeListComponent as Any }
localTable["myPageComponent-MyPageComponent"] = { self.myPageComponent as Any }
localTable["noticeDetailComponent-NoticeDetailComponent"] = { self.noticeDetailComponent as Any }
localTable["remoteNoticeDataSource-any RemoteNoticeDataSource"] = { self.remoteNoticeDataSource as Any }
localTable["noticeRepository-any NoticeRepository"] = { self.noticeRepository as Any }
localTable["fetchWhetherNewNoticeUseCase-any FetchWhetherNewNoticeUseCase"] = { self.fetchWhetherNewNoticeUseCase as Any }
Expand Down Expand Up @@ -501,6 +518,12 @@ extension EnterInformationComponent: Registration {
extension NoticeListComponent: Registration {
public func registerItems() {
keyPathToName[\NoticeListDependency.fetchNoticeListUseCase] = "fetchNoticeListUseCase-any FetchNoticeListUseCase"
keyPathToName[\NoticeListDependency.noticeDetailComponent] = "noticeDetailComponent-NoticeDetailComponent"
}
}
extension NoticeDetailComponent: Registration {
public func registerItems() {
keyPathToName[\NoticeDetailDependency.fetchDetailNoticeUseCase] = "fetchDetailNoticeUseCase-any FetchDetailNoticeUseCase"
}
}
extension FindIDComponent: Registration {
Expand Down Expand Up @@ -544,6 +567,7 @@ private func register1() {
registerProviderFactory("^->AppComponent->ChangePasswordComponent", factoryab7c4d87dab53e0a51b9f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->EnterInformationComponent", factory359a960501e79e833f64f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->NoticeListComponent", factorye14e687c08985bdffcd0f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->NoticeDetailComponent", factory3db143c2f80d621d5a7ff47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->FindIDComponent", factory8dd2f9e0b545ead35ecaf47b58f8f304c97af4d5)
}
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import DomainModule
import NeedleFoundation
import SwiftUI

public protocol NoticeDetailDependency: Dependency {
var fetchDetailNoticeUseCase: any FetchDetailNoticeUseCase { get }
}

public final class NoticeDetailComponent: Component<NoticeDetailDependency> {
public func makeView(id: String) -> some View {
NoticeDetailView(
viewModel: .init(
fetchDetailNoticeUseCase: self.dependency.fetchDetailNoticeUseCase,
id: id
)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import DesignSystem
import SwiftUI
import Utility

struct NoticeDetailView: View {
@StateObject var viewModel: NoticeDetailViewModel
@Environment(\.dismiss) var dismiss

var body: some View {
VStack {
VStack(alignment: .leading, spacing: 24) {
Text(viewModel.title)
.dmsFont(.title(.small), color: .GrayScale.gray7)
.padding(.top, 40)

Divider()
}
VStack(alignment: .leading, spacing: 24) {
Text(viewModel.content)
.padding(.top, 24)
.padding(.bottom, 40)

HStack {
Spacer()

Text(viewModel.date.toDMSDateString())
.dmsFont(.text(.extraSmall), color: .GrayScale.gray5)
.frame(alignment: .trailing)
}
}

Spacer()
}
.navigationTitle("공지")
.navigationBarTitleDisplayMode(.inline)
.padding(.horizontal, 24)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import BaseFeature
import UIKit
import Combine
import DomainModule

final class NoticeDetailViewModel: BaseViewModel {
@Published var title = ""
@Published var content = ""
@Published var date = Date()

let id: String

private let fetchDetailNoticeUseCase: any FetchDetailNoticeUseCase

init(
fetchDetailNoticeUseCase: any FetchDetailNoticeUseCase,
id: String
) {
self.fetchDetailNoticeUseCase = fetchDetailNoticeUseCase
self.id = id
super.init()

addCancellable(
fetchDetailNoticeUseCase.execute(id: id)
) { [weak self] noticeDetail in
self?.title = noticeDetail.title
self?.content = noticeDetail.content
self?.date = noticeDetail.createdAt
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import SwiftUI

public protocol NoticeListDependency: Dependency {
var fetchNoticeListUseCase: any FetchNoticeListUseCase { get }
var noticeDetailComponent: NoticeDetailComponent { get }
}

public final class NoticeListComponent: Component<NoticeListDependency> {
public func makeView() -> some View {
NoticeListView(
viewModel: .init(
fetchNoticeListUseCase: dependency.fetchNoticeListUseCase
)
),
noticeDetailComponent: dependency.noticeDetailComponent
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ import SwiftUI

struct NoticeListView: View {
@StateObject var viewModel: NoticeListViewModel
private let noticeDetailComponent: NoticeDetailComponent

init(
viewModel: NoticeListViewModel
viewModel: NoticeListViewModel,
noticeDetailComponent: NoticeDetailComponent
) {
_viewModel = StateObject(wrappedValue: viewModel)
self.noticeDetailComponent = noticeDetailComponent
}

var body: some View {
Expand All @@ -30,13 +33,14 @@ struct NoticeListView: View {
.frame(height: 10)

ForEach(viewModel.noticeList, id: \.self) { noticeList in
noticeListCellView(
title: noticeList.title,
content: noticeList.createdAt.toSmallDMSDateString()
)
.padding(.top, 5)
.listRowInsets(EdgeInsets())

NavigationLink(destination: noticeDetailComponent.makeView(id: noticeList.id)) {
noticeListCellView(
title: noticeList.title,
content: noticeList.createdAt.toSmallDMSDateString()
)
.padding(.top, 5)
.listRowInsets(EdgeInsets())
}
}
}
.padding(.horizontal, 24)
Expand All @@ -45,6 +49,7 @@ struct NoticeListView: View {
}
.navigationTitle("공지")
.navigationBarTitleDisplayMode(.inline)
.dmsBackground()
}
}

Expand Down