| Conditions | 3 |
| Total Lines | 25 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package ui |
||
| 33 | func NewCustomDialog(title string, content fyne.CanvasObject, buttons ...*widget.Button) *widget.PopUp { |
||
| 34 | var modal *widget.PopUp |
||
| 35 | |||
| 36 | closeButton := widget.NewButton( |
||
| 37 | "Close", |
||
| 38 | func() { modal.Hide() }, |
||
| 39 | ) |
||
| 40 | buttonList := make([]fyne.CanvasObject, len(buttons)+2) |
||
| 41 | buttonList[0] = layout.NewSpacer() |
||
| 42 | buttonList[1] = closeButton |
||
| 43 | idx := 2 |
||
| 44 | for _, button := range buttons { |
||
| 45 | buttonList[idx] = button |
||
| 46 | idx++ |
||
| 47 | } |
||
| 48 | buttonPanel := container.NewHBox(buttonList...) |
||
| 49 | container := container.NewBorder( |
||
| 50 | widget.NewLabel(title), |
||
| 51 | buttonPanel, |
||
| 52 | nil, |
||
| 53 | nil, |
||
| 54 | content, |
||
| 55 | ) |
||
| 56 | modal = widget.NewModalPopUp(container, Window.Canvas()) |
||
| 57 | return modal |
||
| 58 | } |
||
| 59 |