Unify action menus and collapse empty detail pane
This commit is contained in:
+12
-33
@@ -1850,8 +1850,17 @@ func (u *ui) navigationHeaderLabel() string {
|
||||
|
||||
func (u *ui) entryRow(gtx layout.Context, click *widget.Clickable, idx int, item entry) layout.Dimensions {
|
||||
for click.Clicked(gtx) {
|
||||
_ = u.state.ToggleVisibleIndex(idx)
|
||||
if !u.shouldShowDetailPane() {
|
||||
if idx >= 0 && idx < len(u.visible) {
|
||||
u.state.SelectedEntryID = u.visible[idx].ID
|
||||
}
|
||||
} else {
|
||||
_ = u.state.ToggleVisibleIndex(idx)
|
||||
}
|
||||
u.loadSelectedEntryIntoEditor()
|
||||
if u.invalidate != nil {
|
||||
u.invalidate()
|
||||
}
|
||||
}
|
||||
return click.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
selected := item.ID == u.state.SelectedEntryID
|
||||
@@ -2014,21 +2023,7 @@ func (u *ui) detailPanel(gtx layout.Context) layout.Dimensions {
|
||||
return panel(gtx, func(gtx layout.Context) layout.Dimensions {
|
||||
if u.shouldShowDesktopWorkingHeader() {
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Flex{Alignment: layout.Middle, Spacing: layout.SpaceStart}.Layout(gtx,
|
||||
layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
|
||||
return layout.Dimensions{}
|
||||
}),
|
||||
layout.Rigid(u.syncButtonGroup),
|
||||
layout.Rigid(layout.Spacer{Width: unit.Dp(8)}.Layout),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
btn := material.Button(u.theme, &u.lockVault, "Lock")
|
||||
return btn.Layout(gtx)
|
||||
}),
|
||||
layout.Rigid(layout.Spacer{Width: unit.Dp(8)}.Layout),
|
||||
layout.Rigid(u.mainMenuButtonGroup),
|
||||
)
|
||||
}),
|
||||
layout.Rigid(u.headerActions),
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(12)}.Layout),
|
||||
layout.Flexed(1, func(gtx layout.Context) layout.Dimensions {
|
||||
return u.detailPanelContent(gtx)
|
||||
@@ -2049,7 +2044,7 @@ func (u *ui) detailPanelContent(gtx layout.Context) layout.Dimensions {
|
||||
panel := u.staticDetailPanel()
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx, panel...)
|
||||
case detaillayout.ModeEmpty:
|
||||
return layout.Flex{Axis: layout.Vertical}.Layout(gtx, u.emptyDetailChildren()...)
|
||||
return layout.Dimensions{}
|
||||
}
|
||||
item, ok := u.selectedEntry()
|
||||
if mode == detaillayout.ModeEditor {
|
||||
@@ -2089,22 +2084,6 @@ func (u *ui) staticDetailPanel() []layout.FlexChild {
|
||||
}
|
||||
}
|
||||
|
||||
func (u *ui) emptyDetailChildren() []layout.FlexChild {
|
||||
return []layout.FlexChild{
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
lbl := material.Label(u.theme, unit.Sp(18), "Entry details")
|
||||
lbl.Color = accentColor
|
||||
return lbl.Layout(gtx)
|
||||
}),
|
||||
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
|
||||
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
|
||||
lbl := material.Label(u.theme, unit.Sp(16), u.detailPlaceholderMessage())
|
||||
lbl.Color = mutedColor
|
||||
return lbl.Layout(gtx)
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
func (u *ui) detailEditorContent(gtx layout.Context, hasSelected bool) layout.Dimensions {
|
||||
rows := []layout.Widget{
|
||||
func(gtx layout.Context) layout.Dimensions {
|
||||
|
||||
Reference in New Issue
Block a user