Commit cc2e8395 authored by sugita mamoru's avatar sugita mamoru

Preview修正

parent c0c0163f
...@@ -40,4 +40,5 @@ struct ContentView: View { ...@@ -40,4 +40,5 @@ struct ContentView: View {
#Preview { #Preview {
ContentView() ContentView()
.environmentObject(SceneDelegate())
} }
...@@ -10,7 +10,6 @@ import Combine ...@@ -10,7 +10,6 @@ import Combine
struct InputIdPassWordView: View { struct InputIdPassWordView: View {
@EnvironmentObject var loginViewParam: LoginViewParam @EnvironmentObject var loginViewParam: LoginViewParam
// @ObservedObject var loginViewParam: LoginViewParam = LoginViewParam()
let itemHPadding: Double = 16 let itemHPadding: Double = 16
let dialogBottomPadding: Double = 32 let dialogBottomPadding: Double = 32
let textFieldHeight: Double = 49 let textFieldHeight: Double = 49
...@@ -94,4 +93,5 @@ struct InputIdPassWordView: View { ...@@ -94,4 +93,5 @@ struct InputIdPassWordView: View {
#Preview { #Preview {
InputIdPassWordView() InputIdPassWordView()
.environmentObject(LoginViewParam())
} }
...@@ -84,4 +84,6 @@ struct InputUserNameView: View { ...@@ -84,4 +84,6 @@ struct InputUserNameView: View {
#Preview { #Preview {
InputUserNameView(isLogin: .constant(false)) InputUserNameView(isLogin: .constant(false))
.environmentObject(LoginViewParam())
} }
...@@ -45,4 +45,5 @@ struct LoginTypeSelectView: View{ ...@@ -45,4 +45,5 @@ struct LoginTypeSelectView: View{
} }
#Preview { #Preview {
LoginTypeSelectView(isQrRead: .constant(false)) LoginTypeSelectView(isQrRead: .constant(false))
.environmentObject(LoginViewParam())
} }
...@@ -25,16 +25,12 @@ class AppDelegate: NSObject, UIApplicationDelegate{ ...@@ -25,16 +25,12 @@ class AppDelegate: NSObject, UIApplicationDelegate{
} }
} }
//@Observable
class SceneDelegate: UIResponder, UIWindowSceneDelegate, ObservableObject { class SceneDelegate: UIResponder, UIWindowSceneDelegate, ObservableObject {
weak var windowScene: UIWindowScene? weak var windowScene: UIWindowScene?
var tabWindow: UIWindow? var tabWindow: UIWindow?
var overlayWindow: UIWindow?
var tag : Int = 0
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
windowScene = scene as? UIWindowScene windowScene = scene as? UIWindowScene
setupOverlayWindow()
} }
...@@ -57,34 +53,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, ObservableObject { ...@@ -57,34 +53,6 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate, ObservableObject {
self.tabWindow = tabWindow self.tabWindow = tabWindow
} }
func setupOverlayWindow(){
guard let windowScene = windowScene else { return }
let window = UIWindow(windowScene: windowScene)
window.isHidden = true
window.isUserInteractionEnabled = false
self.overlayWindow = window
}
fileprivate func alert<Content: View>(config: Binding<AlertConfig>, @ViewBuilder content: @escaping () -> Content, viewTag: @escaping (Int) -> ()) {
guard let alertWindow = overlayWindow else { return }
let viewController = UIHostingController(rootView:
AlertView(config: config, tag: tag, content: {
content()
})
)
viewController.view.backgroundColor = .clear
viewController.view.tag = tag
viewTag(tag)
tag += 1
if alertWindow.rootViewController == nil {
alertWindow.rootViewController = viewController
alertWindow.isHidden = false
alertWindow.isUserInteractionEnabled = true
}
}
} }
...@@ -94,61 +62,3 @@ class PassThroughWindow: UIWindow{ ...@@ -94,61 +62,3 @@ class PassThroughWindow: UIWindow{
return rootViewController?.view == view ? nil : view return rootViewController?.view == view ? nil : view
} }
} }
struct AlertConfig {
var enableBackgroundBlur: Bool = true
var disableOutsideTap : Bool = true
var transitionType: TransitionType = .slide
var slideEdge : Edge = .bottom
private var show : Bool = false
enum TransitionType{
case slide
case opacity
}
mutating
func present(){
show = true
}
mutating
func dismiss(){
show = false
}
}
fileprivate struct AlertView<Content: View>: View {
@Binding var config: AlertConfig
var tag: Int
@ViewBuilder var content: () -> Content
var body: some View {
GeometryReader(content: { geometry in
Color.red
})
}
}
extension View {
@ViewBuilder
func alert<Content: View>(config: Binding<AlertConfig>, @ViewBuilder content: @escaping () -> Content, viewTag: @escaping (Int) -> ()) -> some View {
self
}
}
fileprivate struct AlertModifier<AlertContent: View>: ViewModifier {
@Binding var config: AlertConfig
@ViewBuilder var alertContent: () -> AlertContent
@Environment private var sceneDelegate: SceneDelegate
@State private var viewTag: Int = 0
func body(content: Content) -> some View {
content
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment