func NewMessageOverviewScreen() tview.Primitive {

	app.MailApp.MessageAccountTree = tview.NewTreeView()
	app.MailApp.MessageAccountTree.SetBorder(true)
	app.MailApp.MessageAccountTree.SetTitle("Accounts")
	app.MailApp.MessageAccountTree.SetGraphics(true)
	app.MailApp.MessageAccountTree.SetSelectedFunc(func(node *tview.TreeNode) {
		addr, err := address.NewAddress(node.GetText())
		if err != nil {
			return
		}
		app.MailApp.CurrentAddr = addr
		app.MailApp.StaleAddr = true
		Refresh()
	})

	app.MailApp.MessageBoxTree = tview.NewTreeView()
	app.MailApp.MessageBoxTree.SetBorder(true)
	app.MailApp.MessageBoxTree.SetTitle("Mailboxes")
	app.MailApp.MessageBoxTree.SetGraphics(true)
	app.MailApp.MessageBoxTree.SetSelectedFunc(func(node *tview.TreeNode) {
		box := "1" // node.GetText()
		app.MailApp.CurrentBox = &box
		app.MailApp.StaleBox = true
		Refresh()
	})

	app.MailApp.MessageList = components.NewMessageList()
	app.MailApp.MessageList.SetBorder(true)
	app.MailApp.MessageList.SetSelectFunc(func(ml components.MessageList, idx int) {
		app.MailApp.MessageView.SetText(createMessageText(ml.Items[idx]))
	})

	menuBar := components.NewMenubar(app.MailApp.App)
	menuBar.SetSlot(9, "Back", func() {
		app.MailApp.Pages.SwitchToPage("main_menu")
	})

	app.MailApp.MessageView = tview.NewTextView()
	app.MailApp.MessageView.SetBorder(true)
	app.MailApp.MessageView.SetText("load a message first")

	// MessageList.SetDoneFunc(func(key tcell.Key) {
	// 	app.Pages.SwitchToPage("main_menu")
	// })

	grid := tview.NewGrid().SetColumns(30, 0).SetRows(20, 0, 1)
	grid.AddItem(app.MailApp.MessageAccountTree, 0, 0, 1, 1, 20, 30, true)
	grid.AddItem(app.MailApp.MessageBoxTree, 1, 0, 1, 1, 0, 0, false)
	grid.AddItem(app.MailApp.MessageList, 0, 1, 1, 1, 0, 0, false)
	grid.AddItem(app.MailApp.MessageView, 1, 1, 1, 1, 0, 0, false)
	grid.AddItem(menuBar, 2, 0, 1, 2, 0, 0, false)

	grid.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
		if event.Rune() == 'a' {
			app.MailApp.App.SetFocus(app.MailApp.MessageAccountTree)
			return nil
		}
		if event.Rune() == 'b' {
			app.MailApp.App.SetFocus(app.MailApp.MessageBoxTree)
			return nil
		}
		if event.Rune() == 'l' {
			app.MailApp.App.SetFocus(app.MailApp.MessageList)
			return nil
		}
		if event.Rune() == 'm' {
			app.MailApp.App.SetFocus(app.MailApp.MessageView)
			return nil
		}

		return event
	})

	return grid
}
// NewMessageOverviewScreen creates a new message overview screen
NewMessageOverviewScreen creates a new message overview screen
// NewMessageOverviewScreen creates a new message overview screen
func NewMessageOverviewScreen() tview.Primitive {
	app.MailApp.MessageAccountTree = tview.NewTreeView()
	app.MailApp.MessageAccountTree.SetBorder(true)
	app.MailApp.MessageAccountTree.SetTitle("Accounts")
	app.MailApp.MessageAccountTree.SetGraphics(true)
	app.MailApp.MessageAccountTree.SetSelectedFunc(func(node *tview.TreeNode) {
		addr, err := address.NewAddress(node.GetText())
		if err != nil {
			return
		}
		app.MailApp.CurrentAddr = addr
		app.MailApp.StaleAddr = true
		Refresh()
	})
	app.MailApp.MessageBoxTree = tview.NewTreeView()
	app.MailApp.MessageBoxTree.SetBorder(true)
	app.MailApp.MessageBoxTree.SetTitle("Mailboxes")
	app.MailApp.MessageBoxTree.SetGraphics(true)
	app.MailApp.MessageBoxTree.SetSelectedFunc(func(node *tview.TreeNode) {
		box := "1" 
		app.MailApp.CurrentBox = &box
		app.MailApp.StaleBox = true
		Refresh()
	})
	app.MailApp.MessageList = components.NewMessageList()
	app.MailApp.MessageList.SetBorder(true)
	app.MailApp.MessageList.SetSelectFunc(func(ml components.MessageList, idx int) {
		app.MailApp.MessageView.SetText(createMessageText(ml.Items[idx]))
	})
	menuBar := components.NewMenubar(app.MailApp.App)
	menuBar.SetSlot(9, "Back", func() {
		app.MailApp.Pages.SwitchToPage("main_menu")
	})
	app.MailApp.MessageView = tview.NewTextView()
	app.MailApp.MessageView.SetBorder(true)
	app.MailApp.MessageView.SetText("load a message first")
	grid := tview.NewGrid().SetColumns(30, 0).SetRows(20, 0, 1)
	grid.AddItem(app.MailApp.MessageAccountTree, 0, 0, 1, 1, 20, 30, true)
	grid.AddItem(app.MailApp.MessageBoxTree, 1, 0, 1, 1, 0, 0, false)
	grid.AddItem(app.MailApp.MessageList, 0, 1, 1, 1, 0, 0, false)
	grid.AddItem(app.MailApp.MessageView, 1, 1, 1, 1, 0, 0, false)
	grid.AddItem(menuBar, 2, 0, 1, 2, 0, 0, false)
	grid.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
		if event.Rune() == 'a' {
			app.MailApp.App.SetFocus(app.MailApp.MessageAccountTree)
			return nil
		}
		if event.Rune() == 'b' {
			app.MailApp.App.SetFocus(app.MailApp.MessageBoxTree)
			return nil
		}
		if event.Rune() == 'l' {
			app.MailApp.App.SetFocus(app.MailApp.MessageList)
			return nil
		}
		if event.Rune() == 'm' {
			app.MailApp.App.SetFocus(app.MailApp.MessageView)
			return nil
		}
		return event
	})
	return grid
}
func NewMessageOverviewScreen ( ) tview . Primitive { app . MailApp . MessageAccountTree = tview . NewTreeView ( ) app . MailApp . MessageAccountTree . SetBorder ( true ) app . MailApp . MessageAccountTree . SetTitle ( " " ) app . MailApp . MessageAccountTree . SetGraphics ( true ) app . MailApp . MessageAccountTree . SetSelectedFunc ( func ( node * tview . TreeNode ) { addr , err := address . NewAddress ( node . GetText ( ) ) if err != nil { return } app . MailApp . CurrentAddr = addr app . MailApp . StaleAddr = true Refresh ( ) } ) app . MailApp . MessageBoxTree = tview . NewTreeView ( ) app . MailApp . MessageBoxTree . SetBorder ( true ) app . MailApp . MessageBoxTree . SetTitle ( " " ) app . MailApp . MessageBoxTree . SetGraphics ( true ) app . MailApp . MessageBoxTree . SetSelectedFunc ( func ( node * tview . TreeNode ) { box := " " app . MailApp . CurrentBox = & box app . MailApp . StaleBox = true Refresh ( ) } ) app . MailApp . MessageList = components . NewMessageList ( ) app . MailApp . MessageList . SetBorder ( true ) app . MailApp . MessageList . SetSelectFunc ( func ( ml components . MessageList , idx int ) { app . MailApp . MessageView . SetText ( createMessageText ( ml . Items [ idx ] ) ) } ) menuBar := components . NewMenubar ( app . MailApp . App ) menuBar . SetSlot ( 9 , " " , func ( ) { app . MailApp . Pages . SwitchToPage ( " " ) } ) app . MailApp . MessageView = tview . NewTextView ( ) app . MailApp . MessageView . SetBorder ( true ) app . MailApp . MessageView . SetText ( " " ) grid := tview . NewGrid ( ) . SetColumns ( 30 , 0 ) . SetRows ( 20 , 0 , 1 ) grid . AddItem ( app . MailApp . MessageAccountTree , 0 , 0 , 1 , 1 , 20 , 30 , true ) grid . AddItem ( app . MailApp . MessageBoxTree , 1 , 0 , 1 , 1 , 0 , 0 , false ) grid . AddItem ( app . MailApp . MessageList , 0 , 1 , 1 , 1 , 0 , 0 , false ) grid . AddItem ( app . MailApp . MessageView , 1 , 1 , 1 , 1 , 0 , 0 , false ) grid . AddItem ( menuBar , 2 , 0 , 1 , 2 , 0 , 0 , false ) grid . SetInputCapture ( func ( event * tcell . EventKey ) * tcell . EventKey { if event . Rune ( ) == 'a' { app . MailApp . App . SetFocus ( app . MailApp . MessageAccountTree ) return nil } if event . Rune ( ) == 'b' { app . MailApp . App . SetFocus ( app . MailApp . MessageBoxTree ) return nil } if event . Rune ( ) == 'l' { app . MailApp . App . SetFocus ( app . MailApp . MessageList ) return nil } if event . Rune ( ) == 'm' { app . MailApp . App . SetFocus ( app . MailApp . MessageView ) return nil } return event } ) return grid }
NewMessageOverviewScreen creates a new message overview screen
NewMessageOverviewScreen creates a new message overview screen
// node.GetText() // MessageList.SetDoneFunc(func(key tcell.Key) { // 	app.Pages.SwitchToPage("main_menu") // })