@ -10,6 +10,7 @@ import (
"fmt"
"fmt"
"image"
"image"
"image/color"
"image/color"
"strings"
"time"
"time"
"gioui.org/f32"
"gioui.org/f32"
@ -70,6 +71,9 @@ type UI struct {
list layout . List
list layout . List
}
}
showDebugMenu bool
runningExit bool // are we an exit node now?
intro struct {
intro struct {
list layout . List
list layout . List
start widget . Clickable
start widget . Clickable
@ -84,6 +88,7 @@ type UI struct {
copy widget . Clickable
copy widget . Clickable
reauth widget . Clickable
reauth widget . Clickable
bug widget . Clickable
bug widget . Clickable
beExit widget . Clickable
exits widget . Clickable
exits widget . Clickable
logout widget . Clickable
logout widget . Clickable
}
}
@ -260,7 +265,11 @@ func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientStat
for _ , e := range ui . search . Events ( ) {
for _ , e := range ui . search . Events ( ) {
if _ , ok := e . ( widget . ChangeEvent ) ; ok {
if _ , ok := e . ( widget . ChangeEvent ) ; ok {
events = append ( events , SearchEvent { Query : ui . search . Text ( ) } )
text := ui . search . Text ( )
if strings . EqualFold ( text , "debug" ) {
ui . showDebugMenu = true
}
events = append ( events , SearchEvent { Query : text } )
break
break
}
}
}
}
@ -319,6 +328,16 @@ func (ui *UI) layout(gtx layout.Context, sysIns system.Insets, state *clientStat
ui . showCopied ( gtx , "bug report marker to clipboard" )
ui . showCopied ( gtx , "bug report marker to clipboard" )
}
}
if ui . menuClicked ( & ui . menu . beExit ) {
ui . runningExit = ! ui . runningExit
events = append ( events , BeExitNodeEvent ( ui . runningExit ) )
if ui . runningExit {
ui . showMessage ( gtx , "Running exit node" )
} else {
ui . showMessage ( gtx , "Stopped running exit node" )
}
}
if ui . menuClicked ( & ui . menu . exits ) || ui . openExitDialog . Clicked ( ) {
if ui . menuClicked ( & ui . menu . exits ) || ui . openExitDialog . Clicked ( ) {
ui . exitDialog . show = true
ui . exitDialog . show = true
}
}
@ -981,6 +1000,15 @@ func (ui *UI) layoutMenu(gtx layout.Context, sysIns system.Insets, expiry time.T
menuItem { title : "Reauthenticate" , btn : & menu . reauth } ,
menuItem { title : "Reauthenticate" , btn : & menu . reauth } ,
menuItem { title : "Log out" , btn : & menu . logout } ,
menuItem { title : "Log out" , btn : & menu . logout } ,
)
)
if ui . runningExit || ui . showDebugMenu {
var title string
if ui . runningExit {
title = "Stop running exit node [BETA]"
} else {
title = "Run exit node [BETA]"
}
items = append ( items , menuItem { title : title , btn : & menu . beExit } )
}
return layoutMenu ( ui . theme , gtx , items , func ( gtx C ) D {
return layoutMenu ( ui . theme , gtx , items , func ( gtx C ) D {
var expiryStr string
var expiryStr string
const fmtStr = time . Stamp
const fmtStr = time . Stamp