Repository: fyne-io/fyne
File: dialog/custom.go (Go)

Code before:
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
func ShowCustom(title, dismiss string, content fyne.CanvasObject, parent fyne.Window) {
	NewCustom(title, dismiss, content, parent).Show()
}

// NewCustomWithoutButtons creates a new custom dialog without any buttons.
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
//
// Since: 2.4
func NewCustomWithoutButtons(title string, content fyne.CanvasObject, parent fyne.Window) *CustomDialog {
	d := &dialog{content: content, title: title, parent: parent}
	d.create(container.NewGridWithColumns(1))

	return &CustomDialog{dialog: d}
}

// SetButtons sets the row of buttons at the bottom of the dialog.
// Passing an empty slice will result in a dialog with no buttons.
//
// Since: 2.4
func (d *CustomDialog) SetButtons(buttons []fyne.CanvasObject) {
	d.dismiss = nil // New button row invalidates possible dismiss button.
	d.setButtons(container.NewGridWithRows(1, buttons...))
}

// SetIcon sets an icon to be shown on the right of the dialog, like the NewInformation dialog.
// Passing a nil resource will remove the icon from the dialog.
//
// Since: 2.6
func (d *CustomDialog) SetIcon(icon fyne.Resource) {
	d.setIcon(icon)
}

// ShowCustomWithoutButtons shows a dialog, without buttons, over the specified application
// using custom content.
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
//
// Since: 2.4
func ShowCustomWithoutButtons(title string, content fyne.CanvasObject, parent fyne.Window) {
	NewCustomWithoutButtons(title, content, parent).Show()
}

// NewCustomConfirm creates and returns a dialog over the specified application using
// custom content. The cancel button will have the dismiss text set and the "OK" will
// use the confirm text. The response callback is called on user action.
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
func NewCustomConfirm(title, confirm, dismiss string, content fyne.CanvasObject,
	callback func(bool), parent fyne.Window) *ConfirmDialog {
	d := &dialog{content: content, title: title, parent: parent, callback: callback}

	d.dismiss = &widget.Button{Text: dismiss, Icon: theme.CancelIcon(),

Review comment (suggestion):
I think we should mention top right and ignore the example.
```suggestion
// SetIcon sets an icon to be shown in the top right of the dialog.
```

Code after:
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
func ShowCustom(title, dismiss string, content fyne.CanvasObject, parent fyne.Window) {
	NewCustom(title, dismiss, content, parent).Show()
}

// NewCustomWithoutButtons creates a new custom dialog without any buttons.
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
//
// Since: 2.4
func NewCustomWithoutButtons(title string, content fyne.CanvasObject, parent fyne.Window) *CustomDialog {
	d := &dialog{content: content, title: title, parent: parent}
	d.create(container.NewGridWithColumns(1))

	return &CustomDialog{dialog: d}
}

// SetButtons sets the row of buttons at the bottom of the dialog.
// Passing an empty slice will result in a dialog with no buttons.
//
// Since: 2.4
func (d *CustomDialog) SetButtons(buttons []fyne.CanvasObject) {
	d.dismiss = nil // New button row invalidates possible dismiss button.
	d.setButtons(container.NewGridWithRows(1, buttons...))
}

// SetIcon sets an icon to be shown in the top right of the dialog.
// Passing a nil resource will remove the icon from the dialog.
//
// Since: 2.6
func (d *CustomDialog) SetIcon(icon fyne.Resource) {
	d.setIcon(icon)
}

// ShowCustomWithoutButtons shows a dialog, without buttons, over the specified application
// using custom content.
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
//
// Since: 2.4
func ShowCustomWithoutButtons(title string, content fyne.CanvasObject, parent fyne.Window) {
	NewCustomWithoutButtons(title, content, parent).Show()
}

// NewCustomConfirm creates and returns a dialog over the specified application using
// custom content. The cancel button will have the dismiss text set and the "OK" will
// use the confirm text. The response callback is called on user action.
// The MinSize() of the CanvasObject passed will be used to set the size of the window.
func NewCustomConfirm(title, confirm, dismiss string, content fyne.CanvasObject,
	callback func(bool), parent fyne.Window) *ConfirmDialog {
	d := &dialog{content: content, title: title, parent: parent, callback: callback}

	d.dismiss = &widget.Button{Text: dismiss, Icon: theme.CancelIcon(),