diff --git a/.package.resolved b/.package.resolved index ae78344f8..ba6dfdf0c 100644 --- a/.package.resolved +++ b/.package.resolved @@ -6,8 +6,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Alamofire/Alamofire", "state" : { - "revision" : "723fa5a6c65812aec4a0d7cc432ee198883b6e00", - "version" : "5.9.0" + "revision" : "f455c2975872ccd2d9c81594c658af65716e9b9a", + "version" : "5.9.1" } }, { @@ -50,8 +50,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Infomaniak/ios-core-ui", "state" : { - "revision" : "6d069462017491b74cd1eec6a87e6333a41c15ac", - "version" : "7.0.0" + "revision" : "78fc0f85a4b32051ab3de6bb492a3690c1fc363b" } }, { @@ -131,8 +130,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/matomo-org/matomo-sdk-ios", "state" : { - "revision" : "15a645e11eaa8053f93749d73ced03da1e56fd01", - "version" : "7.5.2" + "revision" : "a8800d8725fb84bad6b7dea555075f961952bc0a", + "version" : "7.6.0" } }, { @@ -140,8 +139,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/johnpatrickmorgan/NavigationBackport", "state" : { - "revision" : "b002991691b54fd7b952e1e780de252620f8ac77", - "version" : "0.9.1" + "revision" : "add71ebc3cf71e43c662c69c4d7c1f2dc5dc3588", + "version" : "0.9.2" } }, { @@ -239,8 +238,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/Infomaniak/swift-concurrency", "state" : { - "revision" : "1c2e7ee0bb93203c865904494b0aa2aedbc57713", - "version" : "0.0.4" + "revision" : "02960fd5d2cf57c7ba38d13bbbf580d7f6ac7102", + "version" : "0.0.5" } }, { diff --git a/Mail/Components/Buttons/Custom Buttons/AccountButton.swift b/Mail/Components/Buttons/Custom Buttons/AccountButton.swift index 99e5dda6d..ff613b8fe 100644 --- a/Mail/Components/Buttons/Custom Buttons/AccountButton.swift +++ b/Mail/Components/Buttons/Custom Buttons/AccountButton.swift @@ -17,6 +17,7 @@ */ import InfomaniakCore +import InfomaniakDI import MailCore import MailResources import SwiftModalPresentation @@ -25,7 +26,12 @@ import SwiftUI struct AccountButton: View { @EnvironmentObject private var mailboxManager: MailboxManager - @ModalState private var presentedCurrentAccount: Account? + @ModalState private var presentedCurrentAccount: Account? { + didSet { + @InjectService var snackbarPresenter: SnackBarPresentable + snackbarPresenter.dismissAll() + } + } var body: some View { Button { diff --git a/Mail/RootView.swift b/Mail/RootView.swift index 46e035a96..b0ead112b 100644 --- a/Mail/RootView.swift +++ b/Mail/RootView.swift @@ -16,10 +16,13 @@ along with this program. If not, see . */ +import InfomaniakDI import MailCore import SwiftUI struct RootView: View { + @LazyInjectService private var snackbarPresenter: SnackBarPresentable + @EnvironmentObject private var rootViewState: RootViewState var body: some View { @@ -44,5 +47,8 @@ struct RootView: View { PreloadingView(currentAccount: currentAccount) } } + .onChange(of: rootViewState.state) { _ in + snackbarPresenter.dismissAll() + } } } diff --git a/Mail/Views/Menu Drawer/MenuDrawerView.swift b/Mail/Views/Menu Drawer/MenuDrawerView.swift index b48468ff9..9ea96100c 100644 --- a/Mail/Views/Menu Drawer/MenuDrawerView.swift +++ b/Mail/Views/Menu Drawer/MenuDrawerView.swift @@ -43,6 +43,8 @@ class NavigationDrawerState: ObservableObject { } struct NavigationDrawer: View { + @LazyInjectService private var snackbarPresenter: SnackBarPresentable + @EnvironmentObject private var navigationDrawerState: NavigationDrawerState @GestureState private var isDragGestureActive = false @@ -79,6 +81,7 @@ struct NavigationDrawer: View { .gesture(dragGestureForRootViewSize(rootViewSizeProxy.size)) .statusBarHidden(navigationDrawerState.isOpen) .onChange(of: navigationDrawerState.isOpen) { isOpen in + snackbarPresenter.dismissAll() if !isOpen { offsetWidth = 0 } diff --git a/MailCore/Cache/MainViewState.swift b/MailCore/Cache/MainViewState.swift index ed6fb0465..b9eb6b990 100644 --- a/MailCore/Cache/MainViewState.swift +++ b/MailCore/Cache/MainViewState.swift @@ -17,6 +17,8 @@ */ import Foundation +import InfomaniakCoreUI +import InfomaniakDI import SwiftModalPresentation public protocol SelectedThreadOwnable { @@ -24,23 +26,47 @@ public protocol SelectedThreadOwnable { } public class MainViewState: ObservableObject, SelectedThreadOwnable { - @ModalPublished public var composeMessageIntent: ComposeMessageIntent? + @ModalPublished public var composeMessageIntent: ComposeMessageIntent? { + didSet { + @InjectService var snackbarPresenter: SnackBarPresentable + snackbarPresenter.dismissAll() + } + } @ModalPublished public var settingsViewConfig: SettingsViewConfig? @ModalPublished public var isShowingSyncProfile = false @ModalPublished public var isShowingSyncDiscovery = false - @Published public var isShowingSearch = false + @Published public var isShowingSearch = false { + didSet { + @InjectService var snackbarPresenter: SnackBarPresentable + snackbarPresenter.dismissAll() + } + } + @ModalPublished public var isShowingReviewAlert = false - @ModalPublished public var isShowingSafariView: IdentifiableURL? + @ModalPublished public var isShowingSafariView: IdentifiableURL? { + didSet { + @InjectService var snackbarPresenter: SnackBarPresentable + snackbarPresenter.dismissAll() + } + } + @ModalPublished public var isShowingUpdateAvailable = false @ModalPublished public var isShowingSetAppAsDefaultDiscovery = false @Published public var isShowingChristmasEasterEgg = false + @LazyInjectService private var snackbarPresenter: SnackBarPresentable + /// Represents the state of navigation /// /// The selected thread is the last in collection, by convention. - @Published public var threadPath = [Thread]() + @Published public var threadPath = [Thread]() { + didSet { + snackbarPresenter.dismissAll() + } + } + @Published public var selectedFolder: Folder { didSet { SentryDebug.switchFolderBreadcrumb(uid: selectedFolder.remoteId, name: selectedFolder.name) diff --git a/MailCore/Utils/SnackBar/SnackBarPresentable.swift b/MailCore/Utils/SnackBar/SnackBarPresentable.swift index 77010e85b..31d2492de 100644 --- a/MailCore/Utils/SnackBar/SnackBarPresentable.swift +++ b/MailCore/Utils/SnackBar/SnackBarPresentable.swift @@ -32,6 +32,8 @@ public protocol SnackBarPresentable { anchor: CGFloat, contextView: UIView? ) + /// Dismiss all currently presented snackBars + func dismissAll() } public final class SnackBarPresenter: SnackBarPresentable { @@ -67,4 +69,8 @@ public final class SnackBarPresenter: SnackBarPresentable { ) } } + + public func dismissAll() { + NotificationCenter.default.post(name: IKSnackBar.dismissSnackbarNotificationName, object: nil, userInfo: nil) + } } diff --git a/Project.swift b/Project.swift index 4aa4f064e..dc13fa9b6 100644 --- a/Project.swift +++ b/Project.swift @@ -30,7 +30,10 @@ let project = Project(name: "Mail", url: "https://github.com/Infomaniak/ios-core", .revision("7388c5ccc5ab177bf640968a711be2ab2f24200c") ), - .package(url: "https://github.com/Infomaniak/ios-core-ui", .upToNextMajor(from: "7.0.0")), + .package( + url: "https://github.com/Infomaniak/ios-core-ui", + .revision("78fc0f85a4b32051ab3de6bb492a3690c1fc363b") + ), .package(url: "https://github.com/Infomaniak/ios-notifications", .upToNextMajor(from: "5.0.0")), .package(url: "https://github.com/Infomaniak/ios-create-account", .upToNextMajor(from: "6.0.0")), .package(url: "https://github.com/Infomaniak/ios-bug-tracker", .upToNextMajor(from: "4.0.0")),