mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-19 21:06:10 +00:00
Refactoring
This commit is contained in:
1 parent
093390084f
commit
d46b62d3de
10 files changed
+33
-61
No files matched your search
@@ -5,8 +5,9 @@
|
|||||||
// Created by Leon Böttger on 04.04.25.
|
// Created by Leon Böttger on 04.04.25.
|
||||||
//
|
//
|
||||||
|
|
||||||
import Foundation
|
|
||||||
import CryptoKit
|
import CryptoKit
|
||||||
|
import Foundation
|
||||||
|
import LUI
|
||||||
|
|
||||||
extension Data {
|
extension Data {
|
||||||
func urlSafeBase64EncodedString() -> String {
|
func urlSafeBase64EncodedString() -> String {
|
||||||
@@ -111,7 +112,11 @@ extension String {
|
|||||||
|
|
||||||
|
|
||||||
public func fullVersion() -> Bool {
|
public func fullVersion() -> Bool {
|
||||||
return Settings.sharedInstance.gotPlus
|
#if GITHUB
|
||||||
|
return true
|
||||||
|
#else
|
||||||
|
return IAPManager.sharedInstance.plusVersionState
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1739,8 +1739,8 @@
|
|||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SHARED_BUILD = 126;
|
SHARED_BUILD = 128;
|
||||||
SHARED_VERSION = 2.13.1;
|
SHARED_VERSION = 2.13.2;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
@@ -1802,8 +1802,8 @@
|
|||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
MTL_FAST_MATH = YES;
|
MTL_FAST_MATH = YES;
|
||||||
SDKROOT = macosx;
|
SDKROOT = macosx;
|
||||||
SHARED_BUILD = 126;
|
SHARED_BUILD = 128;
|
||||||
SHARED_VERSION = 2.13.1;
|
SHARED_VERSION = 2.13.2;
|
||||||
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
STRING_CATALOG_GENERATE_SYMBOLS = YES;
|
||||||
SWIFT_COMPILATION_MODE = wholemodule;
|
SWIFT_COMPILATION_MODE = wholemodule;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
"location" : "https://github.com/leonboe1/LUI.git",
|
"location" : "https://github.com/leonboe1/LUI.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"branch" : "main",
|
"branch" : "main",
|
||||||
"revision" : "24e35e2829f478d4219e82921302321dae6c1e78"
|
"revision" : "b1be835c12befddc3c5f678837a766d51db1bdc5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -87,8 +87,8 @@
|
|||||||
"kind" : "remoteSourceControl",
|
"kind" : "remoteSourceControl",
|
||||||
"location" : "https://github.com/apple/swift-protobuf.git",
|
"location" : "https://github.com/apple/swift-protobuf.git",
|
||||||
"state" : {
|
"state" : {
|
||||||
"revision" : "9bbb079b69af9d66470ced85461bf13bb40becac",
|
"revision" : "5596511fce902e649c403cd4d6d5da1254f142b7",
|
||||||
"version" : "1.35.0"
|
"version" : "1.35.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
private var sheetAttachedWindow: NSWindow? = nil
|
private var sheetAttachedWindow: NSWindow? = nil
|
||||||
private var errorAlertHandler = ErrorAlertHandler.shared
|
private var errorAlertHandler = ErrorAlertHandler.shared
|
||||||
|
|
||||||
private var iapManager: IAPManager?
|
|
||||||
private var receiveModel: ReceiveModel?
|
private var receiveModel: ReceiveModel?
|
||||||
|
|
||||||
var showsFirewallAlert = false
|
var showsFirewallAlert = false
|
||||||
@@ -35,11 +34,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
|
|
||||||
// MARK: NSApplicationDelegate functions
|
// MARK: NSApplicationDelegate functions
|
||||||
|
|
||||||
func applicationWillFinishLaunching(_: Notification) {
|
|
||||||
LUIInit(configuration: configuration)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_: Notification) {
|
func applicationDidFinishLaunching(_: Notification) {
|
||||||
|
|
||||||
let menu = NSMenu()
|
let menu = NSMenu()
|
||||||
@@ -73,26 +67,25 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
statusItem?.menu = menu
|
statusItem?.menu = menu
|
||||||
statusItem?.behavior = .removalAllowed
|
statusItem?.behavior = .removalAllowed
|
||||||
|
|
||||||
iapManager = IAPManager.sharedInstance
|
|
||||||
|
|
||||||
// app did not lauch before
|
// app did not lauch before
|
||||||
if !Settings.sharedInstance.appLaunchedBefore {
|
if !Settings.sharedInstance.appLaunchedBefore {
|
||||||
log("[AppDelegate] Opening Welcome Screen")
|
log("[AppDelegate] Opening Welcome Screen")
|
||||||
// open welcome screen
|
|
||||||
openMainWindow()
|
DispatchQueue.main.async {
|
||||||
|
// open welcome screen in next cycle (await LUIInit)
|
||||||
|
self.openMainWindow()
|
||||||
|
}
|
||||||
|
|
||||||
// user installed the app after the IAP was implemented, set the user as eligible for IAP
|
// user installed the app after the IAP was implemented, set the user as eligible for IAP
|
||||||
Settings.sharedInstance.isEligibleForIap = true
|
Settings.sharedInstance.isEligibleForIap = true
|
||||||
} else {
|
} else {
|
||||||
// app launched before
|
// app launched before
|
||||||
|
|
||||||
#if GITHUB
|
#if GITHUB
|
||||||
log("[AppDelegate] Downloaded from GitHub.")
|
log("[AppDelegate] Downloaded from GitHub.")
|
||||||
#else
|
#else
|
||||||
// user installed the app before the IAP was implemented, grant the plus version
|
// user installed the app before the IAP was implemented, grant the plus version
|
||||||
if !Settings.sharedInstance.isEligibleForIap {
|
if !Settings.sharedInstance.isEligibleForIap {
|
||||||
log("[AppDelegate] Granting QuickDrop+ for old user")
|
log("[AppDelegate] Granting QuickDrop+ for old user")
|
||||||
Settings.sharedInstance.gotPlus = true
|
|
||||||
UserDefaults.standard.set(true, forKey: Settings.UserDefaultsKeys.plusVersionLegacy.rawValue)
|
UserDefaults.standard.set(true, forKey: Settings.UserDefaultsKeys.plusVersionLegacy.rawValue)
|
||||||
} else {
|
} else {
|
||||||
if !fullVersion() {
|
if !fullVersion() {
|
||||||
@@ -110,6 +103,8 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
|||||||
startReceiving()
|
startReceiving()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LUIInit(configuration: configuration)
|
||||||
|
|
||||||
UNUserNotificationCenter.current().delegate = self
|
UNUserNotificationCenter.current().delegate = self
|
||||||
|
|
||||||
NearbyConnectionManager.shared.connectionUpdateCallback = { isConnected in
|
NearbyConnectionManager.shared.connectionUpdateCallback = { isConnected in
|
||||||
|
|||||||
@@ -13,14 +13,6 @@ let configuration = LUIConfiguration(
|
|||||||
|
|
||||||
plusVersionInfo: GetPlusViewInformation(lifetimeID: "plusversion", monthlyID: "quickdrop.monthly", yearlyID: "quickdrop.yearly", plusViewHeader: isMac() ? "plusview_title" : nil, description: isMac() ? "plusview_description" : "plusview_description_phone", onBoughtPlusVersionAlertMessage: "plusview_success_description", plusVersionFeatures: [], settingsLabelColor: .orange, settingsFooter: "plusview_footer_phone"),
|
plusVersionInfo: GetPlusViewInformation(lifetimeID: "plusversion", monthlyID: "quickdrop.monthly", yearlyID: "quickdrop.yearly", plusViewHeader: isMac() ? "plusview_title" : nil, description: isMac() ? "plusview_description" : "plusview_description_phone", onBoughtPlusVersionAlertMessage: "plusview_success_description", plusVersionFeatures: [], settingsLabelColor: .orange, settingsFooter: "plusview_footer_phone"),
|
||||||
|
|
||||||
setPlusVersion: { result in
|
|
||||||
#if !GITHUB
|
|
||||||
DispatchQueue.main.async {
|
|
||||||
Settings.sharedInstance.gotPlus = result
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
},
|
|
||||||
|
|
||||||
hasRoundedFont: false,
|
hasRoundedFont: false,
|
||||||
|
|
||||||
switchedToIAPafterBundleVersion: AppVersionBundle(appVersion: "1.2", buildVersion: 0, legacyUserDefaultsKey: Settings.UserDefaultsKeys.plusVersionLegacy.rawValue),
|
switchedToIAPafterBundleVersion: AppVersionBundle(appVersion: "1.2", buildVersion: 0, legacyUserDefaultsKey: Settings.UserDefaultsKeys.plusVersionLegacy.rawValue),
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
"en" : {
|
"en" : {
|
||||||
"stringUnit" : {
|
"stringUnit" : {
|
||||||
"state" : "new",
|
"state" : "new",
|
||||||
"value" : "QuickDropGitHub"
|
"value" : "QuickDrop"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,14 +17,6 @@ final class Settings: SharedInstance {
|
|||||||
|
|
||||||
// MARK: - Published UserDefaults Backed Properties
|
// MARK: - Published UserDefaults Backed Properties
|
||||||
|
|
||||||
#if GITHUB
|
|
||||||
let gotPlus = true
|
|
||||||
#else
|
|
||||||
@Published var gotPlus = UserDefaults.standard.bool(forKey: UserDefaultsKeys.plusVersion.rawValue)
|
|
||||||
{ didSet { UserDefaults.standard.set(gotPlus, forKey: UserDefaultsKeys.plusVersion.rawValue) }}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
@Published var automaticallyAcceptFiles: Bool = UserDefaults.standard.bool(forKey: UserDefaultsKeys.automaticallyAcceptFiles.rawValue)
|
@Published var automaticallyAcceptFiles: Bool = UserDefaults.standard.bool(forKey: UserDefaultsKeys.automaticallyAcceptFiles.rawValue)
|
||||||
{ didSet { UserDefaults.standard.set(automaticallyAcceptFiles, forKey: UserDefaultsKeys.automaticallyAcceptFiles.rawValue) }}
|
{ didSet { UserDefaults.standard.set(automaticallyAcceptFiles, forKey: UserDefaultsKeys.automaticallyAcceptFiles.rawValue) }}
|
||||||
|
|
||||||
@@ -76,7 +68,6 @@ final class Settings: SharedInstance {
|
|||||||
public enum UserDefaultsKeys: String, CaseIterable, RawRepresentable {
|
public enum UserDefaultsKeys: String, CaseIterable, RawRepresentable {
|
||||||
case isEligibleForIap = "isEligibleForIap"
|
case isEligibleForIap = "isEligibleForIap"
|
||||||
case appLaunchedBefore = "ShowedWelcomeScreen"
|
case appLaunchedBefore = "ShowedWelcomeScreen"
|
||||||
case plusVersion = "plusVersion"
|
|
||||||
case transmissionCount = "reviewRequestCountKey"
|
case transmissionCount = "reviewRequestCountKey"
|
||||||
case automaticallyAcceptFiles = "automaticallyAcceptFiles"
|
case automaticallyAcceptFiles = "automaticallyAcceptFiles"
|
||||||
case saveFolderBookmark = "saveFolderBookmark"
|
case saveFolderBookmark = "saveFolderBookmark"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ struct TutorialView: View {
|
|||||||
let openPlus: () -> Void
|
let openPlus: () -> Void
|
||||||
|
|
||||||
@State private var licenseWindow: NSWindow?
|
@State private var licenseWindow: NSWindow?
|
||||||
@ObservedObject var settings = Settings.sharedInstance
|
@ObservedObject var iapManager = IAPManager.sharedInstance
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
|
||||||
@@ -55,7 +55,8 @@ struct TutorialView: View {
|
|||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
|
|
||||||
if !settings.gotPlus {
|
#if !GITHUB
|
||||||
|
if !iapManager.plusVersionState {
|
||||||
Button {
|
Button {
|
||||||
openPlus()
|
openPlus()
|
||||||
} label: {
|
} label: {
|
||||||
@@ -66,8 +67,9 @@ struct TutorialView: View {
|
|||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Button {
|
Button {
|
||||||
Settings.sharedInstance.deleteAllUserDefaults()
|
Settings.sharedInstance.deleteAllUserDefaults()
|
||||||
} label: {
|
} label: {
|
||||||
@@ -77,7 +79,7 @@ struct TutorialView: View {
|
|||||||
.opacity(0.5)
|
.opacity(0.5)
|
||||||
}
|
}
|
||||||
.buttonStyle(.plain)
|
.buttonStyle(.plain)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import StoreKit
|
|||||||
struct ContentView: View {
|
struct ContentView: View {
|
||||||
|
|
||||||
@ObservedObject var luiSettings = LUISettings.sharedInstance
|
@ObservedObject var luiSettings = LUISettings.sharedInstance
|
||||||
@ObservedObject var settings = Settings.sharedInstance
|
@ObservedObject var iapManager = IAPManager.sharedInstance
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
AppRootView(isPlus: $settings.gotPlus, phoneView: {
|
AppRootView(phoneView: {
|
||||||
DeviceListView()
|
DeviceListView()
|
||||||
.environment(\.sheetActive, isShareExtension())
|
.environment(\.sheetActive, isShareExtension())
|
||||||
}, settingsView: {
|
}, settingsView: {
|
||||||
CustomSection(header: settings.gotPlus ? "" : "General", footer: "TrustedDevicesFooterShort") {
|
CustomSection(header: iapManager.plusVersionState ? "" : "General", footer: "TrustedDevicesFooterShort") {
|
||||||
LUIButton {
|
LUIButton {
|
||||||
FileManager.default.openDocumentFolder()
|
FileManager.default.openDocumentFolder()
|
||||||
} label: {
|
} label: {
|
||||||
@@ -46,13 +46,10 @@ struct DeviceListView: View {
|
|||||||
#if !EXTENSION
|
#if !EXTENSION
|
||||||
@StateObject var receiveModel = ReceiveModel(controlPlusScreen: { show in
|
@StateObject var receiveModel = ReceiveModel(controlPlusScreen: { show in
|
||||||
log("[DeviceListView] Setting showPlusScreen to \(show)")
|
log("[DeviceListView] Setting showPlusScreen to \(show)")
|
||||||
errorVibration()
|
presentPaywall()
|
||||||
DeviceListViewModel.sharedInstance.showPlusScreen = show
|
|
||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ObservedObject var model = DeviceListViewModel.sharedInstance
|
|
||||||
|
|
||||||
@Environment(\.scenePhase) var scenePhase
|
@Environment(\.scenePhase) var scenePhase
|
||||||
@Environment(\.sheetActive) var sheetActive
|
@Environment(\.sheetActive) var sheetActive
|
||||||
@ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared
|
@ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared
|
||||||
@@ -219,9 +216,6 @@ struct DeviceListView: View {
|
|||||||
NearbyConnectionManager.shared.stopDeviceDiscovery()
|
NearbyConnectionManager.shared.stopDeviceDiscovery()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if !EXTENSION
|
|
||||||
.modifier(PlusVersionSheetModifier(sheetActive: $model.showPlusScreen, isPlusVersion: $settings.gotPlus))
|
|
||||||
#endif
|
|
||||||
.animation(.smooth, value: nearbyConnectionManager.hasLocalNetworkPermission)
|
.animation(.smooth, value: nearbyConnectionManager.hasLocalNetworkPermission)
|
||||||
.animation(.smooth, value: nearbyConnectionManager.isConnectedToLocalNetwork)
|
.animation(.smooth, value: nearbyConnectionManager.isConnectedToLocalNetwork)
|
||||||
.navigationBarItems(trailing: ZStack {
|
.navigationBarItems(trailing: ZStack {
|
||||||
@@ -236,13 +230,6 @@ struct DeviceListView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final class DeviceListViewModel: SharedInstance {
|
|
||||||
static var sharedInstance = DeviceListViewModel()
|
|
||||||
|
|
||||||
@Published var showPlusScreen = false
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
struct DeviceFilePickerButton: View {
|
struct DeviceFilePickerButton: View {
|
||||||
|
|
||||||
let device: RemoteDeviceInfo
|
let device: RemoteDeviceInfo
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public struct LocalNetworkPermissionView: View {
|
|||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
|
|
||||||
PermissionView(title: "introduction_local_network_access", symbol: "", subtitle: "introduction_local_network_access_description".localized(with: "introduction_continue".localized()), permissionAction: {
|
PermissionView(title: "introduction_local_network_access", watchSymbol: "", subtitle: "introduction_local_network_access_description".localized(with: "introduction_continue".localized()), permissionAction: {
|
||||||
|
|
||||||
if requestedLocalNetworkAccess {
|
if requestedLocalNetworkAccess {
|
||||||
// Something went wrong, user pressed again on continue. In this case, just continue with setup
|
// Something went wrong, user pressed again on continue. In this case, just continue with setup
|
||||||
|
|||||||
Reference in new issue
Block a user