diff --git a/ApplicationLibrary/Views/Abstract/NavigationButtonsView.swift b/ApplicationLibrary/Views/Abstract/NavigationButtonsView.swift new file mode 100644 index 0000000..609d5d1 --- /dev/null +++ b/ApplicationLibrary/Views/Abstract/NavigationButtonsView.swift @@ -0,0 +1,60 @@ +import SwiftUI + +@MainActor +public struct NavigationButtonsView: View { + public let showGroupsButton: Bool + public let showConnectionsButton: Bool + public let groupsCount: Int + public let connectionsCount: Int + public let onGroupsTap: () -> Void + public let onConnectionsTap: () -> Void + + public init( + showGroupsButton: Bool, + showConnectionsButton: Bool, + groupsCount: Int, + connectionsCount: Int, + onGroupsTap: @escaping () -> Void, + onConnectionsTap: @escaping () -> Void + ) { + self.showGroupsButton = showGroupsButton + self.showConnectionsButton = showConnectionsButton + self.groupsCount = groupsCount + self.connectionsCount = connectionsCount + self.onGroupsTap = onGroupsTap + self.onConnectionsTap = onConnectionsTap + } + + public var body: some View { + HStack(spacing: 12) { + if showGroupsButton { + Divider() + Text(verbatim: "\(groupsCount)") + .font(.subheadline) + .foregroundStyle(.secondary) + .fixedSize() + Button { + onGroupsTap() + } label: { + Label("Groups", systemImage: "rectangle.3.group.fill") + } + .labelStyle(.iconOnly) + .foregroundStyle(.primary) + } + if showConnectionsButton { + Divider() + Text(verbatim: "\(connectionsCount)") + .font(.subheadline) + .foregroundStyle(.secondary) + .fixedSize() + Button { + onConnectionsTap() + } label: { + Label("Connections", systemImage: "list.bullet.rectangle.portrait.fill") + } + .labelStyle(.iconOnly) + .foregroundStyle(.primary) + } + } + } +} diff --git a/ApplicationLibrary/Views/Abstract/NavigationSheetContent.swift b/ApplicationLibrary/Views/Abstract/NavigationSheetContent.swift new file mode 100644 index 0000000..c086787 --- /dev/null +++ b/ApplicationLibrary/Views/Abstract/NavigationSheetContent.swift @@ -0,0 +1,48 @@ +import Library +import SwiftUI + +@MainActor +public struct SheetContent: View { + private let title: String + private let content: Content + + public init(_ title: String, @ViewBuilder content: () -> Content) { + self.title = title + self.content = content() + } + + public var body: some View { + #if os(iOS) || os(tvOS) + NavigationStackCompat { + content + .navigationTitle(title) + #if os(iOS) + .navigationBarTitleDisplayMode(.inline) + #endif + } + .presentationDetentsIfAvailable() + #endif + } +} + +@MainActor +public struct GroupsSheetContent: View { + public init() {} + + public var body: some View { + SheetContent("Groups") { + GroupListView() + } + } +} + +@MainActor +public struct ConnectionsSheetContent: View { + public init() {} + + public var body: some View { + SheetContent("Connections") { + ConnectionListView() + } + } +} diff --git a/ApplicationLibrary/Views/Abstract/ShareButton.swift b/ApplicationLibrary/Views/Abstract/ShareButton.swift index 467cc68..4cdbadd 100644 --- a/ApplicationLibrary/Views/Abstract/ShareButton.swift +++ b/ApplicationLibrary/Views/Abstract/ShareButton.swift @@ -58,6 +58,7 @@ public struct ShareButtonCompat