-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [WEAV-80] MVI 아키텍쳐 구조 * [Template] MVI 아키텍쳐 템플릿 추가 * [WEAV-80] MVI loading, error 추가/ * [WEAV-80] 기존 뷰 MVI 로 전환
- Loading branch information
1 parent
e3af915
commit ffbacdc
Showing
34 changed files
with
1,806 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Navigation+Ext.swift | ||
// CoreKit | ||
// | ||
// Created by 김지수 on 10/3/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import DesignCore | ||
|
||
private struct NavigationViewModifier: ViewModifier { | ||
let showLeftBackButton: Bool | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.setNavigation( | ||
showLeftBackButton: showLeftBackButton | ||
) | ||
{ | ||
AppCoordinator.shared.pop() | ||
} | ||
} | ||
} | ||
|
||
public extension View { | ||
func setNavigationWithPop() -> some View { | ||
return modifier( | ||
NavigationViewModifier( | ||
showLeftBackButton: true | ||
) | ||
) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// | ||
// ErrorModel.swift | ||
// CoreKit | ||
// | ||
// Created by 김지수 on 10/3/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public struct ErrorModel { | ||
public let title: String? | ||
public let message: String? | ||
|
||
public init( | ||
title: String?, | ||
message: String? | ||
) { | ||
self.title = title | ||
self.message = message | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// MVIContainer.swift | ||
// CoreKit | ||
// | ||
// Created by 김지수 on 10/3/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
import Combine | ||
|
||
final public class MVIContainer<Intent, Model>: ObservableObject { | ||
// MARK: Public | ||
public let intent: Intent | ||
public var model: Model | ||
|
||
// MARK: private | ||
private var cancellable: Set<AnyCancellable> = [] | ||
|
||
// MARK: Life cycle | ||
public init(intent: Intent, model: Model, modelChangePublisher: ObjectWillChangePublisher) { | ||
self.intent = intent | ||
self.model = model | ||
|
||
modelChangePublisher | ||
.receive(on: RunLoop.main) | ||
.sink(receiveValue: objectWillChange.send) | ||
.store(in: &cancellable) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// | ||
// ErrorView.swift | ||
// DesignCore | ||
// | ||
// Created by 김지수 on 10/3/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
private struct ErrorViewModifier: ViewModifier { | ||
var error: Error? | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.overlay { | ||
if let error { | ||
errorView(error: error) | ||
} | ||
} | ||
} | ||
|
||
// Error View | ||
@ViewBuilder | ||
func errorView(error: Error) -> some View { | ||
ZStack { | ||
BackgroundTextureView(.init(hex: 0xF5F1EE)) | ||
Text(error.localizedDescription) | ||
.typography(.semibold_20) | ||
} | ||
} | ||
} | ||
|
||
public extension View { | ||
func setErrorViewIfNeeded(error: Error?) -> some View { | ||
modifier(ErrorViewModifier(error: error)) | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
Projects/DesignSystem/DesignCore/Sources/LoadingView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// | ||
// LoadingView.swift | ||
// DesignCore | ||
// | ||
// Created by 김지수 on 10/4/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
private struct FullScreenLoadingOverlay: View { | ||
var body: some View { | ||
GeometryReader { geometry in | ||
ZStack { | ||
Color.black.opacity(0.2) | ||
ProgressView() | ||
} | ||
.frame(width: geometry.size.width, height: geometry.size.height) | ||
} | ||
.ignoresSafeArea() | ||
} | ||
} | ||
|
||
|
||
private struct LoadingViewModifier: ViewModifier { | ||
let isLoading: Bool | ||
|
||
func body(content: Content) -> some View { | ||
content | ||
.overlay { | ||
if isLoading { | ||
FullScreenLoadingOverlay() | ||
} | ||
} | ||
} | ||
} | ||
|
||
public extension View { | ||
func setLoading(_ isLoading: Bool) -> some View { | ||
modifier(LoadingViewModifier(isLoading: isLoading)) | ||
} | ||
} |
76 changes: 3 additions & 73 deletions
76
...AuthPhoneVerify/AuthPhoneVerifyView.swift → ...VerifyCodeInput/VerifyCodeInputView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 0 additions & 49 deletions
49
Projects/Features/SignUp/Sources/AuthAgreement/AuthAgreementView.swift
This file was deleted.
Oops, something went wrong.
57 changes: 57 additions & 0 deletions
57
Projects/Features/SignUp/Sources/AuthSignUp/AuthAgreement/AuthAgreementIntent.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// AuthAgreementIntent.swift | ||
// SignUp | ||
// | ||
// Created by 김지수 on 10/5/24. | ||
// Copyright © 2024 com.weave. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import CommonKit | ||
import CoreKit | ||
|
||
//MARK: - Intent | ||
class AuthAgreementIntent { | ||
private weak var model: AuthAgreementModelActionable? | ||
private let externalData: DataModel | ||
|
||
// MARK: Life cycle | ||
init( | ||
model: AuthAgreementModelActionable, | ||
externalData: DataModel | ||
) { | ||
self.externalData = externalData | ||
self.model = model | ||
} | ||
} | ||
|
||
//MARK: - Intentable | ||
extension AuthAgreementIntent { | ||
protocol Intentable { | ||
// content | ||
func onTapNextButton() | ||
|
||
// default | ||
func onAppear() | ||
func task() async | ||
} | ||
|
||
struct DataModel {} | ||
} | ||
|
||
//MARK: - Intentable | ||
extension AuthAgreementIntent: AuthAgreementIntent.Intentable { | ||
// default | ||
func onAppear() {} | ||
|
||
func task() async {} | ||
|
||
// content | ||
func onTapNextButton() { | ||
Task { | ||
await AppCoordinator.shared.changeRootView( | ||
.signUp(.authGreeting) | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.