Skip to content

About screen sui #492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions TestApp/Sources/About/AboutSectionView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// Copyright 2024 Readium Foundation. All rights reserved.
// Use of this source code is governed by the BSD-style license
// available in the top-level LICENSE file of the project.
//

import SwiftUI

struct AboutSectionView<Content: View>: View {
enum Icon: String {
case app = "app.badge"
case circle = "c.circle"
case hands = "hands.sparkles"
}

private let title: String
private let icon: Icon
private var content: () -> Content

init(
title: String,
icon: Icon,
content: @escaping () -> Content
) {
self.title = title
self.icon = icon
self.content = content
}

var body: some View {
GroupBox {
content()
.padding(.top, 4)
} label: {
Label {
Text(title)
.bold()
} icon: {
Image(systemName: icon.rawValue)
}
.font(.title2)
}
}
}

#Preview {
AboutSectionView(title: "Version", icon: .app) {
VStack {
HStack {
Text("App Version:")
.foregroundColor(.gray)
Spacer()
Text("alpha-3.0")
.foregroundColor(.primary)
}

HStack(spacing: 10) {
Text("Build Version:")
.foregroundColor(.gray)
Spacer()
Text("alpha-3.0")
.foregroundColor(.primary)
}
}
}
.padding()
}
100 changes: 100 additions & 0 deletions TestApp/Sources/About/AboutView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
//
// Copyright 2024 Readium Foundation. All rights reserved.
// Use of this source code is governed by the BSD-style license
// available in the top-level LICENSE file of the project.
//

import SwiftUI

struct AboutView: View {
var body: some View {
ScrollView(showsIndicators: false) {
VStack(alignment: .center, spacing: 20) {
versionSection
copyrightSection
acknowledgementsSection
}
.padding(.horizontal, 16)
}
}

private var versionSection: some View {
AboutSectionView(
title: "Version",
icon: .app
) {
VStack {
HStack {
Text("App Version:")
.foregroundColor(.secondary)
Spacer()
Text(.appVersion ?? "")
.foregroundColor(.primary)
}

HStack(spacing: 10) {
Text("Build Version:")
.foregroundColor(.secondary)
Spacer()
Text(.buildVersion ?? "")
.foregroundColor(.primary)
}
}
}
}

private var copyrightSection: some View {
AboutSectionView(
title: "Copyright",
icon: .circle
) {
VStack(alignment: .leading) {
Link(destination: .edrlab) {
Text("© 2022 European Digital Reading Lab")
.multilineTextAlignment(.leading)
}

Link(destination: .license) {
Text("[BSD-3 License]")
.multilineTextAlignment(.leading)
}
}
.frame(maxWidth: .infinity, alignment: .leading)
}
}

private var acknowledgementsSection: some View {
AboutSectionView(
title: "Acknowledgements",
icon: .hands
) {
VStack(alignment: .center) {
Text("R2 Reader wouldn't have been developed without the financial help of the French State.")
.multilineTextAlignment(.center)
.foregroundColor(.primary)
Image("rf")
.resizable()
.scaledToFit()
.frame(width: 200)
.clipShape(RoundedRectangle(cornerRadius: 10))
}
}
}
}

struct About_Previews: PreviewProvider {
static var previews: some View {
AboutView()
}
}

private extension String {
static let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String

static let buildVersion = Bundle.main.infoDictionary?["CFBundleVersion"] as? String
}

private extension URL {
static let edrlab = URL(string: "https://www.edrlab.org/")!
static let license = URL(string: "https://opensource.org/licenses/BSD-3-Clause")!
}
Comment on lines +97 to +100
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

14 changes: 10 additions & 4 deletions TestApp/Sources/App/AppModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Combine
import Foundation
import ReadiumShared
import ReadiumStreamer
import SwiftUI
import UIKit

/// Base module delegate, that sub-modules' delegate can extend.
Expand Down Expand Up @@ -58,9 +59,10 @@ final class AppModule {
}

private(set) lazy var aboutViewController: UIViewController = {
let storyboard = UIStoryboard(name: "App", bundle: nil)
let aboutViewController = storyboard.instantiateViewController(withIdentifier: "AboutTableViewController") as! AboutTableViewController
return UINavigationController(rootViewController: aboutViewController)
let hostingController = UIHostingController(rootView: AboutView())
hostingController.navigationItem.title = "About the Readium Swift Toolkit"
hostingController.navigationItem.largeTitleDisplayMode = .never
return UINavigationController(rootViewController: hostingController)
}()
}

Expand Down Expand Up @@ -88,7 +90,11 @@ extension AppModule: LibraryModuleDelegate {
extension AppModule: ReaderModuleDelegate {}

extension AppModule: OPDSModuleDelegate {
func opdsDownloadPublication(_ publication: Publication?, at link: Link, sender: UIViewController) async throws -> Book {
func opdsDownloadPublication(
_ publication: Publication?,
at link: ReadiumShared.Link,
sender: UIViewController
) async throws -> Book {
guard let url = link.url(relativeTo: publication?.baseURL).absoluteURL else {
throw OPDSError.invalidURL(link.href)
}
Expand Down
Loading