Skip to content

Commit

Permalink
Added notification settings support on macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
MadeiraAlexandre committed Nov 22, 2023
1 parent 7c697fb commit 11ead0a
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 174 deletions.
11 changes: 7 additions & 4 deletions CronicaWidget/Views/ItemContentList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ private struct PosterImage: View {
.resizable()
.aspectRatio(contentMode: .fill)
#elseif os(macOS)
Image(nsImage: (NSImage(data: image) ?? NSImage(systemSymbolName: "popcorn.fill", accessibilityDescription: "")) ?? "")
.resizable()
.aspectRatio(contentMode: .fill)

if let nsImage = NSImage(data: image) {
Image(nsImage: nsImage)
.resizable()
.aspectRatio(contentMode: .fill)
} else {
Image(systemName: "popcorn.fill")
}
#endif
} else {
PlaceholderImage()
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ You can also download the latest beta from <a href="https://testflight.apple.com

## Contact

If you any question, you can send me an email at <a href = "mailto: [email protected]"> [email protected]</a>, I'll try to answer as quick as I can.<br>
I'm also availabe at iMessage, you can send a message at the same email address above.<br>
Follow me on Twitter: [_alexMadeira](https://twitter.com/_alexMadeira).
- If you any question, you can send me an email at <a href = "mailto: [email protected]"> [email protected]</a>, I'll try to answer as quick as I can.<br>
- I'm also availabe at iMessage, you can send a message at the **same email address above**.<br>
- Follow Cronica on Twitter: [CronicaApp](https://twitter.com/CronicaApp).

20 changes: 13 additions & 7 deletions Shared/Manager/CronicaTelemetry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

import Foundation
import os
import TelemetryClient
#if os(macOS) || os(tvOS)
#if !os(iOS)
import Aptabase
#else
import TelemetryClient
#endif

struct CronicaTelemetry {
Expand All @@ -23,23 +24,26 @@ struct CronicaTelemetry {

func setup() {
#if !targetEnvironment(simulator) || !DEBUG
guard let key = Key.telemetryClientKey else { return }
let configuration = TelemetryManagerConfiguration(appID: key)
TelemetryManager.initialize(with: configuration)
#if !os(iOS)
guard let aptabaseKey = Key.aptabaseClientKey else { return }
Aptabase.shared.initialize(appKey: aptabaseKey)
Aptabase.shared.trackEvent("app_started")
#else
guard let key = Key.telemetryClientKey else { return }
let configuration = TelemetryManagerConfiguration(appID: key)
TelemetryManager.initialize(with: configuration)
#endif
#endif
}

/// Send a signal using TelemetryDeck service.
/// Send a signal using TelemetryDeck service (on iOS/iPadOS) or in Aptabase (macOS, watchOS, tvOS).
///
/// If it is running in Simulator or Debug, it will send a warning on logger.
func handleMessage(_ message: String, for id: String) {
#if targetEnvironment(simulator) || DEBUG
logger.warning("\(message), for: \(id)")
#else
#if os(tvOS) || os(macOS)
#if !os(iOS)
Aptabase.shared.trackEvent(id, with: ["Message": message])
#else
if TelemetryManager.isInitialized {
Expand All @@ -49,7 +53,9 @@ struct CronicaTelemetry {
#endif
}

#if os(iOS)
var isTelemetryDeckInitialized: String {
return TelemetryManager.isInitialized.description
}
#endif
}
10 changes: 8 additions & 2 deletions Shared/Store/SettingsStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,15 @@ class SettingsStore: ObservableObject {
@AppStorage("primaryRightSwipe") var primaryRightSwipe: SwipeGestureOptions = .delete
@AppStorage("secondaryRightSwipe") var secondaryRightSwipe: SwipeGestureOptions = .markArchive
@AppStorage("allowFullSwipe") var allowFullSwipe = false
#if os(macOS)
@AppStorage("allowNotifications") var allowNotifications = false
@AppStorage("notifyMovies") var notifyMovieRelease = false
@AppStorage("notifyTVShows") var notifyNewEpisodes = false
#else
@AppStorage("allowNotifications") var allowNotifications = true
@AppStorage("notifyMovies") var notifyMovieRelease = true
@AppStorage("notifyTVShows") var notifyNewEpisodes = true
#endif
@AppStorage("userHasPurchasedTipJar") var hasPurchasedTipJar = false
#if os(tvOS)
@AppStorage("itemContentListDisplayType") var listsDisplayType: ItemContentListPreferredDisplayType = .card
Expand Down Expand Up @@ -76,7 +82,7 @@ class SettingsStore: ObservableObject {
@AppStorage("preferCoverOnUpNext") var preferCoverOnUpNext = false
@AppStorage("markUpNextWatchedOnTap") var markWatchedOnTapUpNext = false
@AppStorage("confirmationForMarkOnTapUpNext") var askForConfirmationUpNext = true
#if os(macOS)
#if os(macOS)
@AppStorage("showMenuBarApp") var showMenuBarApp = true
#endif
#endif
}
Loading

0 comments on commit 11ead0a

Please sign in to comment.