Fix Android reopen crash and simplify group navigation

This commit is contained in:
Joe Julian
2026-04-02 07:28:55 -07:00
parent 5b6f7bb1de
commit 7fc0661b32
3 changed files with 196 additions and 12 deletions
+75 -10
View File
@@ -245,6 +245,8 @@ type ui struct {
detailList widget.List
apiPolicyList widget.List
lifecycleList widget.List
recentVaultListState widget.List
recentRemoteListState widget.List
copyUser widget.Clickable
copyPass widget.Clickable
copyURL widget.Clickable
@@ -552,6 +554,12 @@ func newUIWithState(mode string, sess appstate.CurrentSession, paths statePaths)
lifecycleList: widget.List{
List: layout.List{Axis: layout.Vertical},
},
recentVaultListState: widget.List{
List: layout.List{Axis: layout.Vertical},
},
recentRemoteListState: widget.List{
List: layout.List{Axis: layout.Vertical},
},
state: appstate.State{},
selectedHistoryIndex: -1,
selectedAuditIndex: -1,
@@ -5167,21 +5175,78 @@ func (u *ui) groupBar(gtx layout.Context) layout.Dimensions {
displayPath := u.displayPath()
atRoot := len(displayPath) == 0
return compactCard(gtx, func(gtx layout.Context) layout.Dimensions {
if u.mode == "phone" {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
lbl := material.Label(u.theme, unit.Sp(12), "GROUPS")
lbl.Color = mutedColor
return lbl.Layout(gtx)
}),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
if atRoot {
return layout.Dimensions{}
}
return layout.Inset{Top: unit.Dp(8)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
return layout.Flex{Spacing: layout.SpaceStart}.Layout(gtx,
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
for u.goToRootGroup.Clicked(gtx) {
root := u.hiddenVaultRoot()
if root == "" {
u.setCurrentPath(nil)
} else {
u.setCurrentPath([]string{root})
}
u.filter()
}
return tonedButton(gtx, u.theme, &u.goToRootGroup, "Root")
}),
layout.Rigid(layout.Spacer{Width: unit.Dp(6)}.Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
for u.goToParentGroup.Clicked(gtx) {
u.setCurrentPath(u.currentPath[:len(u.currentPath)-1])
u.filter()
}
return tonedButton(gtx, u.theme, &u.goToParentGroup, "Up")
}),
)
})
}),
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
if len(groups) == 0 {
lbl := material.Label(u.theme, unit.Sp(12), "No subgroups here.")
lbl.Color = mutedColor
return lbl.Layout(gtx)
}
maxY := gtx.Dp(unit.Dp(168))
if gtx.Constraints.Max.Y > maxY {
gtx.Constraints.Max.Y = maxY
}
if gtx.Constraints.Min.Y > gtx.Constraints.Max.Y {
gtx.Constraints.Min.Y = gtx.Constraints.Max.Y
}
return material.List(u.theme, &u.groupList).Layout(gtx, len(groups), func(gtx layout.Context, i int) layout.Dimensions {
idx := i
name := groups[i]
return layout.Inset{Bottom: unit.Dp(6)}.Layout(gtx, func(gtx layout.Context) layout.Dimensions {
for u.groupClicks[idx].Clicked(gtx) {
u.state.EnterGroup(name)
u.currentPath = append([]string(nil), u.state.CurrentPath...)
u.filter()
}
return tonedButton(gtx, u.theme, &u.groupClicks[idx], name)
})
})
}),
)
}
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
lbl := material.Label(u.theme, unit.Sp(12), "BROWSE GROUPS")
lbl := material.Label(u.theme, unit.Sp(12), "GROUPS")
lbl.Color = mutedColor
return lbl.Layout(gtx)
}),
layout.Rigid(layout.Spacer{Height: unit.Dp(4)}.Layout),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
lbl := material.Label(u.theme, unit.Sp(12), "Root anchors the vault, current group sets the listing, and child groups open deeper paths.")
lbl.Color = mutedColor
return lbl.Layout(gtx)
}),
layout.Rigid(layout.Spacer{Height: unit.Dp(8)}.Layout),
layout.Rigid(detailLine(u.theme, "Root", "Vault root (/)")),
layout.Rigid(layout.Spacer{Height: unit.Dp(6)}.Layout),
layout.Rigid(detailLine(u.theme, "Current Group", u.currentGroupDisplayName())),
layout.Rigid(func(gtx layout.Context) layout.Dimensions {
if atRoot {
@@ -5261,7 +5326,7 @@ func (u *ui) groupBar(gtx layout.Context) layout.Dimensions {
u.currentPath = append([]string(nil), u.state.CurrentPath...)
u.filter()
}
return tonedButton(gtx, u.theme, &u.groupClicks[idx], "Open "+name)
return tonedButton(gtx, u.theme, &u.groupClicks[idx], name)
})
})
}),