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 :: 마이페이지 Feature #125

Merged
merged 7 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 10 additions & 8 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,17 @@ private func factory1ab5a747ddf21e1393f9f47b58f8f304c97af4d5(_ component: Needle
return MainTabDependency2826cdb310ed0b17a725Provider(appComponent: parent1(component) as! AppComponent)
}
private class MyPageDependency48d84b530313b3ee40feProvider: MyPageDependency {


init() {

var fetchMyProfileUseCase: any FetchMyProfileUseCase {
return appComponent.fetchMyProfileUseCase
}
private let appComponent: AppComponent
init(appComponent: AppComponent) {
self.appComponent = appComponent
}
}
/// ^->AppComponent->MyPageComponent
private func factory0f6f456ebf157d02dfb3e3b0c44298fc1c149afb(_ component: NeedleFoundation.Scope) -> AnyObject {
return MyPageDependency48d84b530313b3ee40feProvider()
private func factory0f6f456ebf157d02dfb3f47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject {
return MyPageDependency48d84b530313b3ee40feProvider(appComponent: parent1(component) as! AppComponent)
}
private class RootDependency3944cc797a4a88956fb5Provider: RootDependency {
var signinComponent: SigninComponent {
Expand Down Expand Up @@ -470,7 +472,7 @@ extension MainTabComponent: Registration {
}
extension MyPageComponent: Registration {
public func registerItems() {

keyPathToName[\MyPageDependency.fetchMyProfileUseCase] = "fetchMyProfileUseCase-any FetchMyProfileUseCase"
}
}
extension RootComponent: Registration {
Expand Down Expand Up @@ -558,7 +560,7 @@ private func register1() {
registerProviderFactory("^->AppComponent->SignupEmailVerifyComponent", factory3b1904c76335d70151ebf47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->SignupProfileImageComponent", factory6792674212c15df7e9cff47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->MainTabComponent", factory1ab5a747ddf21e1393f9f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->MyPageComponent", factory0f6f456ebf157d02dfb3e3b0c44298fc1c149afb)
registerProviderFactory("^->AppComponent->MyPageComponent", factory0f6f456ebf157d02dfb3f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->RootComponent", factory264bfc4d4cb6b0629b40f47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->SigninComponent", factory2882a056d84a613debccf47b58f8f304c97af4d5)
registerProviderFactory("^->AppComponent->HomeComponent", factory67229cdf0f755562b2b1f47b58f8f304c97af4d5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ struct NoticeView: View {
.cornerRadius(100)
.padding(.horizontal, 24)
.padding(.top, 12)
.shadow(
color: .GrayScale.gray4.opacity(0.24),
y: 1,
blur: 20
)
.dmsShadow()
}
}
13 changes: 11 additions & 2 deletions Projects/Features/MyPageFeature/Sources/MyPageComponent.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import DomainModule
import SwiftUI
import NeedleFoundation

public protocol MyPageDependency: Dependency {}
public protocol MyPageDependency: Dependency {
var fetchMyProfileUseCase: any FetchMyProfileUseCase { get }
}

public final class MyPageComponent: Component<MyPageDependency> {
public func makeView() -> some View {
Text("Text")
NavigationView {
MyPageView(
viewModel: .init(
fetchMyProfileUseCase: self.dependency.fetchMyProfileUseCase
)
)
}
}
}
147 changes: 146 additions & 1 deletion Projects/Features/MyPageFeature/Sources/MyPageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,151 @@ struct MyPageView: View {
}

var body: some View {
Text("Text")
ScrollView(showsIndicators: false) {
VStack {
HStack {
VStack(alignment: .leading, spacing: 8) {
Text("\(viewModel.profile?.gcn ?? "") \(viewModel.profile?.name ?? "Loading...")")
.dmsFont(.title(.small), color: .GrayScale.gray7)

Text(viewModel.profile?.schoolName ?? "")
.dmsFont(.text(.small), color: .GrayScale.gray6)
}

Spacer()

ZStack(alignment: .bottomTrailing) {
AsyncImage(url: URL(string: "")) { image in
image
.resizable()
.frame(width: 74, height: 74)
.clipShape(Circle())
} placeholder: {
Color.GrayScale.gray5
.frame(width: 74, height: 74)
.clipShape(Circle())
}

Circle()
.fill(Color.GrayScale.gray3)
.frame(width: 24, height: 24)
.overlay {
DMSImage(.pencil)
.frame(width: 16, height: 16)
}
}
}
.padding(.top, 48)

Text(viewModel.profile?.phrase ?? "")
.dmsFont(.text(.small), color: .GrayScale.gray7)
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity)
.padding(.vertical, 14)
.padding(.horizontal, 20)
.background {
Color.PrimaryVariant.lighten2
.cornerRadius(5)
}
.padding(.top, 60)

HStack(spacing: 12) {
rewardPointCardView(title: "상점", point: viewModel.profile?.bonusPoint ?? 0)

rewardPointCardView(title: "벌점", point: viewModel.profile?.minusPoint ?? 0)
}

VStack(alignment: .leading, spacing: 0) {
myPageOptionRowCardView(title: "상벌점 내역 확인")
.dmsFont(.text(.medium), color: .GrayScale.gray6)
.cornerRadius(10, corners: [.topLeft, .topRight])

Divider()
.padding(.horizontal, 10)

myPageOptionRowCardView(title: "비밀번호 변경")
.dmsFont(.text(.medium), color: .GrayScale.gray6)
.cornerRadius(10, corners: [.bottomLeft, .bottomRight])
}
.background {
RoundedRectangle(cornerRadius: 10)
.fill(Color.GrayScale.gray1)
.dmsShadow()
}

VStack(alignment: .leading, spacing: 0) {
myPageOptionRowCardView(title: "로그아웃", action: viewModel.logoutButtonDidTap)
.dmsFont(.text(.medium), color: .System.error)
.onTapGesture(perform: viewModel.logoutButtonDidTap)
.cornerRadius(10)
}
.frame(maxWidth: .infinity)
.background {
RoundedRectangle(cornerRadius: 10)
.fill(Color.GrayScale.gray1)
.dmsShadow()
}

Spacer()
}
.padding(.horizontal, 24)
.dmsBackground()
.navigationTitle("마이페이지")
.navigationBarTitleDisplayMode(.inline)
}
.onAppear(perform: viewModel.onAppear)
.alert("", isPresented: $viewModel.isPresentedLogoutAlert) {
Button("취소", role: .cancel) {}
Button("로그아웃", role: .destructive, action: viewModel.confirmLogoutButtonDidTap)
} message: {
Text("정말 로그아웃 하시겠습니까?")
.dmsFont(.text(.medium), color: .GrayScale.gray6)
}
}

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

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

@ViewBuilder
func rewardPointCardView(title: String, point: Int) -> some View {
VStack {
HStack {
Text(title)
.dmsFont(.text(.small), color: .GrayScale.gray6)

Spacer()
}
.padding(.top, 16)

HStack {
Spacer()

Text("\(point)")
.dmsFont(.title(.large), color: .GrayScale.gray6)
}
.padding(.bottom, 16)
}
.padding(.horizontal, 20)
.frame(maxWidth: .infinity)
.frame(height: 95)
.background {
RoundedRectangle(cornerRadius: 10)
.stroke(Color.PrimaryVariant.primary, lineWidth: 1)
.dmsShadow()
}
}
}
25 changes: 25 additions & 0 deletions Projects/Features/MyPageFeature/Sources/MyPageViewModel.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
import BaseFeature
import Combine
import DomainModule

final class MyPageViewModel: BaseViewModel {
@Published var profile: MyProfileEntity?
@Published var isPresentedLogoutAlert = false

private let fetchMyProfileUseCase: any FetchMyProfileUseCase

public init(
fetchMyProfileUseCase: any FetchMyProfileUseCase
) {
self.fetchMyProfileUseCase = fetchMyProfileUseCase
}

func onAppear() {
addCancellable(
fetchMyProfileUseCase.execute()
) { [weak self] profile in
self?.profile = profile
}
}

func logoutButtonDidTap() {
isPresentedLogoutAlert = true
}

func confirmLogoutButtonDidTap() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

// swiftlint:disable identifier_name line_length nesting type_body_length type_name
public enum DesignSystemAsset {
public enum Icons {
public static let pencil = DesignSystemImages(name: "pencil")
}
public enum PrimaryColor {
public static let darken1 = DesignSystemColors(name: "Darken-1")
public static let darken2 = DesignSystemColors(name: "Darken-2")
Expand Down Expand Up @@ -87,5 +90,45 @@ public extension DesignSystemColors.Color {
}
}

public struct DesignSystemImages {
public fileprivate(set) var name: String

#if os(macOS)
public typealias Image = NSImage
#elseif os(iOS) || os(tvOS) || os(watchOS)
public typealias Image = UIImage
#endif

public var image: Image {
let bundle = DesignSystemResources.bundle
#if os(iOS) || os(tvOS)
let image = Image(named: name, in: bundle, compatibleWith: nil)
#elseif os(macOS)
let image = bundle.image(forResource: NSImage.Name(name))
#elseif os(watchOS)
let image = Image(named: name)
#endif
guard let result = image else {
fatalError("Unable to load image asset named \(name).")
}
return result
}
}

public extension DesignSystemImages.Image {
@available(macOS, deprecated,
message: "This initializer is unsafe on macOS, please use the DesignSystemImages.image property")
convenience init?(asset: DesignSystemImages) {
#if os(iOS) || os(tvOS)
let bundle = DesignSystemResources.bundle
self.init(named: asset.name, in: bundle, compatibleWith: nil)
#elseif os(macOS)
self.init(named: NSImage.Name(asset.name))
#elseif os(watchOS)
self.init(named: asset.name)
#endif
}
}

// swiftlint:enable all
// swiftformat:enable all
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "pencil.svg",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "pencil 1.svg",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "pencil 2.svg",
"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.
Loading