Add a back button to the passphrase entry page. Clear the clipboard
after 45 seconds.
This commit is contained in:
parent
59a15849f3
commit
9ead860d17
|
@ -286,7 +286,13 @@ func eventLoop() {
|
||||||
Background: darkgray,
|
Background: darkgray,
|
||||||
Alignment: text.Middle,
|
Alignment: text.Middle,
|
||||||
}
|
}
|
||||||
var copiedWhen time.Time
|
cleared := &Overlay{Face: face, Text: "clipboard cleared",
|
||||||
|
Color: black,
|
||||||
|
Background: darkgray,
|
||||||
|
Alignment: text.Middle,
|
||||||
|
}
|
||||||
|
overlay := copied
|
||||||
|
var overlayStart time.Time
|
||||||
|
|
||||||
updateBtns := func() {
|
updateBtns := func() {
|
||||||
passBtns = passBtns[:0]
|
passBtns = passBtns[:0]
|
||||||
|
@ -395,8 +401,16 @@ func eventLoop() {
|
||||||
//p, err := store.Decrypt(name)
|
//p, err := store.Decrypt(name)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
passgo.Clip(p)
|
passgo.Clip(p)
|
||||||
copiedWhen = time.Now()
|
overlayStart = time.Now()
|
||||||
|
overlay = copied
|
||||||
animOn()
|
animOn()
|
||||||
|
go func() {
|
||||||
|
time.Sleep(time.Second * 45)
|
||||||
|
passgo.Clip("")
|
||||||
|
overlay = cleared
|
||||||
|
overlayStart = time.Now()
|
||||||
|
animOn()
|
||||||
|
}()
|
||||||
} else {
|
} else {
|
||||||
log(Info, "Can't decrypt ", name)
|
log(Info, "Can't decrypt ", name)
|
||||||
log(Info, err)
|
log(Info, err)
|
||||||
|
@ -413,29 +427,27 @@ func eventLoop() {
|
||||||
page = confPage
|
page = confPage
|
||||||
}
|
}
|
||||||
flex.Layout(c1, c2)
|
flex.Layout(c1, c2)
|
||||||
x := time.Since(copiedWhen).Seconds()
|
x := time.Since(overlayStart).Seconds()
|
||||||
start, end := 1.5, 1.75
|
start, end := 1.5, 1.75
|
||||||
switch {
|
switch {
|
||||||
case x > start && x < end:
|
case x > start && x < end:
|
||||||
fade := (end - x) / (end - start)
|
fade := (end - x) / (end - start)
|
||||||
copied.Color.R = uint8(float64(black.R) * fade)
|
overlay.Color.R = uint8(float64(black.R) * fade)
|
||||||
copied.Color.G = uint8(float64(black.G) * fade)
|
overlay.Color.G = uint8(float64(black.G) * fade)
|
||||||
copied.Color.B = uint8(float64(black.B) * fade)
|
overlay.Color.B = uint8(float64(black.B) * fade)
|
||||||
copied.Color.A = uint8(float64(black.A) * fade)
|
overlay.Color.A = uint8(float64(black.A) * fade)
|
||||||
copied.Background.R = uint8(float64(darkgray.R) * fade)
|
overlay.Background.R = uint8(float64(darkgray.R) * fade)
|
||||||
copied.Background.G = uint8(float64(darkgray.G) * fade)
|
overlay.Background.G = uint8(float64(darkgray.G) * fade)
|
||||||
copied.Background.B = uint8(float64(darkgray.B) * fade)
|
overlay.Background.B = uint8(float64(darkgray.B) * fade)
|
||||||
copied.Background.A = uint8(float64(darkgray.A) * fade)
|
overlay.Background.A = uint8(float64(darkgray.A) * fade)
|
||||||
fallthrough
|
fallthrough
|
||||||
case x <= start:
|
case x <= start:
|
||||||
cs = margincs
|
cs = margincs
|
||||||
al := layout.Align{Alignment: layout.SE}
|
al := layout.Align{Alignment: layout.SE}
|
||||||
cs = al.Begin(ops, cs)
|
cs = al.Begin(ops, cs)
|
||||||
cs.Width.Min = cs.Width.Max
|
cs.Width.Min = cs.Width.Max
|
||||||
dims = al.End(copied.Layout(c, ops, cs))
|
dims = al.End(overlay.Layout(c, ops, cs))
|
||||||
case animating:
|
case animating:
|
||||||
copied.Color = black
|
|
||||||
copied.Background = darkgray
|
|
||||||
animOff()
|
animOff()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,13 +497,21 @@ func eventLoop() {
|
||||||
cs = flex.Rigid()
|
cs = flex.Rigid()
|
||||||
al := &layout.Align{Alignment: layout.E}
|
al := &layout.Align{Alignment: layout.E}
|
||||||
cs = al.Begin(ops, cs)
|
cs = al.Begin(ops, cs)
|
||||||
c4 := flex.End(al.End(okBtn.Layout(c, q, ops, cs)))
|
btnflx := &layout.Flex{Axis: layout.Horizontal}
|
||||||
|
btnflx.Init(ops, cs)
|
||||||
|
cs = btnflx.Rigid()
|
||||||
|
bc1 := btnflx.End(backBtn.Layout(c, q, ops, cs))
|
||||||
|
cs = btnflx.Rigid()
|
||||||
|
bc2 := btnflx.End(okBtn.Layout(c, q, ops, cs))
|
||||||
|
dims = btnflx.Layout(bc1, bc2)
|
||||||
|
c4 := flex.End(al.End(dims))
|
||||||
flex.Layout(c1, c2, c3, c4)
|
flex.Layout(c1, c2, c3, c4)
|
||||||
if okBtn.Clicked() {
|
if okBtn.Clicked() {
|
||||||
log(Info, "Ok")
|
log(Info, "Ok")
|
||||||
go func() { // do not block UI thread
|
go func() { // do not block UI thread
|
||||||
passch <-[]byte(promptEd.Text())
|
passch <-[]byte(promptEd.Text())
|
||||||
}()
|
}()
|
||||||
|
w.Invalidate()
|
||||||
page = listPage
|
page = listPage
|
||||||
}
|
}
|
||||||
if backBtn.Clicked() {
|
if backBtn.Clicked() {
|
||||||
|
@ -499,6 +519,7 @@ func eventLoop() {
|
||||||
go func() {
|
go func() {
|
||||||
passch <- nil // cancel prompt
|
passch <- nil // cancel prompt
|
||||||
}()
|
}()
|
||||||
|
w.Invalidate()
|
||||||
page = listPage
|
page = listPage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user