Refactor to use Bedrock's LicensesView with License model

This commit is contained in:
Matt Bruce 2026-01-04 18:15:20 -06:00
parent 44512e923c
commit d0e541910b
2 changed files with 30 additions and 57 deletions

View File

@ -8,63 +8,36 @@
import SwiftUI import SwiftUI
import Bedrock import Bedrock
// MARK: - Licenses View // MARK: - App Licenses
struct LicensesView: View { extension License {
var body: some View { /// All open source licenses used in SelfieCam
ScrollView { static let appLicenses: [License] = [
VStack(alignment: .leading, spacing: Design.Spacing.large) { License(
// MijickCamera
licenseCard(
name: "MijickCamera", name: "MijickCamera",
url: "https://github.com/Mijick/Camera", url: "https://github.com/Mijick/Camera",
license: "Apache 2.0 License", licenseType: "Apache 2.0 License",
description: "Camera framework for SwiftUI. Created by Tomasz Kurylik at Mijick." description: "Camera framework for SwiftUI. Created by Tomasz Kurylik at Mijick."
) ),
License(
// RevenueCat
licenseCard(
name: "RevenueCat", name: "RevenueCat",
url: "https://github.com/RevenueCat/purchases-ios", url: "https://github.com/RevenueCat/purchases-ios",
license: "MIT License", licenseType: "MIT License",
description: "In-app subscriptions made easy." description: "In-app subscriptions made easy."
) )
} ]
.padding(Design.Spacing.large)
}
.background(AppSurface.overlay)
.navigationTitle(String(localized: "Open Source Licenses"))
.navigationBarTitleDisplayMode(.inline)
} }
private func licenseCard(name: String, url: String, license: String, description: String) -> some View { // MARK: - App Licenses View
SettingsCard(backgroundColor: AppSurface.card, borderColor: AppBorder.subtle) {
VStack(alignment: .leading, spacing: Design.Spacing.small) {
Text(name)
.font(.system(size: Design.BaseFontSize.medium, weight: .bold))
.foregroundStyle(.white)
Text(description) struct AppLicensesView: View {
.font(.system(size: Design.BaseFontSize.caption)) var body: some View {
.foregroundStyle(.white.opacity(Design.Opacity.strong)) LicensesView(
licenses: License.appLicenses,
HStack { backgroundColor: AppSurface.overlay,
Label(license, systemImage: "doc.text") cardBackgroundColor: AppSurface.card,
.font(.system(size: Design.BaseFontSize.xSmall)) cardBorderColor: AppBorder.subtle,
.foregroundStyle(AppAccent.primary) accentColor: AppAccent.primary
)
Spacer()
if let linkURL = URL(string: url) {
Link(destination: linkURL) {
Label(String(localized: "View on GitHub"), systemImage: "arrow.up.right.square")
.font(.system(size: Design.BaseFontSize.xSmall))
.foregroundStyle(AppAccent.primary)
}
}
}
.padding(.top, Design.Spacing.xSmall)
}
}
} }
} }

View File

@ -533,7 +533,7 @@ struct SettingsView: View {
subtitle: String(localized: "Third-party libraries used in this app"), subtitle: String(localized: "Third-party libraries used in this app"),
backgroundColor: .clear backgroundColor: .clear
) { ) {
LicensesView() AppLicensesView()
} }
} }