From c3c034cd4b23f26f220d95412cd4d3674dbbffb3 Mon Sep 17 00:00:00 2001 From: Anna Zakharova Date: Fri, 8 Nov 2024 13:29:19 +0000 Subject: [PATCH] IOS-3708 Integrate @Entry macro --- .../ApplicationLayer/GlobalEnv/AppInterfaceStyle.swift | 8 +------- .../ApplicationLayer/GlobalEnv/KeyboardDismiss.swift | 9 +-------- .../ApplicationLayer/GlobalEnv/PresentedDismiss.swift | 9 +-------- .../SwiftUI/Buttons/AsyncStandardButtonGroup.swift | 9 +-------- .../Common/SwiftUI/DragAndDrop/DragAndDropFrames.swift | 9 +-------- .../Common/SwiftUI/DragAndDrop/DragAndDropModels.swift | 9 +-------- .../AnytypeNavigationAdditionalSafeArea.swift | 9 +-------- .../NavigationView/AnytypeNavigationItemData.swift | 9 +-------- .../Flows/SpaceHub/Support/PageNavigation.swift | 9 +-------- .../BottomPanel/HomeBottomPanelStateEnvironment.swift | 9 +-------- .../CommonViews/NotificationDismissEnvironment.swift | 9 +-------- 11 files changed, 11 insertions(+), 87 deletions(-) diff --git a/Anytype/Sources/ApplicationLayer/GlobalEnv/AppInterfaceStyle.swift b/Anytype/Sources/ApplicationLayer/GlobalEnv/AppInterfaceStyle.swift index 3f844979e5..dfe10312a7 100644 --- a/Anytype/Sources/ApplicationLayer/GlobalEnv/AppInterfaceStyle.swift +++ b/Anytype/Sources/ApplicationLayer/GlobalEnv/AppInterfaceStyle.swift @@ -39,15 +39,9 @@ final class AppInterfaceStyle { } } -struct AppInterfaceStyleKey: EnvironmentKey { - static let defaultValue = AppInterfaceStyle(window: nil) -} extension EnvironmentValues { - var appInterfaceStyle: AppInterfaceStyle { - get { self[AppInterfaceStyleKey.self] } - set { self[AppInterfaceStyleKey.self] = newValue } - } + @Entry var appInterfaceStyle = AppInterfaceStyle(window: nil) } extension View { diff --git a/Anytype/Sources/ApplicationLayer/GlobalEnv/KeyboardDismiss.swift b/Anytype/Sources/ApplicationLayer/GlobalEnv/KeyboardDismiss.swift index a372e6031c..a87f6ef958 100644 --- a/Anytype/Sources/ApplicationLayer/GlobalEnv/KeyboardDismiss.swift +++ b/Anytype/Sources/ApplicationLayer/GlobalEnv/KeyboardDismiss.swift @@ -1,15 +1,8 @@ import Foundation import SwiftUI -struct KeyboardDismiss: EnvironmentKey { - static let defaultValue: () -> Void = {} -} - extension EnvironmentValues { - var keyboardDismiss: () -> Void { - get { self[KeyboardDismiss.self] } - set { self[KeyboardDismiss.self] = newValue } - } + @Entry var keyboardDismiss: () -> Void = {} } extension View { diff --git a/Anytype/Sources/ApplicationLayer/GlobalEnv/PresentedDismiss.swift b/Anytype/Sources/ApplicationLayer/GlobalEnv/PresentedDismiss.swift index fa6c97f8fd..5539c16329 100644 --- a/Anytype/Sources/ApplicationLayer/GlobalEnv/PresentedDismiss.swift +++ b/Anytype/Sources/ApplicationLayer/GlobalEnv/PresentedDismiss.swift @@ -24,15 +24,8 @@ struct DismissAllPresented: Equatable { } } -struct PresentedDismissKey: EnvironmentKey { - static let defaultValue = DismissAllPresented(window: nil) -} - extension EnvironmentValues { - var dismissAllPresented: DismissAllPresented { - get { self[PresentedDismissKey.self] } - set { self[PresentedDismissKey.self] = newValue } - } + @Entry var dismissAllPresented = DismissAllPresented(window: nil) } extension View { diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/Buttons/AsyncStandardButtonGroup.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/Buttons/AsyncStandardButtonGroup.swift index 661cdb5be5..dab506aa9a 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/Buttons/AsyncStandardButtonGroup.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/Buttons/AsyncStandardButtonGroup.swift @@ -1,15 +1,8 @@ import Foundation import SwiftUI -struct StandardButtonGroupDisableKey: EnvironmentKey { - static let defaultValue: Binding = .constant(false) -} - extension EnvironmentValues { - var standardButtonGroupDisable: Binding { - get { self[StandardButtonGroupDisableKey.self] } - set { self[StandardButtonGroupDisableKey.self] = newValue } - } + @Entry var standardButtonGroupDisable: Binding = .constant(false) } struct AsyncStandardButtonGroup: View { diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropFrames.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropFrames.swift index b7b4c751eb..277ae975d3 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropFrames.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropFrames.swift @@ -1,15 +1,8 @@ import Foundation import SwiftUI -struct AnytypeDragAndDropFrames: EnvironmentKey { - static let defaultValue = DragAndDropFrames() -} - extension EnvironmentValues { - var anytypeDragAndDropFrames: DragAndDropFrames { - get { self[AnytypeDragAndDropFrames.self] } - set { self[AnytypeDragAndDropFrames.self] = newValue } - } + @Entry var anytypeDragAndDropFrames = DragAndDropFrames() } final class DragAndDropFrames { diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropModels.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropModels.swift index ae7c3708d1..08b9adecf2 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropModels.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/DragAndDrop/DragAndDropModels.swift @@ -1,15 +1,8 @@ import Foundation import SwiftUI -struct AnytypeDragState: EnvironmentKey { - static let defaultValue: Binding = .constant(DragState()) -} - extension EnvironmentValues { - var anytypeDragState: Binding { - get { self[AnytypeDragState.self] } - set { self[AnytypeDragState.self] = newValue } - } + @Entry var anytypeDragState: Binding = .constant(DragState()) } struct DropDataElement { diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationAdditionalSafeArea.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationAdditionalSafeArea.swift index 64db34fedb..152b7d1c37 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationAdditionalSafeArea.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationAdditionalSafeArea.swift @@ -1,15 +1,8 @@ import Foundation import SwiftUI -struct AnytypeNavigationPanelSizeEnvironmentKey: EnvironmentKey { - static let defaultValue = CGSize.zero -} - extension EnvironmentValues { - var anytypeNavigationPanelSize: CGSize { - get { self[AnytypeNavigationPanelSizeEnvironmentKey.self] } - set { self[AnytypeNavigationPanelSizeEnvironmentKey.self] = newValue } - } + @Entry var anytypeNavigationPanelSize = CGSize.zero } extension View { diff --git a/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationItemData.swift b/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationItemData.swift index 2bef2ae748..3667df27ec 100644 --- a/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationItemData.swift +++ b/Anytype/Sources/PresentationLayer/Common/SwiftUI/NavigationView/AnytypeNavigationItemData.swift @@ -1,15 +1,8 @@ import Foundation import SwiftUI -struct AnytypeNavigationItemDataEnvironmentKey: EnvironmentKey { - static let defaultValue: AnyHashable? = nil -} - extension EnvironmentValues { - var anytypeNavigationItemData: AnyHashable? { - get { self[AnytypeNavigationItemDataEnvironmentKey.self] } - set { self[AnytypeNavigationItemDataEnvironmentKey.self] = newValue } - } + @Entry var anytypeNavigationItemData: AnyHashable? = nil } extension View { diff --git a/Anytype/Sources/PresentationLayer/Flows/SpaceHub/Support/PageNavigation.swift b/Anytype/Sources/PresentationLayer/Flows/SpaceHub/Support/PageNavigation.swift index 4afd0dcbb9..f7c5833cc4 100644 --- a/Anytype/Sources/PresentationLayer/Flows/SpaceHub/Support/PageNavigation.swift +++ b/Anytype/Sources/PresentationLayer/Flows/SpaceHub/Support/PageNavigation.swift @@ -8,13 +8,6 @@ struct PageNavigation { let replace: (EditorScreenData) -> Void } -struct PageNavigationEnvironmentKey: EnvironmentKey { - static let defaultValue: PageNavigation = PageNavigation(push: { _ in }, pop: { }, replace: { _ in }) -} - extension EnvironmentValues { - var pageNavigation: PageNavigation { - get { self[PageNavigationEnvironmentKey.self] } - set { self[PageNavigationEnvironmentKey.self] = newValue } - } + @Entry var pageNavigation = PageNavigation(push: { _ in }, pop: { }, replace: { _ in }) } diff --git a/Anytype/Sources/PresentationLayer/Modules/HomeNavigationContainer/BottomPanel/HomeBottomPanelStateEnvironment.swift b/Anytype/Sources/PresentationLayer/Modules/HomeNavigationContainer/BottomPanel/HomeBottomPanelStateEnvironment.swift index 3230294a18..2d3b8915c9 100644 --- a/Anytype/Sources/PresentationLayer/Modules/HomeNavigationContainer/BottomPanel/HomeBottomPanelStateEnvironment.swift +++ b/Anytype/Sources/PresentationLayer/Modules/HomeNavigationContainer/BottomPanel/HomeBottomPanelStateEnvironment.swift @@ -1,15 +1,8 @@ import Foundation import SwiftUI -private struct HomeBottomPanelStateEnvironmentKey: EnvironmentKey { - static let defaultValue = Binding.constant(HomeBottomPanelState()) -} - private extension EnvironmentValues { - var homeBottomPanelState: Binding { - get { self[HomeBottomPanelStateEnvironmentKey.self] } - set { self[HomeBottomPanelStateEnvironmentKey.self] = newValue } - } + @Entry var homeBottomPanelState = Binding.constant(HomeBottomPanelState()) } private struct HomeBottomHiddenStateViewModifier: ViewModifier { diff --git a/Anytype/Sources/PresentationLayer/Notifications/CommonViews/NotificationDismissEnvironment.swift b/Anytype/Sources/PresentationLayer/Notifications/CommonViews/NotificationDismissEnvironment.swift index c50d098e31..fc64b7395a 100644 --- a/Anytype/Sources/PresentationLayer/Notifications/CommonViews/NotificationDismissEnvironment.swift +++ b/Anytype/Sources/PresentationLayer/Notifications/CommonViews/NotificationDismissEnvironment.swift @@ -1,13 +1,6 @@ import Foundation import SwiftUI -struct NotificationDismissKey: EnvironmentKey { - static let defaultValue: () -> Void = {} -} - extension EnvironmentValues { - var notificationDismiss: () -> Void { - get { self[NotificationDismissKey.self] } - set { self[NotificationDismissKey.self] = newValue } - } + @Entry var notificationDismiss: () -> Void = {} }