Merge pull request #645 from omnivore-app/read-now-pending-button

Move the read now button, add a pending state
This commit is contained in:
Satindar Dhillon
2022-05-18 09:19:25 -07:00
committed by GitHub
4 changed files with 37 additions and 29 deletions

View File

@ -22,7 +22,7 @@ public extension PlatformViewController {
final class ShareExtensionViewModel: ObservableObject {
@Published var title: String?
@Published var status = ShareExtensionStatus.successfullySaved
@Published var status = ShareExtensionStatus.processing
@Published var debugText: String?
var subscriptions = Set<AnyCancellable>()
@ -75,7 +75,7 @@ final class ShareExtensionViewModel: ObservableObject {
self?.debugText = "saveArticleError: \(error)"
self?.status = .failed(error: error)
} receiveValue: { [weak self] _ in
self?.status = .successfullySaved
self?.status = .success
}
.store(in: &subscriptions)

View File

@ -10,6 +10,7 @@ public enum FeatureFlag {
public static let showAccountDeletion = false
public static let enableSnoozeFromShareExtension = false
public static let enableRemindersFromShareExtension = false
public static let enableReadNow = false
public static let enablePushNotifications = false
public static let enableShareButton = false
public static let enableSnooze = false

View File

@ -13,7 +13,6 @@ public enum LocalText {
static let networkError = localText(key: "error.network")
static let genericError = localText(key: "error.generic")
static let invalidCredsLoginError = localText(key: "loginError.invalidCreds")
static let saveArticleSavingState = localText(key: "saveArticleSavingState")
static let saveArticleSavedState = localText(key: "saveArticleSavedState")
static let saveArticleProcessingState = localText(key: "saveArticleProcessingState")
static let extensionAppUnauthorized = localText(key: "extensionAppUnauthorized")

View File

@ -3,16 +3,13 @@ import SwiftUI
import Utils
public enum ShareExtensionStatus {
case saving
case processing
case successfullySaved
case success
case failed(error: SaveArticleError)
var displayMessage: String {
switch self {
case .saving:
return LocalText.saveArticleSavingState
case .successfullySaved:
case .success:
return LocalText.saveArticleSavedState
case let .failed(error: error):
return error.displayMessage
@ -140,19 +137,17 @@ public struct ShareExtensionChildView: View {
Spacer()
if case ShareExtensionStatus.successfullySaved = status {
HStack {
Spacer()
IconButtonView(
title: "Read Now",
systemIconName: "book",
action: {
readNowButtonAction()
}
)
Spacer()
if case ShareExtensionStatus.success = status {
HStack(spacing: 4) {
Text("Saved to Omnivore")
.font(.appTitleThree)
.foregroundColor(.appGrayText)
.padding(.trailing, 16)
.multilineTextAlignment(.center)
.fixedSize(horizontal: false, vertical: true)
.lineLimit(nil)
}
.padding(.horizontal, 8)
.padding()
} else if case let ShareExtensionStatus.failed(error) = status {
HStack {
Spacer()
@ -207,16 +202,29 @@ public struct ShareExtensionChildView: View {
}
.padding(.horizontal)
Button(
action: {
dismissButtonTappedAction(reminderTime, hideUntilReminded)
},
label: {
Text("Dismiss")
.frame(maxWidth: .infinity)
HStack {
if case ShareExtensionStatus.success = status, FeatureFlag.enableReadNow {
Button(
action: { readNowButtonAction() },
label: { Text("Read Now").frame(maxWidth: .infinity) }
)
.buttonStyle(RoundedRectButtonStyle())
}
)
.buttonStyle(RoundedRectButtonStyle())
if case ShareExtensionStatus.processing = status, FeatureFlag.enableReadNow {
Button(action: {}, label: { ProgressView().frame(maxWidth: .infinity) })
.buttonStyle(RoundedRectButtonStyle())
}
Button(
action: {
dismissButtonTappedAction(reminderTime, hideUntilReminded)
},
label: {
Text("Dismiss")
.frame(maxWidth: .infinity)
}
)
.buttonStyle(RoundedRectButtonStyle())
}
.padding(.horizontal)
.padding(.bottom)
}