From 4c21bb4c69c24be2097544078c4b5098cb05f9a5 Mon Sep 17 00:00:00 2001 From: Satindar Dhillon Date: Fri, 8 Apr 2022 09:10:51 -0700 Subject: [PATCH] move snoozePresented var into home View Model --- .../Sources/App/Views/Home/HomeFeedViewIOS.swift | 16 ++++------------ .../Sources/App/Views/Home/HomeFeedViewMac.swift | 3 +-- .../App/Views/Home/HomeFeedViewModel.swift | 1 + .../OmnivoreKit/Sources/Utils/FeatureFlags.swift | 2 +- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift index 1991ede19..33479cc75 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewIOS.swift @@ -10,7 +10,6 @@ import Views struct HomeFeedContainerView: View { @EnvironmentObject var dataService: DataService @AppStorage(UserDefaultKey.homeFeedlayoutPreference.rawValue) var prefersListLayout = UIDevice.isIPhone - @State private var snoozePresented = false @State private var itemToSnooze: FeedItem? @State private var selectedLinkItem: FeedItem? @ObservedObject var viewModel: HomeFeedViewModel @@ -21,7 +20,6 @@ import Views HomeFeedView( prefersListLayout: $prefersListLayout, selectedLinkItem: $selectedLinkItem, - snoozePresented: $snoozePresented, itemToSnooze: $itemToSnooze, viewModel: viewModel ) @@ -56,7 +54,6 @@ import Views HomeFeedView( prefersListLayout: $prefersListLayout, selectedLinkItem: $selectedLinkItem, - snoozePresented: $snoozePresented, itemToSnooze: $itemToSnooze, viewModel: viewModel ) @@ -92,8 +89,8 @@ import Views self.selectedLinkItem = feedItem } } - .formSheet(isPresented: $snoozePresented) { - SnoozeView(snoozePresented: $snoozePresented, itemToSnooze: $itemToSnooze) { + .formSheet(isPresented: $viewModel.snoozePresented) { + SnoozeView(snoozePresented: $viewModel.snoozePresented, itemToSnooze: $itemToSnooze) { viewModel.snoozeUntil( dataService: dataService, linkId: $0.feedItemId, @@ -118,7 +115,6 @@ import Views @Binding var prefersListLayout: Bool @Binding var selectedLinkItem: FeedItem? - @Binding var snoozePresented: Bool @Binding var itemToSnooze: FeedItem? @ObservedObject var viewModel: HomeFeedViewModel @@ -128,14 +124,12 @@ import Views HomeFeedListView( prefersListLayout: $prefersListLayout, selectedLinkItem: $selectedLinkItem, - snoozePresented: $snoozePresented, itemToSnooze: $itemToSnooze, viewModel: viewModel ) } else { HomeFeedGridView( selectedLinkItem: $selectedLinkItem, - snoozePresented: $snoozePresented, itemToSnooze: $itemToSnooze, viewModel: viewModel ) @@ -179,7 +173,6 @@ import Views @EnvironmentObject var dataService: DataService @Binding var prefersListLayout: Bool @Binding var selectedLinkItem: FeedItem? - @Binding var snoozePresented: Bool @Binding var itemToSnooze: FeedItem? @State private var itemToRemove: FeedItem? @@ -217,7 +210,7 @@ import Views if FeatureFlag.enableSnooze { Button { itemToSnooze = item - snoozePresented = true + viewModel.snoozePresented = true } label: { Label { Text("Snooze") } icon: { Image.moon } } @@ -270,7 +263,7 @@ import Views if FeatureFlag.enableSnooze { Button { itemToSnooze = item - snoozePresented = true + viewModel.snoozePresented = true } label: { Label { Text("Snooze") } icon: { Image.moon } }.tint(.appYellow48) @@ -308,7 +301,6 @@ import Views struct HomeFeedGridView: View { @EnvironmentObject var dataService: DataService @Binding var selectedLinkItem: FeedItem? - @Binding var snoozePresented: Bool @Binding var itemToSnooze: FeedItem? @State private var itemToRemove: FeedItem? diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift index de7ac9a1d..a45956258 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewMac.swift @@ -12,7 +12,6 @@ import Views @State private var selectedLinkItem: FeedItem? @State private var itemToRemove: FeedItem? @State private var confirmationShown = false - @State private var snoozePresented = false @State private var itemToSnooze: FeedItem? @ObservedObject var viewModel: HomeFeedViewModel @@ -54,7 +53,7 @@ import Views if FeatureFlag.enableSnooze { Button { itemToSnooze = item - snoozePresented = true + viewModel.snoozePresented = true } label: { Label { Text("Snooze") } icon: { Image.moon } } diff --git a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift index 18ef3b6e7..af451e827 100644 --- a/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift +++ b/apple/OmnivoreKit/Sources/App/Views/Home/HomeFeedViewModel.swift @@ -16,6 +16,7 @@ final class HomeFeedViewModel: ObservableObject { @Published var showPushNotificationPrimer = false @Published var itemUnderLabelEdit: FeedItem? @Published var searchQuery = "" + @Published var snoozePresented = false var cursor: String? var sendProgressUpdates = false diff --git a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift index ab5196f5a..01e306528 100644 --- a/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift +++ b/apple/OmnivoreKit/Sources/Utils/FeatureFlags.swift @@ -13,7 +13,7 @@ public enum FeatureFlag { public static let enableRemindersFromShareExtension = false public static let enablePushNotifications = false public static let enableShareButton = false - public static let enableSnooze = false + public static let enableSnooze = true public static let enableLabels = true public static let useLocalWebView = true }