Use resizable sidebar layout for Subscriptions on macOS

Replaces the iOS-style floating channel strip with a dedicated
channels column next to the feed, using HSplitView for a native
draggable divider. Mirrors the tvOS two-column structure.
This commit is contained in:
Arkadiusz Fal
2026-04-19 15:04:21 +02:00
parent 68890b1f8a
commit 5e205e4a4c
2 changed files with 165 additions and 3 deletions

View File

@@ -0,0 +1,77 @@
//
// MacSubscriptionsSidebarRow.swift
// Yattee
//
// Compact row used in the macOS Subscriptions sidebar for the
// "All Channels" entry and each subscribed channel.
//
#if os(macOS)
import SwiftUI
import NukeUI
struct MacSubscriptionsSidebarRow: View {
let name: String
let avatarURL: URL?
let serverURL: URL?
let authHeader: String?
let channelID: String?
let isAllChannels: Bool
private let avatarSize: CGFloat = 28
private var effectiveAvatarURL: URL? {
guard let channelID else { return nil }
return AvatarURLBuilder.avatarURL(
channelID: channelID,
directURL: avatarURL,
serverURL: serverURL,
size: Int(avatarSize * 2)
)
}
var body: some View {
HStack(spacing: 8) {
avatar
.frame(width: avatarSize, height: avatarSize)
.clipShape(Circle())
Text(name)
.lineLimit(1)
Spacer(minLength: 0)
}
.contentShape(Rectangle())
}
@ViewBuilder
private var avatar: some View {
if isAllChannels {
ZStack {
Circle().fill(.quaternary)
Image(systemName: "rectangle.stack.fill")
.resizable()
.aspectRatio(contentMode: .fit)
.foregroundStyle(.secondary)
.padding(avatarSize * 0.25)
}
} else {
LazyImage(request: AvatarURLBuilder.imageRequest(url: effectiveAvatarURL, authHeader: authHeader)) { state in
if let image = state.image {
image
.resizable()
.aspectRatio(contentMode: .fill)
} else {
Circle()
.fill(.quaternary)
.overlay {
Text(String(name.prefix(1)))
.font(.caption)
.foregroundStyle(.secondary)
}
}
}
}
}
}
#endif