From d0e541910b7c9c0378bc939e2775702b5eb7bdab Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Sun, 4 Jan 2026 18:15:20 -0600 Subject: [PATCH] Refactor to use Bedrock's LicensesView with License model --- .../Features/Settings/LicensesView.swift | 85 +++++++------------ .../Features/Settings/SettingsView.swift | 2 +- 2 files changed, 30 insertions(+), 57 deletions(-) diff --git a/SelfieCam/Features/Settings/LicensesView.swift b/SelfieCam/Features/Settings/LicensesView.swift index ca5fb61..edba66e 100644 --- a/SelfieCam/Features/Settings/LicensesView.swift +++ b/SelfieCam/Features/Settings/LicensesView.swift @@ -8,63 +8,36 @@ import SwiftUI import Bedrock -// MARK: - Licenses View +// MARK: - App Licenses -struct LicensesView: View { +extension License { + /// All open source licenses used in SelfieCam + static let appLicenses: [License] = [ + License( + name: "MijickCamera", + url: "https://github.com/Mijick/Camera", + licenseType: "Apache 2.0 License", + description: "Camera framework for SwiftUI. Created by Tomasz Kurylik at Mijick." + ), + License( + name: "RevenueCat", + url: "https://github.com/RevenueCat/purchases-ios", + licenseType: "MIT License", + description: "In-app subscriptions made easy." + ) + ] +} + +// MARK: - App Licenses View + +struct AppLicensesView: View { var body: some View { - ScrollView { - VStack(alignment: .leading, spacing: Design.Spacing.large) { - // MijickCamera - licenseCard( - name: "MijickCamera", - url: "https://github.com/Mijick/Camera", - license: "Apache 2.0 License", - description: "Camera framework for SwiftUI. Created by Tomasz Kurylik at Mijick." - ) - - // RevenueCat - licenseCard( - name: "RevenueCat", - url: "https://github.com/RevenueCat/purchases-ios", - license: "MIT License", - 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 { - 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) - .font(.system(size: Design.BaseFontSize.caption)) - .foregroundStyle(.white.opacity(Design.Opacity.strong)) - - HStack { - Label(license, systemImage: "doc.text") - .font(.system(size: Design.BaseFontSize.xSmall)) - .foregroundStyle(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) - } - } + LicensesView( + licenses: License.appLicenses, + backgroundColor: AppSurface.overlay, + cardBackgroundColor: AppSurface.card, + cardBorderColor: AppBorder.subtle, + accentColor: AppAccent.primary + ) } } diff --git a/SelfieCam/Features/Settings/SettingsView.swift b/SelfieCam/Features/Settings/SettingsView.swift index 0a70cff..af562cb 100644 --- a/SelfieCam/Features/Settings/SettingsView.swift +++ b/SelfieCam/Features/Settings/SettingsView.swift @@ -533,7 +533,7 @@ struct SettingsView: View { subtitle: String(localized: "Third-party libraries used in this app"), backgroundColor: .clear ) { - LicensesView() + AppLicensesView() } }