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 :: 디자인 시스템 탭바 변경사항 반영 #139

Merged
merged 3 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ private class MyPageDependency48d84b530313b3ee40feProvider: MyPageDependency {
var changeProfileComponent: ChangeProfileComponent {
return appComponent.changeProfileComponent
}
var rewardPointDetailComponent: RewardPointDetailComponent {
return appComponent.rewardPointDetailComponent
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
Expand Down Expand Up @@ -517,6 +520,7 @@ extension MyPageComponent: Registration {
public func registerItems() {
keyPathToName[\MyPageDependency.fetchMyProfileUseCase] = "fetchMyProfileUseCase-any FetchMyProfileUseCase"
keyPathToName[\MyPageDependency.changeProfileComponent] = "changeProfileComponent-ChangeProfileComponent"
keyPathToName[\MyPageDependency.rewardPointDetailComponent] = "rewardPointDetailComponent-RewardPointDetailComponent"
}
}
extension RewardPointDetailComponent: Registration {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ struct MainTabView: View {
Spacer()
}
}

}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import NeedleFoundation
public protocol MyPageDependency: Dependency {
var fetchMyProfileUseCase: any FetchMyProfileUseCase { get }
var changeProfileComponent: ChangeProfileComponent { get }
var rewardPointDetailComponent: RewardPointDetailComponent { get }
}

public final class MyPageComponent: Component<MyPageDependency> {
Expand All @@ -14,7 +15,8 @@ public final class MyPageComponent: Component<MyPageDependency> {
viewModel: .init(
fetchMyProfileUseCase: self.dependency.fetchMyProfileUseCase
),
changeProfileComponent: self.dependency.changeProfileComponent
changeProfileComponent: self.dependency.changeProfileComponent,
rewardPointDetailComponent: self.dependency.rewardPointDetailComponent
)
}
}
Expand Down
41 changes: 24 additions & 17 deletions Projects/Features/MyPageFeature/Sources/MyPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ struct MyPageView: View {
@StateObject var viewModel: MyPageViewModel

private let changeProfileComponent: ChangeProfileComponent
private let rewardPointDetailComponent: RewardPointDetailComponent

init(
viewModel: MyPageViewModel,
changeProfileComponent: ChangeProfileComponent
changeProfileComponent: ChangeProfileComponent,
rewardPointDetailComponent: RewardPointDetailComponent
) {
_viewModel = StateObject(wrappedValue: viewModel)
self.changeProfileComponent = changeProfileComponent
self.rewardPointDetailComponent = rewardPointDetailComponent
}

var body: some View {
Expand Down Expand Up @@ -73,9 +76,15 @@ struct MyPageView: View {
}

VStack(alignment: .leading, spacing: 0) {
myPageOptionRowCardView(title: "상벌점 내역 확인")
.dmsFont(.body(.body2), color: .GrayScale.gray6)
.cornerRadius(10, corners: [.topLeft, .topRight])
NavigationLink {
DeferView {
rewardPointDetailComponent.makeView()
}
} label: {
myPageOptionRowCardView(title: "상벌점 내역 확인")
.dmsFont(.body(.body2), color: .GrayScale.gray6)
.cornerRadius(10, corners: [.topLeft, .topRight])
}

Divider()
.padding(.horizontal, 10)
Expand All @@ -91,7 +100,7 @@ struct MyPageView: View {
}

VStack(alignment: .leading, spacing: 0) {
myPageOptionRowCardView(title: "로그아웃", action: viewModel.logoutButtonDidTap)
myPageOptionRowCardView(title: "로그아웃")
.dmsFont(.body(.body2), color: .System.error)
.onTapGesture(perform: viewModel.logoutButtonDidTap)
.cornerRadius(10)
Expand Down Expand Up @@ -125,19 +134,17 @@ struct MyPageView: View {
}

@ViewBuilder
func myPageOptionRowCardView(title: String, action: @escaping () -> Void = {}) -> some View {
Button(action: action) {
HStack {
Text(title)
func myPageOptionRowCardView(title: String) -> some View {
HStack {
Text(title)

Spacer()
}
.padding(.vertical, 15)
.padding(.horizontal, 20)
.background {
Color.GrayScale.gray1
.dmsShadow()
}
Spacer()
}
.padding(.vertical, 15)
.padding(.horizontal, 20)
.background {
Color.GrayScale.gray1
.dmsShadow()
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import DesignSystem
import DataMappingModule
import SwiftUI
import DomainModule

struct RewardPointDetailView: View {
@StateObject var viewModel: RewardPointDetailViewModel
@Environment(\.dismiss) var dismiss

init(
viewModel: RewardPointDetailViewModel
Expand All @@ -12,69 +14,65 @@ struct RewardPointDetailView: View {
}

var body: some View {
NavigationView {
VStack(alignment: .leading) {
HStack {
ForEach(PointsType.allCases, id: \.self) { point in
DMSButton(
text: point.display,
style: viewModel.pointsType == point ? .contained : .outlined,
color: viewModel.pointsType == point ? .PrimaryVariant.primary : .GrayScale.gray6
) {
viewModel.pointsType = point
viewModel.fetchPointList()
VStack(alignment: .leading) {
HStack {
ForEach(PointsType.allCases, id: \.self) { type in
DMSButton(
text: type.display,
style: viewModel.pointsType == type ? .contained : .outlined,
color: viewModel.pointsType == type ? .PrimaryVariant.primary : .GrayScale.gray6
) {
withAnimation {
viewModel.pointsTypeChanged(type: type)
}
.padding(.trailing, 12)
}
.padding(.trailing, 12)
}
.padding(.leading, 24)
.padding(.top, 16)
}
.padding(.leading, 24)
.padding(.top, 16)

Text("\(viewModel.point?.totalPoint ?? 0)" + " 점")
.dmsFont(.headline(.headline2), color: .GrayScale.gray6)
.padding(.top, 44)
.padding(.horizontal, 24)
.padding(.bottom, 44)
ScrollView {
VStack {
ForEach(viewModel.point?.poinsts ?? [], id: \.self) { pointList in
pointsListCellView(
date: pointList.date.toSmallDMSDateString(),
name: pointList.name,
score: "\(pointList.score)"
)
Text("\(viewModel.point?.totalPoint ?? 0)" + " 점")
.dmsFont(.headline(.headline2), color: .GrayScale.gray6)
.padding(.top, 44)
.padding(.horizontal, 24)
.padding(.bottom, 44)

ScrollView {
VStack {
ForEach(viewModel.point?.poinsts ?? [], id: \.self) { point in
pointsListCellView(point: point)
.padding(.top, 5)
.listRowInsets(EdgeInsets())
}
}
.padding(.horizontal, 24)
}
.navigationTitle("상벌점 현황")
.navigationBarTitleDisplayMode(.inline)
.dmsBackground()
.padding(.horizontal, 24)
}
}
.dmsBackButton(dismiss: dismiss)
.navigationTitle("상벌점 현황")
.navigationBarTitleDisplayMode(.inline)
.dmsBackground()
}

@ViewBuilder
func pointsListCellView(date: String, name: String, score: String) -> some View {
func pointsListCellView(point: PointEntity.SinglePoint) -> some View {
ZStack {
Color.System.surface
.cornerRadius(6)

HStack {
VStack(alignment: .leading, spacing: 8) {
Text(date)
.dmsFont(.etc(.caption), color: .System.title)
Text("\(point.date.month)월 \(point.date.day)일")
.dmsFont(.etc(.caption), color: .GrayScale.gray5)

Text(name)
.dmsFont(.body(.body2), color: .System.text)
Text(point.name)
.dmsFont(.body(.body2), color: .GrayScale.gray6)
}
HStack {
Spacer()

Text(score)
.dmsFont(.body(.body2), color: score.contains("-") ? .System.error : .PrimaryVariant.darken2)
Text("\(point.type == .bonus ? "+" : "-")\(point.score)")
.dmsFont(.body(.body2), color: point.type == .bonus ? .PrimaryVariant.darken2 : .System.error)
}

Spacer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,18 @@ final class RewardPointDetailViewModel: BaseViewModel {
fetchPointList()
}

func pointsTypeChanged(type: PointsType) {
pointsType = type
fetchPointList()
}

func fetchPointList() {
addCancellable(
self.fetchPointListUseCase.execute(
type: pointsType
)) { [weak self] point in
self?.point = point
}
)
) { [weak self] point in
self?.point = point
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,35 @@ struct NoticeDetailView: View {
@Environment(\.dismiss) var dismiss

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

Text(viewModel.date.toDMSDateString())
.dmsFont(.etc(.caption), color: .GrayScale.gray5)
.padding(.top, 10)
Text(viewModel.displayDate)
.dmsFont(.etc(.caption), color: .GrayScale.gray5)
.padding(.top, 10)

Divider()
.padding(.top, 20)
}
.frame(maxWidth: .infinity)
.padding(.top, 40)
Divider()
.padding(.top, 20)
}
.frame(maxWidth: .infinity)
.padding(.top, 40)

Text(viewModel.content)
.dmsFont(.body(.body2), color: .GrayScale.gray6)
.padding(.top, 24)
.padding(.bottom, 40)
Text(viewModel.content)
.frame(maxWidth: .infinity, alignment: .leading)
.multilineTextAlignment(.leading)
.dmsFont(.body(.body2), color: .GrayScale.gray6)
.padding(.top, 24)

Spacer()
Spacer()
}
}
.navigationTitle("공지")
.navigationBarTitleDisplayMode(.inline)
.padding(.horizontal, 24)
.dmsBackground()
.dmsBackButton(dismiss: dismiss)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ final class NoticeDetailViewModel: BaseViewModel {
@Published var title = ""
@Published var content = ""
@Published var date = Date()
var displayDate: String {
"\(date.year)/\(date.month)/\(date.day) \(date.hour):\(date.minute)"
}

let id: String
private let id: String

private let fetchDetailNoticeUseCase: any FetchDetailNoticeUseCase

Expand All @@ -24,7 +27,7 @@ final class NoticeDetailViewModel: BaseViewModel {
fetchDetailNoticeUseCase.execute(id: id)
) { [weak self] noticeDetail in
self?.title = noticeDetail.title
self?.content = noticeDetail.content
self?.content = "asdasf\nasda"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이거 뭐에요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 실험하던거 실수가

self?.date = noticeDetail.createdAt
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ struct NoticeListView: View {
Spacer()

NoticeOrderButton(text: viewModel.noticeOrderType.display, color: .GrayScale.gray6) {
viewModel.orderTypeButtonDidTap()
withAnimation {
viewModel.orderTypeButtonDidTap()
}
}
.padding(.horizontal, 24)
.padding(.horizontal, 24)
}
.padding(.top, 12)

Expand Down Expand Up @@ -63,7 +65,7 @@ struct NoticeListView: View {
Text(title)
.dmsFont(.body(.body2), color: .System.title)

Text(date.toSmallDMSDateString())
Text("\(String(date.year))/\(date.month)/\(date.day)")
.dmsFont(.etc(.caption), color: .System.text)
}
Spacer()
Expand All @@ -72,6 +74,5 @@ struct NoticeListView: View {
}
.frame(height: 68)
.shadow(color: .GrayScale.gray5.opacity(0.15), blur: 20)

}
}
8 changes: 8 additions & 0 deletions Projects/Modules/Utility/Sources/DateUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,12 @@ public extension Date {
var day: Int {
return Calendar.current.component(.day, from: self)
}

var hour: Int {
return Calendar.current.component(.hour, from: self)
}

var minute: Int {
return Calendar.current.component(.minute, from: self)
}
}