Skip to content

Commit

Permalink
let modal view be responsive in dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
oligo committed Nov 21, 2024
1 parent f8af9d2 commit 4c2c32b
Showing 1 changed file with 2 additions and 29 deletions.
31 changes: 2 additions & 29 deletions view/modal.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/oligo/gioview/theme"

"gioui.org/io/event"
"gioui.org/io/pointer"
"gioui.org/layout"
"gioui.org/op"
"gioui.org/op/clip"
Expand Down Expand Up @@ -78,22 +77,6 @@ func (m *ModalView) update(gtx layout.Context) bool {
m.closed = true
}

// Dismiss the contextual widget if the user clicked outside of it.
for {
_, ok := gtx.Event(
pointer.Filter{Target: m, Kinds: pointer.Press})
if !ok {
break
}
// e, ok := e.(pointer.Event)
// if !ok {
// continue
// }
// if e.Type == pointer.Press {
// m.closed = true
// }
}

if m.View.Finished() {
m.closed = true
}
Expand Down Expand Up @@ -161,15 +144,6 @@ func (m *ModalView) Layout(gtx layout.Context, th *theme.Theme) layout.Dimension
}()
op.Defer(gtx.Ops, modalAreaOps)

// Capture pointer events in the modal area.
// defer pointer.PassOp{}.Push(gtx.Ops).Pop()
// defer clip.Rect(image.Rectangle{Max: gtx.Constraints.Min}).Push(gtx.Ops).Pop()
// pointer.InputOp{
// Tag: m,
// Grab: false,
// Types: pointer.Press | pointer.Release,
// }.Add(gtx.Ops)

return dims
}

Expand All @@ -184,9 +158,8 @@ func (m *ModalView) layoutView(gtx layout.Context, th *theme.Theme) layout.Dimen

gtx.Constraints.Max.X = min(gtx.Constraints.Max.X, gtx.Dp(m.MaxWidth))
gtx.Constraints.Max.Y = int(float32(gtx.Constraints.Max.Y) * min(0.9, m.MaxHeight))
gtx.Constraints.Min = gtx.Constraints.Max

// m.modalList.Axis = layout.Vertical
gtx.Constraints.Min.X = gtx.Constraints.Max.X
gtx.Constraints.Min.Y = 0

return m.Padding.Layout(gtx, func(gtx C) D {
return layout.Flex{
Expand Down

0 comments on commit 4c2c32b

Please sign in to comment.