Same Show-UDModal structure for many buttons

Product: PowerShell Universal
Version: 2.11.1

Hello,

I have five buttons to run five actions. Before that I use UDModal to inform user about contain critical information and user should confirm. The UDModal structure and the text for every button are the same, only the action to do is different.

New-UDButton -Id ‘Button1’ -Text ‘do task1’ -OnClick{
Show-UDModal -Content {
New-UDTypography -Style @{color=‘red’} -Variant ‘subtitle1’ -Text “Make sure…”
} -Footer {
New-UDButton -Text “OK” -OnClick {
Hide-UDModal
Show-UDModal -Content {
New-UDTypography -Style @{color=‘red’} -Variant ‘subtitle1’ -Text “Are you sure to continue?”
} -Footer {
New-UDButton -Text “Ja” -OnClick {
Hide-UDModal
## do action1…
}
New-UDButton -Text “Nein” -OnClick {
Hide-UDModal
}
}
}
} -Persistent
}

I don´t want to repeat Show-UDModal -Content{} five times.
How can I put this part in a sort of a function returning true or false, so that I only call it like
function confirmReturn

if (confirmReturn) {
#do your action
}

Any idea appreciated.