mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
remove apple waitlist code
This commit is contained in:
parent
53df427fcb
commit
a2b968f991
6 changed files with 23 additions and 215 deletions
|
|
@ -29,21 +29,6 @@ public final class RootViewModel: ObservableObject {
|
|||
registerFonts()
|
||||
}
|
||||
|
||||
func updateWaitlistStatus() {
|
||||
services.dataService.viewerPublisher().sink(
|
||||
receiveCompletion: { completion in
|
||||
guard case let .failure(error) = completion else { return }
|
||||
print(error)
|
||||
},
|
||||
receiveValue: { [weak self] viewer in
|
||||
guard let self = self else { return }
|
||||
let isWaitlisted = viewer.isWaitlisted
|
||||
self.services.authenticator.updateWaitlistStatus(isWaitlistedUser: isWaitlisted)
|
||||
}
|
||||
)
|
||||
.store(in: &subscriptions)
|
||||
}
|
||||
|
||||
func configurePDFProvider(pdfViewerProvider: @escaping (URL, PDFViewerViewModel) -> AnyView) {
|
||||
PDFProvider.pdfViewerProvider = { [weak self] url, feedItem in
|
||||
guard let self = self else { return AnyView(Text("")) }
|
||||
|
|
@ -163,34 +148,30 @@ public struct RootView: View {
|
|||
|
||||
@ViewBuilder private var innerBody: some View {
|
||||
if authenticator.isLoggedIn {
|
||||
if authenticator.isWaitlisted {
|
||||
WaitlistView(viewModel: WaitlistViewModel.make(services: viewModel.services))
|
||||
} else {
|
||||
PrimaryContentView(viewModel: primaryViewModel)
|
||||
.onAppear {
|
||||
viewModel.updateWaitlistStatus()
|
||||
viewModel.triggerPushNotificationRequestIfNeeded()
|
||||
PrimaryContentView(viewModel: primaryViewModel)
|
||||
.onAppear {
|
||||
viewModel.triggerPushNotificationRequestIfNeeded()
|
||||
}
|
||||
#if os(iOS)
|
||||
.fullScreenCover(item: $viewModel.webLinkPath, content: { safariLinkPath in
|
||||
NavigationView {
|
||||
FullScreenWebAppView(
|
||||
viewModel: viewModel.webAppWrapperViewModel(webLinkPath: safariLinkPath.path),
|
||||
handleClose: { viewModel.webLinkPath = nil }
|
||||
)
|
||||
}
|
||||
#if os(iOS)
|
||||
.fullScreenCover(item: $viewModel.webLinkPath, content: { safariLinkPath in
|
||||
NavigationView {
|
||||
FullScreenWebAppView(
|
||||
viewModel: viewModel.webAppWrapperViewModel(webLinkPath: safariLinkPath.path),
|
||||
handleClose: { viewModel.webLinkPath = nil }
|
||||
)
|
||||
}
|
||||
})
|
||||
#endif
|
||||
.snackBar(
|
||||
isShowing: $viewModel.showSnackbar,
|
||||
text: Text(viewModel.snackbarMessage ?? "")
|
||||
)
|
||||
#if os(iOS)
|
||||
.customAlert(isPresented: $viewModel.showPushNotificationPrimer) {
|
||||
pushNotificationPrimerView
|
||||
}
|
||||
#endif
|
||||
}
|
||||
})
|
||||
#endif
|
||||
.snackBar(
|
||||
isShowing: $viewModel.showSnackbar,
|
||||
text: Text(viewModel.snackbarMessage ?? "")
|
||||
)
|
||||
#if os(iOS)
|
||||
.customAlert(isPresented: $viewModel.showPushNotificationPrimer) {
|
||||
pushNotificationPrimerView
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
WelcomeView(viewModel: WelcomeViewModel.make(services: viewModel.services))
|
||||
.accessibilityElement()
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
import Models
|
||||
import Services
|
||||
import SwiftUI
|
||||
import Utils
|
||||
import Views
|
||||
|
||||
extension WaitlistViewModel {
|
||||
static func make(services: Services) -> WaitlistViewModel {
|
||||
let viewModel = WaitlistViewModel()
|
||||
viewModel.bind(services: services)
|
||||
return viewModel
|
||||
}
|
||||
|
||||
func bind(services: Services) {
|
||||
performActionSubject.sink { [weak self] action in
|
||||
switch action {
|
||||
case .logout:
|
||||
services.authenticator.logout()
|
||||
case .checkStatus:
|
||||
self?.updateWaitlistStatus(services: services)
|
||||
}
|
||||
}
|
||||
.store(in: &subscriptions)
|
||||
}
|
||||
|
||||
private func updateWaitlistStatus(services: Services) {
|
||||
services.dataService.viewerPublisher().sink(
|
||||
receiveCompletion: { completion in
|
||||
guard case let .failure(error) = completion else { return }
|
||||
print(error)
|
||||
},
|
||||
receiveValue: { viewer in
|
||||
let isWaitlisted = viewer.isWaitlisted
|
||||
services.authenticator.updateWaitlistStatus(isWaitlistedUser: isWaitlisted)
|
||||
}
|
||||
)
|
||||
.store(in: &subscriptions)
|
||||
}
|
||||
}
|
||||
|
|
@ -50,19 +50,16 @@ public struct Viewer {
|
|||
public let username: String
|
||||
public let name: String
|
||||
public let profileImageURL: String?
|
||||
public let isWaitlisted: Bool
|
||||
|
||||
public init(
|
||||
username: String,
|
||||
name: String,
|
||||
profileImageURL: String?,
|
||||
isWaitlisted: Bool,
|
||||
userID: String
|
||||
) {
|
||||
self.username = username
|
||||
self.name = name
|
||||
self.profileImageURL = profileImageURL
|
||||
self.isWaitlisted = isWaitlisted
|
||||
self.userID = userID
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ public final class Authenticator: ObservableObject {
|
|||
}
|
||||
|
||||
@Published public internal(set) var isLoggedIn: Bool
|
||||
@Published public internal(set) var isWaitlisted = false
|
||||
|
||||
let networker: Networker
|
||||
|
||||
|
|
@ -58,10 +57,6 @@ public final class Authenticator: ObservableObject {
|
|||
return !authToken.isEmpty
|
||||
}
|
||||
|
||||
public func updateWaitlistStatus(isWaitlistedUser: Bool) {
|
||||
isWaitlisted = isWaitlistedUser
|
||||
}
|
||||
|
||||
private func clearCookies() {
|
||||
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ extension DataService {
|
|||
profileImageURL: try $0.profile(
|
||||
selection: .init { try $0.pictureUrl() }
|
||||
),
|
||||
isWaitlisted: try !($0.isFullUser() ?? false),
|
||||
userID: try $0.id()
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,125 +0,0 @@
|
|||
import Combine
|
||||
import Models
|
||||
import SwiftUI
|
||||
|
||||
public final class WaitlistViewModel: ObservableObject {
|
||||
public enum Action {
|
||||
case logout
|
||||
case checkStatus
|
||||
}
|
||||
|
||||
public var subscriptions = Set<AnyCancellable>()
|
||||
public let performActionSubject = PassthroughSubject<Action, Never>()
|
||||
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public struct WaitlistView: View {
|
||||
@Environment(\.horizontalSizeClass) var horizontalSizeClass
|
||||
@ObservedObject private var viewModel: WaitlistViewModel
|
||||
|
||||
public init(viewModel: WaitlistViewModel) {
|
||||
self.viewModel = viewModel
|
||||
}
|
||||
|
||||
@ViewBuilder func userInteractiveView(width: CGFloat) -> some View {
|
||||
waitlistButtonView
|
||||
.frame(width: width)
|
||||
.zIndex(2)
|
||||
}
|
||||
|
||||
var titleLogo: some View {
|
||||
Image.omnivoreTitleLogo
|
||||
.renderingMode(.template)
|
||||
.foregroundColor(.appGrayTextContrast)
|
||||
.frame(height: 40)
|
||||
}
|
||||
|
||||
var waitlistButtonView: some View {
|
||||
VStack(alignment: .center, spacing: 32) {
|
||||
Text("Your username has been reserved. We will inform you by email when we open up Omnivore to more users.")
|
||||
.font(.appHeadline)
|
||||
.multilineTextAlignment(.center)
|
||||
.frame(maxWidth: 300)
|
||||
|
||||
BorderedButton(color: .appGrayTextContrast, text: "Check Status") {
|
||||
viewModel.performActionSubject.send(.checkStatus)
|
||||
}
|
||||
.frame(width: 220)
|
||||
|
||||
BorderedButton(color: .appGrayTextContrast, text: "Logout") {
|
||||
viewModel.performActionSubject.send(.logout)
|
||||
}
|
||||
.frame(width: 220)
|
||||
}
|
||||
.padding(.horizontal, horizontalSizeClass == .compact ? 16 : 80)
|
||||
.padding(.top, horizontalSizeClass == .compact ? 16 : 0)
|
||||
}
|
||||
|
||||
@ViewBuilder func splitColorBackground(width: CGFloat) -> some View {
|
||||
HStack(spacing: 0) {
|
||||
Color.systemBackground.frame(width: width * 0.5)
|
||||
Color.appBackground.frame(width: width * 0.5)
|
||||
}
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
|
||||
@ViewBuilder func largeBackgroundImage(width: CGFloat) -> some View {
|
||||
Image.readingIllustrationXXL
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fill)
|
||||
.frame(width: width)
|
||||
.clipped()
|
||||
.edgesIgnoringSafeArea([.vertical, .trailing])
|
||||
}
|
||||
|
||||
@ViewBuilder func primaryContent() -> some View {
|
||||
if horizontalSizeClass == .compact {
|
||||
GeometryReader { geometry in
|
||||
ZStack(alignment: .leading) {
|
||||
Color.systemBackground
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
|
||||
if geometry.size.width < geometry.size.height {
|
||||
VStack {
|
||||
Color.appDeepBackground.frame(height: 100)
|
||||
Spacer()
|
||||
}
|
||||
.edgesIgnoringSafeArea(.all)
|
||||
}
|
||||
|
||||
VStack {
|
||||
if geometry.size.width < geometry.size.height {
|
||||
RegistrationHeroImageView(
|
||||
tapGestureHandler: {}
|
||||
)
|
||||
}
|
||||
userInteractiveView(width: geometry.size.width)
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
GeometryReader { geometry in
|
||||
ZStack(alignment: .leading) {
|
||||
splitColorBackground(width: geometry.size.width)
|
||||
|
||||
VStack {
|
||||
titleLogo
|
||||
Spacer()
|
||||
}
|
||||
.padding()
|
||||
|
||||
HStack(spacing: 0) {
|
||||
userInteractiveView(width: geometry.size.width * 0.5)
|
||||
largeBackgroundImage(width: geometry.size.width * 0.5)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var body: some View {
|
||||
primaryContent()
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue