From b3f222e316d78901341bf549dabf0ba7d5e07a90 Mon Sep 17 00:00:00 2001 From: Ira Limitanei Date: Fri, 16 Jan 2026 10:30:19 +0900 Subject: [PATCH] Extract about dialog conf options to separate file --- .../Adwaita/View/Dialogs/AboutDialog.swift | 63 ++++--------------- 1 file changed, 13 insertions(+), 50 deletions(-) diff --git a/Sources/Adwaita/View/Dialogs/AboutDialog.swift b/Sources/Adwaita/View/Dialogs/AboutDialog.swift index 106fdde..7cccbc1 100644 --- a/Sources/Adwaita/View/Dialogs/AboutDialog.swift +++ b/Sources/Adwaita/View/Dialogs/AboutDialog.swift @@ -15,19 +15,8 @@ struct AboutDialog: AdwaitaWidget { @Binding var visible: Bool /// The wrapped view. var child: AnyView - - /// The app's name. - var appName: String? - /// The developer's name. - var developer: String? - /// The app version. - var version: String? - /// The app icon. - var icon: Icon? - /// The app's website. - var website: URL? - /// The link for opening issues. - var issues: URL? + /// The dialog configuration options. + var config: AdwaitaAboutDialogConfig /// The ID for the dialog's storage. let dialogID = "dialog" @@ -36,30 +25,18 @@ struct AboutDialog: AdwaitaWidget { /// - Parameters: /// - visible: The visibility. /// - child: The child view. - /// - appName: The app's name. - /// - developer: The developer's name. - /// - version: The version. - /// - icon: The icon. - /// - website: The website's URL. - /// - issues: The link for opening issues. + /// - configure: A closure that mutates the dialog configuration. init( visible: Binding, child: AnyView, - appName: String? = nil, - developer: String? = nil, - version: String? = nil, - icon: Icon? = nil, - website: URL? = nil, - issues: URL? = nil + configure: (inout AdwaitaAboutDialogConfig) -> Void ) { self._visible = visible self.child = child - self.appName = appName - self.developer = developer - self.version = version - self.icon = icon - self.website = website - self.issues = issues + + var cfg = AdwaitaAboutDialogConfig() + configure(&cfg) + self.config = cfg } /// The view storage. @@ -97,26 +74,12 @@ struct AboutDialog: AdwaitaWidget { storage.opaquePointer?.cast() ) } - let dialog = storage.content[dialogID]?.first?.opaquePointer - if let appName { - adw_about_dialog_set_application_name(dialog, appName) + guard let dialog = storage.content[dialogID]?.first?.opaquePointer else { + return } - if let developer { - adw_about_dialog_set_developer_name(dialog, developer) - } - if let version { - adw_about_dialog_set_version(dialog, version) - } - if let icon { - adw_about_dialog_set_application_icon(dialog, icon.string) - } - if let website { - adw_about_dialog_set_website(dialog, website.absoluteString) - } - if let issues { - adw_about_dialog_set_issue_url(dialog, issues.absoluteString) - } - adw_dialog_set_content_height(dialog?.cast(), -1) + config.apply(to: dialog) + + adw_dialog_set_content_height(dialog.cast(), -1) } else { if storage.content[dialogID]?.first != nil { let dialog = storage.content[dialogID]?.first?.opaquePointer