Skip to content

Commit

Permalink
Merge pull request #338 from GSM-MSG/334-authentication-form-ui-building
Browse files Browse the repository at this point in the history
๐Ÿ”€ :: [#334] GSM ์ธ์ฆ์ œ Form UI ์ถ”๊ฐ€
  • Loading branch information
baekteun authored Jul 6, 2024
2 parents 352683f + 7db8b56 commit 68060e2
Show file tree
Hide file tree
Showing 14 changed files with 484 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "xmark.svg",
"filename" : "Xmark.svg",
"idiom" : "universal"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@ import SwiftUI
import ViewUtil
import UniformTypeIdentifiers

public struct FileField: View {
@State var fileText: String
@State var isShow: Bool
@State var isError: Bool
let errorText: String
let allowedContentTypes: [UTType]
let action: (URL) -> Void
public struct SMSFileField: View {
private let placeholder: String?
private let fileText: String?
@State private var isShow: Bool = false
private let isError: Bool
private let errorText: String
private let allowedContentTypes: [UTType]
private let action: (Result<URL, Error>) -> Void

public init(
fileText: String,
isShow: Bool,
_ placeholder: String? = nil,
fileText: String?,
isError: Bool = false,
errorText: String = "",
allowedContentTypes: [UTType] = [.content],
action: @escaping (URL) -> Void
action: @escaping (Result<URL, Error>) -> Void
) {
self.placeholder = placeholder
self.fileText = fileText
self.isShow = isShow
self.isError = isError
self.errorText = errorText
self.allowedContentTypes = allowedContentTypes
Expand All @@ -28,9 +29,9 @@ public struct FileField: View {

public var body: some View {
SMSTextField(
"",
placeholder ?? "",
text: Binding(
get: { fileText },
get: { fileText ?? "" },
set: { _ in }
),
errorText: errorText,
Expand All @@ -57,14 +58,7 @@ public struct FileField: View {
),
allowedContentTypes: allowedContentTypes
) { result in
switch result {
case .success(let url):
fileText = url.lastPathComponent
action(url)

case .failure:
self.isError = true
}
action(result)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,63 @@
import UIKit
import SwiftUI
@testable import GSMAuthenticationFormFeature

@main
final class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
struct GSMAuthenticationFormDemoApp: App {
var body: some Scene {
WindowGroup {
let uiModel = GSMAuthenticationFormUIModel(
areas: [
.init(
title: "Area",
files: [],
sections: [
.init(
title: "Section1",
description: "Description",
currentFieldCount: 2,
fields: [
.init(
key: "text",
type: .text(value: nil),
placeholder: "text placeholder"
),
.init(
key: "number",
type: .number(value: nil),
placeholder: "number placeholder"
),
.init(
key: "file",
type: .file(fileName: nil),
placeholder: "file placeholder"
)
]
),
.init(
title: "Section2",
description: "Description",
currentFieldCount: 3,
fields: [
.init(
key: "boolean",
type: .boolean(isSelcted: false),
placeholder: nil
),
.init(
key: "select",
type: .select(selectedValue: nil, values: ["a", "b", "c"]),
placeholder: "select placeholder"
)
]
)
]
)
]
)

func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
) -> Bool {
window = UIWindow(frame: UIScreen.main.bounds)
let viewController = UIViewController()
viewController.view.backgroundColor = .yellow
window?.rootViewController = viewController
window?.makeKeyAndVisible()

return true
GSMAuthenticationFormBuilderView(uiModel: uiModel) { interaction in

}
}
}
}
4 changes: 3 additions & 1 deletion Projects/Feature/GSMAuthenticationFormFeature/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ let project = Project.makeModule(
name: ModulePaths.Feature.GSMAuthenticationFormFeature.rawValue,
product: .staticLibrary,
targets: [.interface, .unitTest, .demo],
internalDependencies: []
internalDependencies: [
.Feature.BaseFeature
]
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
final class GSMAuthenticationFormIntent: GSMAuthenticationFormIntentProtocol {
weak var model: (any GSMAuthenticationFormActionProtocol)?

init(model: any GSMAuthenticationFormActionProtocol) {
self.model = model
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
protocol GSMAuthenticationFormIntentProtocol {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
final class GSMAuthenticationFormModel: GSMAuthenticationFormStateProtocol {

}

extension GSMAuthenticationFormModel: GSMAuthenticationFormActionProtocol {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

protocol GSMAuthenticationFormStateProtocol {

}

protocol GSMAuthenticationFormActionProtocol: AnyObject {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import Foundation

// swiftlint: disable nesting
struct GSMAuthenticationFormUIModel {
let areas: [Area]

struct Area {
let title: String
let files: [File]
let sections: [Section]

struct File {
let name: String
let url: String
}

struct Section {
let title: String
let description: String
let currentFieldCount: Int
let fields: [Field]

struct Field {
let key: String
let type: FieldType
let placeholder: String?

enum FieldType {
case text(value: String?)
case number(value: Int?)
case boolean(isSelcted: Bool?)
case file(fileName: String?)
case select(selectedValue: String?, values: [String])
}
}
}
}
}
// swiftlint: enable nesting
Loading

0 comments on commit 68060e2

Please sign in to comment.