func NewUnlockVault() tview.Primitive {

	createModal := func(p tview.Primitive, width, height int) tview.Primitive {
		return tview.NewFlex().
			AddItem(nil, 0, 1, false).
			AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
				AddItem(nil, 0, 1, false).
				AddItem(p, height, 1, true).
				AddItem(nil, 0, 1, false), width, 1, false).
			AddItem(nil, 0, 1, false)
	}

	errorDisplayed := false

	ModalDialogInput = tview.NewForm().
		AddPasswordField("Password:", "", 40, '*', func(text string) {
			vault.VaultPassword = text
		}).
		AddButton("Open vault", func() {
			var err error
			app.MailApp.Vault, err = vault.Open(vault.VaultPath, vault.VaultPassword)
			if err == nil {
				app.MailApp.StaleVault = true
				Refresh()
				app.MailApp.Pages.SwitchToPage("main_menu")
				app.MailApp.App.SetFocus(MainMenu)
				return
			}

			if !errorDisplayed {
				errorDisplayed = true
				ModalDialogBox.AddText("Incorrect vault password specified", false, tview.AlignCenter, tcell.ColorRed)
			}
			// Clear password
			ModalDialogInput.GetFormItem(0).(*tview.InputField).SetText("")
			ModalDialogInput.SetFocus(0)
			app.MailApp.App.SetFocus(ModalDialogInput)
		}).
		AddButton("Quit", func() {
			app.MailApp.App.Stop()
			os.Exit(0)
		}).
		SetButtonsAlign(tview.AlignCenter)

	ModalDialogBox = tview.NewFrame(ModalDialogInput).SetBorders(0, 0, 0, 0, 0, 0)

	ModalDialogBox.SetBorder(true).
		SetBorderPadding(1, 1, 1, 1).
		SetTitle(" Enter your vault password ")

	return createModal(ModalDialogBox, 60, 10)
}
// NewUnlockVault Display a modal dialog that opens the vault
NewUnlockVault Display a modal dialog that opens the vault
// NewUnlockVault Display a modal dialog that opens the vault
func NewUnlockVault() tview.Primitive {
	createModal := func(p tview.Primitive, width, height int) tview.Primitive {
		return tview.NewFlex().
			AddItem(nil, 0, 1, false).
			AddItem(tview.NewFlex().SetDirection(tview.FlexRow).
				AddItem(nil, 0, 1, false).
				AddItem(p, height, 1, true).
				AddItem(nil, 0, 1, false), width, 1, false).
			AddItem(nil, 0, 1, false)
	}
	errorDisplayed := false
	ModalDialogInput = tview.NewForm().
		AddPasswordField("Password:", "", 40, '*', func(text string) {
			vault.VaultPassword = text
		}).
		AddButton("Open vault", func() {
			var err error
			app.MailApp.Vault, err = vault.Open(vault.VaultPath, vault.VaultPassword)
			if err == nil {
				app.MailApp.StaleVault = true
				Refresh()
				app.MailApp.Pages.SwitchToPage("main_menu")
				app.MailApp.App.SetFocus(MainMenu)
				return
			}
			if !errorDisplayed {
				errorDisplayed = true
				ModalDialogBox.AddText("Incorrect vault password specified", false, tview.AlignCenter, tcell.ColorRed)
			}
			ModalDialogInput.GetFormItem(0).(*tview.InputField).SetText("")
			ModalDialogInput.SetFocus(0)
			app.MailApp.App.SetFocus(ModalDialogInput)
		}).
		AddButton("Quit", func() {
			app.MailApp.App.Stop()
			os.Exit(0)
		}).
		SetButtonsAlign(tview.AlignCenter)
	ModalDialogBox = tview.NewFrame(ModalDialogInput).SetBorders(0, 0, 0, 0, 0, 0)
	ModalDialogBox.SetBorder(true).
		SetBorderPadding(1, 1, 1, 1).
		SetTitle(" Enter your vault password ")
	return createModal(ModalDialogBox, 60, 10)
}
func NewUnlockVault ( ) tview . Primitive { createModal := func ( p tview . Primitive , width , height int ) tview . Primitive { return tview . NewFlex ( ) . AddItem ( nil , 0 , 1 , false ) . AddItem ( tview . NewFlex ( ) . SetDirection ( tview . FlexRow ) . AddItem ( nil , 0 , 1 , false ) . AddItem ( p , height , 1 , true ) . AddItem ( nil , 0 , 1 , false ) , width , 1 , false ) . AddItem ( nil , 0 , 1 , false ) } errorDisplayed := false ModalDialogInput = tview . NewForm ( ) . AddPasswordField ( " " , " " , 40 , '*' , func ( text string ) { vault . VaultPassword = text } ) . AddButton ( " " , func ( ) { var err error app . MailApp . Vault , err = vault . Open ( vault . VaultPath , vault . VaultPassword ) if err == nil { app . MailApp . StaleVault = true Refresh ( ) app . MailApp . Pages . SwitchToPage ( " " ) app . MailApp . App . SetFocus ( MainMenu ) return } if ! errorDisplayed { errorDisplayed = true ModalDialogBox . AddText ( " " , false , tview . AlignCenter , tcell . ColorRed ) } ModalDialogInput . GetFormItem ( 0 ) . ( * tview . InputField ) . SetText ( " " ) ModalDialogInput . SetFocus ( 0 ) app . MailApp . App . SetFocus ( ModalDialogInput ) } ) . AddButton ( " " , func ( ) { app . MailApp . App . Stop ( ) os . Exit ( 0 ) } ) . SetButtonsAlign ( tview . AlignCenter ) ModalDialogBox = tview . NewFrame ( ModalDialogInput ) . SetBorders ( 0 , 0 , 0 , 0 , 0 , 0 ) ModalDialogBox . SetBorder ( true ) . SetBorderPadding ( 1 , 1 , 1 , 1 ) . SetTitle ( " " ) return createModal ( ModalDialogBox , 60 , 10 ) }
NewUnlockVault Display a modal dialog that opens the vault
NewUnlockVault Display a modal dialog that opens the vault
// Clear password