Minor fixes
This commit is contained in:
@@ -87,20 +87,26 @@ public func FormItem(_ title: String, @ViewBuilder content: () -> some View) ->
|
||||
#endif
|
||||
}
|
||||
|
||||
public func FormToggle(_ titleKey: LocalizedStringKey, _ subtitleKey: LocalizedStringKey, _ isOn: Binding<Bool>, _ action: @escaping (_ newValue: Bool) async -> Void) -> some View {
|
||||
public func FormToggle(_ titleKey: LocalizedStringKey, _ subtitleKey: LocalizedStringKey, _ isOn: Binding<Bool>, header: LocalizedStringKey? = nil, _ action: @escaping (_ newValue: Bool) async -> Void) -> some View {
|
||||
#if os(macOS)
|
||||
Toggle(isOn: isOn) {
|
||||
VStack(alignment: .leading) {
|
||||
Text(titleKey)
|
||||
Spacer()
|
||||
Text(subtitleKey)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
Section {
|
||||
Toggle(isOn: isOn) {
|
||||
VStack(alignment: .leading) {
|
||||
Text(titleKey)
|
||||
Spacer()
|
||||
Text(subtitleKey)
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
}
|
||||
}
|
||||
.onChangeCompat(of: isOn.wrappedValue) { newValue in
|
||||
Task {
|
||||
await action(newValue)
|
||||
.onChangeCompat(of: isOn.wrappedValue) { newValue in
|
||||
Task {
|
||||
await action(newValue)
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
if let header {
|
||||
Text(header)
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -111,6 +117,10 @@ public func FormToggle(_ titleKey: LocalizedStringKey, _ subtitleKey: LocalizedS
|
||||
await action(newValue)
|
||||
}
|
||||
}
|
||||
} header: {
|
||||
if let header {
|
||||
Text(header)
|
||||
}
|
||||
} footer: {
|
||||
Text(subtitleKey)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
|
||||
@@ -193,15 +193,6 @@ public struct GlobalChecksModifier: ViewModifier {
|
||||
}
|
||||
|
||||
#if os(tvOS)
|
||||
var state = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
dismissButton: .cancel(String(localized: "Ok"))
|
||||
)
|
||||
state.onDismiss = continueChain
|
||||
alert = state
|
||||
#else
|
||||
if report.migrationLink.isEmpty {
|
||||
var state = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
@@ -209,17 +200,26 @@ public struct GlobalChecksModifier: ViewModifier {
|
||||
)
|
||||
state.onDismiss = continueChain
|
||||
alert = state
|
||||
} else {
|
||||
alert = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
primaryButton: .default(String(localized: "Documentation")) {
|
||||
openURL(URL(string: report.migrationLink)!)
|
||||
},
|
||||
secondaryButton: .cancel(String(localized: "Ok")),
|
||||
onDismiss: continueChain
|
||||
)
|
||||
}
|
||||
#else
|
||||
if report.migrationLink.isEmpty {
|
||||
var state = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
dismissButton: .cancel(String(localized: "Ok"))
|
||||
)
|
||||
state.onDismiss = continueChain
|
||||
alert = state
|
||||
} else {
|
||||
alert = AlertState(
|
||||
title: String(localized: "Deprecated Warning"),
|
||||
message: report.message(),
|
||||
primaryButton: .default(String(localized: "Documentation")) {
|
||||
openURL(URL(string: report.migrationLink)!)
|
||||
},
|
||||
secondaryButton: .cancel(String(localized: "Ok")),
|
||||
onDismiss: continueChain
|
||||
)
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -3,10 +3,10 @@ import SwiftUI
|
||||
|
||||
@MainActor
|
||||
public struct SheetContent<Content: View>: View {
|
||||
private let title: String
|
||||
private let title: LocalizedStringKey
|
||||
private let content: Content
|
||||
|
||||
public init(_ title: String, @ViewBuilder content: () -> Content) {
|
||||
public init(_ title: LocalizedStringKey, @ViewBuilder content: () -> Content) {
|
||||
self.title = title
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ public struct CoreView: View {
|
||||
}
|
||||
|
||||
if Variant.isBeta {
|
||||
Section {}
|
||||
FormToggle("Disable Deprecated Warnings", "Do not show warnings about usages of deprecated features.", $disableDeprecatedWarnings) { newValue in
|
||||
FormToggle("Disable Deprecated Warnings", "Do not show warnings about usages of deprecated features.", $disableDeprecatedWarnings, header: "Beta Settings") {
|
||||
newValue in
|
||||
await SharedPreferences.disableDeprecatedWarnings.set(newValue)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,10 +139,4 @@ public enum SharedPreferences {
|
||||
|
||||
public static let enabledDashboardCards = Preference<[String]>("enabled_dashboard_cards", defaultValue: [])
|
||||
public static let dashboardCardOrder = Preference<[String]>("dashboard_card_order", defaultValue: [])
|
||||
|
||||
#if DEBUG
|
||||
public static let inDebug = true
|
||||
#else
|
||||
public static let inDebug = false
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -16,7 +16,13 @@ public enum Variant {
|
||||
public static let applicationName = "SFT"
|
||||
#endif
|
||||
|
||||
public static var isBeta = LibboxVersion().contains("-")
|
||||
public static let isBeta = LibboxVersion().contains("-")
|
||||
|
||||
#if DEBUG
|
||||
public static let inDebug = true
|
||||
#else
|
||||
public static let inDebug = false
|
||||
#endif
|
||||
|
||||
#if os(iOS)
|
||||
public static var debugNoIOS26 = false
|
||||
|
||||
@@ -32,7 +32,7 @@ open class ApplicationDelegate: NSObject, NSApplicationDelegate, UNUserNotificat
|
||||
event?.eventID == kAEOpenApplication &&
|
||||
event?.paramDescriptor(forKeyword: keyAEPropData)?.enumCodeValue == keyAELaunchedAsLogInItem
|
||||
let shouldShowWindow = Variant.screenshotMode ||
|
||||
SharedPreferences.inDebug ||
|
||||
Variant.inDebug ||
|
||||
!launchedAsLogInItem ||
|
||||
!SharedPreferences.showMenuBarExtra.getBlocking() ||
|
||||
!SharedPreferences.menuBarExtraInBackground.getBlocking()
|
||||
@@ -74,7 +74,7 @@ open class ApplicationDelegate: NSObject, NSApplicationDelegate, UNUserNotificat
|
||||
}
|
||||
|
||||
public func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool {
|
||||
SharedPreferences.inDebug || !SharedPreferences.menuBarExtraInBackground.getBlocking()
|
||||
Variant.inDebug || !SharedPreferences.menuBarExtraInBackground.getBlocking()
|
||||
}
|
||||
|
||||
public func applicationShouldHandleReopen(_: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
||||
|
||||
+10
-11
@@ -195,29 +195,28 @@ struct MainView: View {
|
||||
@ObservedObject var profile: ExtensionProfile
|
||||
|
||||
var body: some View {
|
||||
Text(statusText)
|
||||
statusText
|
||||
.font(.subheadline)
|
||||
.foregroundStyle(.secondary)
|
||||
.lineLimit(1)
|
||||
.fixedSize()
|
||||
}
|
||||
|
||||
private var statusText: String {
|
||||
private var statusText: Text {
|
||||
switch profile.status {
|
||||
case .invalid:
|
||||
return String(localized: "Invalid")
|
||||
case .disconnected:
|
||||
return String(localized: "Stopped")
|
||||
return Text("Stopped")
|
||||
case .connecting:
|
||||
return String(localized: "Starting")
|
||||
return Text("Starting")
|
||||
case .connected:
|
||||
return String(localized: "Started")
|
||||
return Text("Started")
|
||||
case .reasserting:
|
||||
return String(localized: "Reasserting")
|
||||
return Text("Reasserting")
|
||||
case .disconnecting:
|
||||
return String(localized: "Stopping")
|
||||
@unknown default:
|
||||
return String(localized: "Unknown")
|
||||
return Text("Stopping")
|
||||
default:
|
||||
return Text("Unknown")
|
||||
.foregroundColor(.red)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import MacLibrary
|
||||
class StandaloneApplicationDelegate: ApplicationDelegate {
|
||||
func applicationWillFinishLaunching(_: Notification) {
|
||||
Variant.useSystemExtension = true
|
||||
Variant.isBeta = false
|
||||
LibboxSetXPCDialer(CommandXPCDialer.shared)
|
||||
UserServiceEndpointPublisher.shared.start()
|
||||
Task {
|
||||
|
||||
@@ -2672,7 +2672,7 @@
|
||||
PRODUCT_NAME = "sing-box";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
@@ -2714,7 +2714,7 @@
|
||||
PRODUCT_NAME = "sing-box";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
SDKROOT = iphoneos;
|
||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
@@ -2755,7 +2755,7 @@
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
REEXPORTED_LIBRARY_PATHS = "";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
@@ -2794,7 +2794,7 @@
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
REEXPORTED_LIBRARY_PATHS = "";
|
||||
SDKROOT = macosx;
|
||||
SWIFT_EMIT_LOC_STRINGS = NO;
|
||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
|
||||
Reference in New Issue
Block a user