generated from GSM-MSG/MSG-Repository-Generator
-
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.
Merge pull request #320 from GSM-MSG/317-authentication-input-page-ui
๐ :: [#317] ์ธ์ฆ์ ์ ๋ ฅ ํ์ด์ง ํผ๋ธ๋ฆฌ์ฑ
- Loading branch information
Showing
18 changed files
with
387 additions
and
0 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
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
72 changes: 72 additions & 0 deletions
72
Projects/Core/DesignSystem/Sources/TextField/SMSTextEditor.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,72 @@ | ||
import SwiftUI | ||
import ViewUtil | ||
|
||
public struct SMSTextEditor: View { | ||
@Binding var text: String | ||
@FocusState var isFocused: Bool | ||
var placeholder: String | ||
var errorText: String | ||
var isError: Bool | ||
var isOnClear: Bool | ||
var onSubmit: () -> Void | ||
|
||
public init( | ||
_ placeholder: String = "", | ||
text: Binding<String>, | ||
errorText: String = "", | ||
isError: Bool = false, | ||
isOnClear: Bool = true, | ||
onSubmit: @escaping () -> Void = {} | ||
) { | ||
self._text = text | ||
self.placeholder = placeholder | ||
self.errorText = errorText | ||
self.isError = isError | ||
self.isOnClear = isOnClear | ||
self.onSubmit = onSubmit | ||
} | ||
|
||
public var body: some View { | ||
VStack(alignment: .leading, spacing: 8) { | ||
ZStack(alignment: .topLeading) { | ||
HStack { | ||
TextEditor(text: $text) | ||
.onSubmit(onSubmit) | ||
.smsFont(.body1, color: .neutral(.n50)) | ||
.focused($isFocused) | ||
|
||
SMSIcon(.xmark) | ||
.buttonWrapper { | ||
text = "" | ||
} | ||
.conditional(text.isNotEmpty && isOnClear) | ||
} | ||
.colorMultiply(.sms(.neutral(.n10))) | ||
.frame(height: 216) | ||
.padding(.horizontal, 8) | ||
.background(Color.sms(.neutral(.n10))) | ||
.cornerRadius(8) | ||
.overlay { | ||
RoundedRectangle(cornerRadius: 8) | ||
.strokeBorder(Color.sms(.primary(.p2))) | ||
.conditional(isFocused) | ||
} | ||
.onTapGesture { | ||
isFocused = true | ||
} | ||
|
||
if text.isEmpty { | ||
Text(placeholder) | ||
.smsFont(.body1, color: .neutral(.n30)) | ||
.padding(.top, 11) | ||
.padding(.leading, 12) | ||
} | ||
} | ||
ConditionView(isError && errorText.isNotEmpty) { | ||
Text(errorText) | ||
.padding(.leading, 8) | ||
.smsFont(.caption1, color: .error(.e2)) | ||
} | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Projects/Feature/InputAuthenticationFeature/Demo/Resources/LaunchScreen.storyboard
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,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM"> | ||
<dependencies> | ||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/> | ||
<capability name="Safe area layout guides" minToolsVersion="9.0"/> | ||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> | ||
</dependencies> | ||
<scenes> | ||
<!--View Controller--> | ||
<scene sceneID="EHf-IW-A2E"> | ||
<objects> | ||
<viewController id="01J-lp-oVM" sceneMemberID="viewController"> | ||
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3"> | ||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> | ||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> | ||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> | ||
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/> | ||
</view> | ||
</viewController> | ||
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/> | ||
</objects> | ||
<point key="canvasLocation" x="53" y="375"/> | ||
</scene> | ||
</scenes> | ||
</document> |
27 changes: 27 additions & 0 deletions
27
Projects/Feature/InputAuthenticationFeature/Demo/Sources/AppDelegate.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,27 @@ | ||
import BaseFeature | ||
import SwiftUI | ||
import InputAuthenticationFeatureInterface | ||
@testable import InputAuthenticationFeature | ||
|
||
final class DummyInputAuthenticationDelegate: InputAuthenticationDelegate { | ||
func completeToInputInputAuthentication() {} | ||
} | ||
|
||
@main | ||
struct InputAuthenticationApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
let model = InputAuthenticationModel() | ||
let intent = InputAuthenticationIntent( | ||
model: model, | ||
inputAuthenticationDelegate: DummyInputAuthenticationDelegate() | ||
) | ||
let container = MVIContainer( | ||
intent: intent as InputAuthenticationIntentProtocol, | ||
model: model as InputAuthenticationStateProtocol, | ||
modelChangePublisher: model.objectWillChange | ||
) | ||
InputAuthenticationView(container: container) | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Projects/Feature/InputAuthenticationFeature/Interface/InputAuthenticationBuildable.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,6 @@ | ||
import SwiftUI | ||
|
||
public protocol InputAuthenticationBuildable { | ||
associatedtype ViewType: View | ||
func makeView(delegate: InputAuthenticationDelegate) -> ViewType | ||
} |
3 changes: 3 additions & 0 deletions
3
Projects/Feature/InputAuthenticationFeature/Interface/InputAuthenticationDelegate.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,3 @@ | ||
public protocol InputAuthenticationDelegate: AnyObject { | ||
func completeToInputInputAuthentication() | ||
} |
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,12 @@ | ||
import ProjectDescription | ||
import ProjectDescriptionHelpers | ||
import DependencyPlugin | ||
|
||
let project = Project.makeModule( | ||
name: ModulePaths.Feature.InputAuthenticationFeature.rawValue, | ||
product: .staticLibrary, | ||
targets: [.interface, .unitTest, .demo], | ||
internalDependencies: [ | ||
.Feature.BaseFeature | ||
] | ||
) |
19 changes: 19 additions & 0 deletions
19
Projects/Feature/InputAuthenticationFeature/Sources/DI/InputAuthenticationComponent.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,19 @@ | ||
import BaseFeature | ||
import InputAuthenticationFeatureInterface | ||
import NeedleFoundation | ||
import SwiftUI | ||
|
||
public protocol InputAuthenticationDependency: Dependency {} | ||
|
||
public final class InputAuthenticationComponent: Component<InputAuthenticationDependency>, InputAuthenticationBuildable { | ||
public func makeView(delegate: InputAuthenticationDelegate) -> some View { | ||
let model = InputAuthenticationModel() | ||
let intent = InputAuthenticationIntent(model: model, inputAuthenticationDelegate: delegate) | ||
let container = MVIContainer( | ||
intent: intent as InputAuthenticationIntentProtocol, | ||
model: model as InputAuthenticationStateProtocol, | ||
modelChangePublisher: model.objectWillChange | ||
) | ||
return InputAuthenticationView(container: container) | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Projects/Feature/InputAuthenticationFeature/Sources/Intent/InputAuthenticationIntent.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,35 @@ | ||
import Foundation | ||
import InputAuthenticationFeatureInterface | ||
|
||
final class InputAuthenticationIntent: InputAuthenticationIntentProtocol { | ||
private weak var model: (any InputAuthenticationActionProtocol)? | ||
private weak var inputAuthenticationDelegate: (any InputAuthenticationDelegate)? | ||
|
||
init( | ||
model: any InputAuthenticationActionProtocol, | ||
inputAuthenticationDelegate: any InputAuthenticationDelegate | ||
) { | ||
self.model = model | ||
self.inputAuthenticationDelegate = inputAuthenticationDelegate | ||
} | ||
|
||
func updateAuthenticationTitle(index: Int, title: String) { | ||
model?.updateAuthenticationTitle(index: index, title: title) | ||
} | ||
|
||
func updateAuthenticationContent(index: Int, content: String) { | ||
model?.updateAuthenticationContent(index: index, content: content) | ||
} | ||
|
||
func completeButtonDidTap() { | ||
inputAuthenticationDelegate?.completeToInputInputAuthentication() | ||
} | ||
|
||
func authenticationAppendButtonDidTap() { | ||
model?.appendEmptyAuthentication() | ||
} | ||
|
||
func appendEmptyAuthentication() { | ||
model?.appendEmptyAuthentication() | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Projects/Feature/InputAuthenticationFeature/Sources/Intent/InputAuthenticationProtocol.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,9 @@ | ||
import Foundation | ||
|
||
protocol InputAuthenticationIntentProtocol { | ||
func completeButtonDidTap() | ||
func updateAuthenticationTitle(index: Int, title: String) | ||
func updateAuthenticationContent(index: Int, content: String) | ||
func authenticationAppendButtonDidTap() | ||
func appendEmptyAuthentication() | ||
} |
27 changes: 27 additions & 0 deletions
27
Projects/Feature/InputAuthenticationFeature/Sources/Model/InputAuthenticationModel.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,27 @@ | ||
import Foundation | ||
|
||
final class InputAuthenticationModel: ObservableObject, InputAuthenticationStateProtocol { | ||
@Published var authenticationTitle: String = "" | ||
@Published var authenticationContent: String = "" | ||
@Published var authenticationList: [AuthenticationInfo] = [] | ||
} | ||
|
||
extension InputAuthenticationModel: InputAuthenticationActionProtocol { | ||
func appendEmptyAuthentication() { | ||
let newAuthentication = AuthenticationInfo( | ||
title: "", | ||
content: "" | ||
) | ||
self.authenticationList.append(newAuthentication) | ||
} | ||
|
||
func updateAuthenticationTitle(index: Int, title: String) { | ||
guard authenticationList[safe: index] != nil else { return } | ||
self.authenticationList[index].title = title | ||
} | ||
|
||
func updateAuthenticationContent(index: Int, content: String) { | ||
guard authenticationList[safe: index] != nil else { return } | ||
self.authenticationList[index].content = content | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...s/Feature/InputAuthenticationFeature/Sources/Model/InputAuthenticationModelProtocol.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,18 @@ | ||
import Foundation | ||
|
||
struct AuthenticationInfo: Equatable { | ||
var title: String | ||
var content: String | ||
} | ||
|
||
protocol InputAuthenticationStateProtocol { | ||
var authenticationTitle: String { get } | ||
var authenticationContent: String { get } | ||
var authenticationList: [AuthenticationInfo] { get } | ||
} | ||
|
||
protocol InputAuthenticationActionProtocol: AnyObject { | ||
func updateAuthenticationTitle(index: Int, title: String) | ||
func updateAuthenticationContent(index: Int, content: String) | ||
func appendEmptyAuthentication() | ||
} |
Oops, something went wrong.