Skip to content

Commit

Permalink
🩹 ::[#330] 컨벤션, action() 위치 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
kimsh153 committed May 24, 2024
1 parent f7fa8e6 commit bd9df9d
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions Projects/Core/DesignSystem/Sources/File/FileField.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import SwiftUI
import ViewUtil
import UniformTypeIdentifiers

public struct FileField: View {
@State var fileText: String
@State var isShow: Bool
@State var isError: Bool
let action: () -> Void
let allowedContentTypes: [UTType]
let action: (URL) -> Void

public init(
fileText: String,
isShow: Bool,
isError: Bool = false,
action: @escaping () -> Void
allowedContentTypes: [UTType] = [.content],
action: @escaping (URL) -> Void
) {
self.fileText = fileText
self.isShow = isShow
self.isError = isError
self.allowedContentTypes = allowedContentTypes
self.action = action
}

Expand All @@ -38,22 +42,23 @@ public struct FileField: View {
TapGesture()
.onEnded {
self.isShow = true
action()
}
)
.fileImporter(
isPresented:
Binding(
get: {isShow},
set: {active in isShow = active
isPresented: Binding(
get: { isShow },
set: { active in
isShow = active
}
),
allowedContentTypes: [.content]
allowedContentTypes: allowedContentTypes
) { result in
switch result {
case .success(let url):
fileText = url.lastPathComponent
case .failure(let error):
action(url)

case .failure:
self.isError = true
}
}
Expand Down

0 comments on commit bd9df9d

Please sign in to comment.