Improve dashboard
This commit is contained in:
@@ -1,9 +1,9 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Library
|
import Library
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
#if canImport(UIKit)
|
#if os(iOS)
|
||||||
import UIKit
|
import UIKit
|
||||||
#elseif canImport(AppKit)
|
#elseif os(macOS)
|
||||||
import AppKit
|
import AppKit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ public struct ShareButtonCompat<Label>: View where Label: View {
|
|||||||
|
|
||||||
@Binding private var alert: Alert?
|
@Binding private var alert: Alert?
|
||||||
|
|
||||||
#if canImport(AppKit)
|
#if os(macOS)
|
||||||
@State private var sharePresented = false
|
@State private var sharePresented = false
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -55,22 +55,22 @@ public struct ShareButtonCompat<Label>: View where Label: View {
|
|||||||
|
|
||||||
public var body: some View {
|
public var body: some View {
|
||||||
Button(action: shareItem, label: label)
|
Button(action: shareItem, label: label)
|
||||||
#if canImport(AppKit)
|
#if os(macOS)
|
||||||
.background(SharingServicePicker($sharePresented, $alert, itemURL))
|
.background(SharingServicePicker($sharePresented, $alert, itemURL))
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private func shareItem() {
|
private func shareItem() {
|
||||||
#if canImport(UIKit)
|
#if os(iOS)
|
||||||
Task.detached {
|
Task.detached {
|
||||||
shareItem0()
|
shareItem0()
|
||||||
}
|
}
|
||||||
#elseif canImport(AppKit)
|
#elseif os(macOS)
|
||||||
sharePresented = true
|
sharePresented = true
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if canImport(UIKit)
|
#if os(iOS)
|
||||||
private func shareItem0() {
|
private func shareItem0() {
|
||||||
do {
|
do {
|
||||||
let shareItem = try itemURL()
|
let shareItem = try itemURL()
|
||||||
@@ -86,13 +86,13 @@ public struct ShareButtonCompat<Label>: View where Label: View {
|
|||||||
|
|
||||||
private func shareItem1(_ item: URL) {
|
private func shareItem1(_ item: URL) {
|
||||||
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
|
if let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
|
||||||
try windowScene.keyWindow?.rootViewController?.present(UIActivityViewController(activityItems: [item], applicationActivities: nil), animated: true, completion: nil)
|
windowScene.keyWindow?.rootViewController?.present(UIActivityViewController(activityItems: [item], applicationActivities: nil), animated: true, completion: nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if canImport(AppKit)
|
#if os(macOS)
|
||||||
private struct SharingServicePicker: NSViewRepresentable {
|
private struct SharingServicePicker: NSViewRepresentable {
|
||||||
@Binding private var isPresented: Bool
|
@Binding private var isPresented: Bool
|
||||||
@Binding private var alert: Alert?
|
@Binding private var alert: Alert?
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public struct ExtensionStatusView: View {
|
|||||||
StatusLine("Uplink", "\(LibboxFormatBytes(message.uplink))/s")
|
StatusLine("Uplink", "\(LibboxFormatBytes(message.uplink))/s")
|
||||||
StatusLine("Downlink", "\(LibboxFormatBytes(message.downlink))/s")
|
StatusLine("Downlink", "\(LibboxFormatBytes(message.downlink))/s")
|
||||||
}
|
}
|
||||||
StatusItem("TrafficTotal") {
|
StatusItem("Traffic Total") {
|
||||||
StatusLine("Uplink", LibboxFormatBytes(message.uplinkTotal))
|
StatusLine("Uplink", LibboxFormatBytes(message.uplinkTotal))
|
||||||
StatusLine("Downlink", LibboxFormatBytes(message.downlinkTotal))
|
StatusLine("Downlink", LibboxFormatBytes(message.downlinkTotal))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public struct GroupItemView: View {
|
|||||||
}
|
}
|
||||||
Spacer(minLength: 8)
|
Spacer(minLength: 8)
|
||||||
HStack {
|
HStack {
|
||||||
Text(item.type)
|
Text(item.displayType)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
Spacer(minLength: 0)
|
Spacer(minLength: 0)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
import Libbox
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
public struct OutboundGroup: Codable {
|
public struct OutboundGroup: Codable {
|
||||||
@@ -20,13 +21,6 @@ public struct OutboundGroup: Codable {
|
|||||||
|
|
||||||
public extension OutboundGroup {
|
public extension OutboundGroup {
|
||||||
var displayType: String {
|
var displayType: String {
|
||||||
switch type {
|
LibboxProxyDisplayType(type)
|
||||||
case "selector":
|
|
||||||
return "Selector"
|
|
||||||
case "urltest":
|
|
||||||
return "URLTest"
|
|
||||||
default:
|
|
||||||
return "Unknown"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
import Libbox
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
public struct OutboundGroupItem: Codable {
|
public struct OutboundGroupItem: Codable {
|
||||||
@@ -10,6 +11,10 @@ public struct OutboundGroupItem: Codable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public extension OutboundGroupItem {
|
public extension OutboundGroupItem {
|
||||||
|
var displayType: String {
|
||||||
|
LibboxProxyDisplayType(type)
|
||||||
|
}
|
||||||
|
|
||||||
var delayString: String {
|
var delayString: String {
|
||||||
"\(urlTestDelay)ms"
|
"\(urlTestDelay)ms"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<key>ApplicationLibrary.xcscheme_^#shared#^_</key>
|
<key>ApplicationLibrary.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>5</integer>
|
<integer>6</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>Associations (Playground) 1.xcscheme</key>
|
<key>Associations (Playground) 1.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
<key>MacLibrary.xcscheme_^#shared#^_</key>
|
<key>MacLibrary.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>2</integer>
|
<integer>5</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>MessageExtension.xcscheme_^#shared#^_</key>
|
<key>MessageExtension.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
<key>SFM.System.xcscheme_^#shared#^_</key>
|
<key>SFM.System.xcscheme_^#shared#^_</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>orderHint</key>
|
<key>orderHint</key>
|
||||||
<integer>6</integer>
|
<integer>2</integer>
|
||||||
</dict>
|
</dict>
|
||||||
<key>SFM.xcscheme</key>
|
<key>SFM.xcscheme</key>
|
||||||
<dict>
|
<dict>
|
||||||
|
|||||||
Reference in New Issue
Block a user