Extract about dialog conf options to separate file

This commit is contained in:
Ira Limitanei 2026-01-16 10:30:19 +09:00
parent 9597c57b39
commit b3f222e316
Signed by: lambdaclan
GPG Key ID: 43D6A575B03B80E4

View File

@ -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<Bool>,
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