72 lines
2 KiB
Swift
72 lines
2 KiB
Swift
//
|
|
// MediaRow.swift
|
|
//
|
|
// Copyright 2026 Brendan Szymanski <hello@bscubed.dev>
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
|
|
import Adwaita
|
|
import Foundation
|
|
import LuminateCore
|
|
|
|
public struct MediaRow: View {
|
|
|
|
public var title: String
|
|
public var items: [Components.Schemas.BaseItemDto]
|
|
@Binding public var navigation: NavigationStack<Page>
|
|
public var onSeeAll: (() -> Void)?
|
|
|
|
public init(
|
|
title: String,
|
|
items: [Components.Schemas.BaseItemDto],
|
|
navigation: Binding<NavigationStack<Page>>,
|
|
onSeeAll: (() -> Void)? = nil
|
|
) {
|
|
self.title = title
|
|
self.items = items
|
|
_navigation = navigation
|
|
self.onSeeAll = onSeeAll
|
|
}
|
|
|
|
public var view: Body {
|
|
VStack(spacing: 16) {
|
|
HStack {
|
|
Text(title)
|
|
.title3()
|
|
|
|
/// Poor man's `Spacer()`
|
|
Bin()
|
|
.hexpand()
|
|
|
|
if let onSeeAll {
|
|
Button("See All") {
|
|
onSeeAll()
|
|
}
|
|
}
|
|
}
|
|
|
|
ScrollView {
|
|
ForEach(items, horizontal: true) { item in
|
|
HomePosterCell(item: item)
|
|
.padding(16, .trailing)
|
|
}
|
|
}
|
|
.vscrollbarPolicy(.never)
|
|
.hscrollbarPolicy(.external)
|
|
}
|
|
}
|
|
}
|