~whereswaldon/sprig

ref: cedbec5bf0da6b73b5b711f17309a7234c6a3604 sprig/reply-view.go -rw-r--r-- 18.9 KiB
cedbec5bChris Waldon wip: add primitive support for moving focus with arrow keys a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
package main

import (
	"image/color"
	"log"

	"gioui.org/f32"
	"gioui.org/io/key"
	"gioui.org/layout"
	"gioui.org/op"
	"gioui.org/op/clip"
	"gioui.org/op/paint"
	"gioui.org/unit"
	"gioui.org/widget"
	"gioui.org/widget/material"
	forest "git.sr.ht/~whereswaldon/forest-go"
	"git.sr.ht/~whereswaldon/forest-go/fields"
	"git.sr.ht/~whereswaldon/materials"
	"git.sr.ht/~whereswaldon/sprig/ds"
	"git.sr.ht/~whereswaldon/sprig/icons"
	sprigWidget "git.sr.ht/~whereswaldon/sprig/widget"
	sprigTheme "git.sr.ht/~whereswaldon/sprig/widget/theme"
)

type ReplyListView struct {
	manager ViewManager

	*Settings
	*ArborState
	*sprigTheme.Theme

	CopyReplyButton widget.Clickable

	ReplyList    layout.List
	ReplyStates  []sprigWidget.Reply
	Focused      *fields.QualifiedHash
	Ancestry     []*fields.QualifiedHash
	Descendants  []*fields.QualifiedHash
	Conversation *fields.QualifiedHash
	// Whether the Ancestry and Descendants need to be regenerated because the
	// contents of the replylist changed
	StateRefreshNeeded bool

	CreatingConversation     bool
	ReplyingTo               *forest.Reply
	ReplyingToAuthor         *forest.Identity
	ReplyEditor              widget.Editor
	FilterButton             widget.Clickable
	CancelReplyButton        widget.Clickable
	CreateReplyButton        widget.Clickable
	SendReplyButton          widget.Clickable
	PasteIntoReplyButton     widget.Clickable
	CreateConversationButton widget.Clickable
	CommunityChoice          widget.Enum
	CommunityList            layout.List

	// Filtered determines whether or not the visible nodes should be
	// filtered to only those related to the selected node
	Filtered          bool
	PrefilterPosition layout.Position

	ShouldRequestKeyboardFocus bool
}

var _ View = &ReplyListView{}

func NewReplyListView(settings *Settings, arborState *ArborState, theme *sprigTheme.Theme) View {
	c := &ReplyListView{
		Settings:   settings,
		ArborState: arborState,
		Theme:      theme,
	}
	c.ReplyList.Axis = layout.Vertical
	// ensure that we are notified when we need to refresh the state of visible nodes
	c.ArborState.SubscribableStore.SubscribeToNewMessages(func(forest.Node) {
		c.StateRefreshNeeded = true
	})
	c.ReplyList.ScrollToEnd = true
	c.ReplyList.Position.BeforeEnd = false
	return c
}

func (c *ReplyListView) BecomeVisible() {
}

func (c *ReplyListView) NavItem() *materials.NavItem {
	return &materials.NavItem{
		Name: "Messages",
		Icon: icons.ChatIcon,
	}
}

func (c *ReplyListView) AppBarData() (bool, string, []materials.AppBarAction, []materials.OverflowAction) {
	th := c.Theme.Theme
	return true, "Messages", []materials.AppBarAction{
		materials.SimpleIconAction(
			th,
			&c.CreateConversationButton,
			icons.CreateConversationIcon,
			materials.OverflowAction{
				Name: "Create Conversation",
				Tag:  &c.CreateConversationButton,
			},
		),
	}, []materials.OverflowAction{}
}

func (c *ReplyListView) HandleClipboard(contents string) {
	c.ReplyEditor.Insert(contents)
}

func (c *ReplyListView) getContextualActions() ([]materials.AppBarAction, []materials.OverflowAction) {
	th := c.Theme.Theme
	return []materials.AppBarAction{
		materials.SimpleIconAction(
			th,
			&c.CreateReplyButton,
			icons.ReplyIcon,
			materials.OverflowAction{
				Name: "Reply to selected",
				Tag:  &c.CreateReplyButton,
			},
		),
		materials.SimpleIconAction(
			th,
			&c.CopyReplyButton,
			icons.CopyIcon,
			materials.OverflowAction{
				Name: "Copy reply text",
				Tag:  &c.CopyReplyButton,
			},
		),
		materials.AppBarAction{
			OverflowAction: materials.OverflowAction{
				Name: "Filter by selected",
				Tag:  &c.FilterButton,
			},
			Layout: func(gtx C, bg, fg color.RGBA) D {
				btn := materials.SimpleIconButton(th, &c.FilterButton, icons.FilterIcon)
				btn.Background = bg
				btn.Color = fg
				if c.Filtered {
					btn.Color, btn.Background = btn.Background, btn.Color
				}
				return btn.Layout(gtx)
			},
		},
	}, []materials.OverflowAction{}
}

func (c *ReplyListView) triggerReplyContextMenu(gtx layout.Context) {
	actions, overflow := c.getContextualActions()
	c.manager.RequestContextualBar(gtx, "Message Operations", actions, overflow)
}

func (c *ReplyListView) dismissReplyContextMenu(gtx layout.Context) {
	c.manager.DismissContextualBar(gtx)
}

func (c *ReplyListView) moveFocusUp() {
	if c.Focused == nil {
		return
	}
	currentIndex := c.ArborState.ReplyList.IndexForID(c.Focused)
	if currentIndex < 0 {
		return
	}
	c.ArborState.ReplyList.WithReplies(func(replies []ds.ReplyData) {
		if currentIndex <= 0 {
			return
		}
		nextIndex := currentIndex - 1
		c.Focused = replies[nextIndex].Reply.ID()
		c.StateRefreshNeeded = true
		c.ensureFocusedVisible(nextIndex)
	})
}

func (c *ReplyListView) moveFocusDown() {
	if c.Focused == nil {
		return
	}
	currentIndex := c.ArborState.ReplyList.IndexForID(c.Focused)
	if currentIndex < 0 {
		return
	}
	c.ArborState.ReplyList.WithReplies(func(replies []ds.ReplyData) {
		if currentIndex >= len(replies)-1 {
			return
		}
		nextIndex := currentIndex + 1
		c.Focused = replies[nextIndex].Reply.ID()
		c.StateRefreshNeeded = true
		c.ensureFocusedVisible(nextIndex)
	})
}

func (c *ReplyListView) ensureFocusedVisible(focusedIndex int) {
	log.Printf("position: %v, index: %d", c.ReplyList.Position, focusedIndex)
	currentFirst := c.ReplyList.Position.First
	notInFirstFive := currentFirst+5 > focusedIndex
	if currentFirst <= focusedIndex && notInFirstFive {
		return
	}
	c.ReplyList.Position.First = focusedIndex
	if notInFirstFive {
		//		c.ReplyList.Position.First++
	}
	c.ReplyList.Position.Offset = 0
	c.ReplyList.Position.BeforeEnd = true
	log.Printf("after: %v", c.ReplyList.Position)
}

func (c *ReplyListView) Update(gtx layout.Context) {
	for _, event := range gtx.Events(c) {
		switch event := event.(type) {
		case key.Event:
			switch event.Name {
			case key.NameUpArrow:
				c.moveFocusUp()
			case key.NameDownArrow:
				c.moveFocusDown()
			}
			log.Println("key", event)
		}
	}
	overflowTag := c.manager.SelectedOverflowTag()
	for i := range c.ReplyStates {
		clickHandler := &c.ReplyStates[i]
		if clickHandler.Clicked() {
			c.requestKeyboardFocus()
			clickedOnFocused := clickHandler.Reply.Equals(c.Focused)
			if !clickedOnFocused {
				c.StateRefreshNeeded = true
				c.Focused = clickHandler.Reply
				reply, _, _ := c.ArborState.SubscribableStore.Get(clickHandler.Reply)
				c.Conversation = &reply.(*forest.Reply).ConversationID
				c.dismissReplyContextMenu(gtx)
			} else {
				c.triggerReplyContextMenu(gtx)
			}
		}
	}
	if c.StateRefreshNeeded && c.Focused != nil {
		c.StateRefreshNeeded = false
		c.Ancestry, _ = c.ArborState.SubscribableStore.AncestryOf(c.Focused)
		c.Descendants, _ = c.ArborState.SubscribableStore.DescendantsOf(c.Focused)
	}
	if c.FilterButton.Clicked() || overflowTag == &c.FilterButton {
		if c.Filtered {
			c.ReplyList.Position = c.PrefilterPosition
		} else {
			c.PrefilterPosition = c.ReplyList.Position
		}
		c.Filtered = !c.Filtered
		c.manager.DismissOverflow(gtx)
	}
	if c.Focused != nil && (c.CopyReplyButton.Clicked() || overflowTag == &c.CopyReplyButton) {
		reply, _, err := c.ArborState.SubscribableStore.Get(c.Focused)
		if err != nil {
			log.Printf("failed looking up selected message: %v", err)
		} else {
			c.manager.UpdateClipboard(string(reply.(*forest.Reply).Content.Blob))
		}
		c.manager.DismissOverflow(gtx)
	}
	if c.PasteIntoReplyButton.Clicked() {
		c.manager.RequestClipboardPaste()
	}
	if c.Focused != nil && (c.CreateReplyButton.Clicked() || overflowTag == &c.CreateReplyButton) {
		reply, _, err := c.ArborState.SubscribableStore.Get(c.Focused)
		if err != nil {
			log.Printf("failed looking up selected message: %v", err)
		} else {
			c.ReplyingTo = reply.(*forest.Reply)
			author, _, err := c.ArborState.SubscribableStore.GetIdentity(&c.ReplyingTo.Author)
			if err != nil {
				log.Printf("failed looking up select message author: %v", err)
			} else {
				c.ReplyingToAuthor = author.(*forest.Identity)
			}
		}
		c.manager.DismissOverflow(gtx)
		c.ReplyEditor.Focus()
	}
	if c.CreateConversationButton.Clicked() || overflowTag == &c.CreateConversationButton {
		c.CreatingConversation = true
		c.ReplyEditor.Focus()
		c.manager.DismissOverflow(gtx)
	}
	if c.CancelReplyButton.Clicked() {
		c.resetReplyState()
	}
	if c.SendReplyButton.Clicked() {
		var newReply *forest.Reply
		var author *forest.Identity
		if c.CreatingConversation {
			if c.CommunityChoice.Value != "" {
				var chosen *forest.Community
				chosenString := c.CommunityChoice.Value
				c.ArborState.CommunityList.WithCommunities(func(communities []*forest.Community) {
					for _, community := range communities {
						if community.ID().String() == chosenString {
							chosen = community
							break
						}
					}
				})
				nodeBuilder, err := c.Settings.Builder()
				if err != nil {
					log.Printf("failed acquiring node builder: %v", err)
				} else {
					author = nodeBuilder.User
					convo, err := nodeBuilder.NewReply(chosen, c.ReplyEditor.Text(), []byte{})
					if err != nil {
						log.Printf("failed creating new conversation: %v", err)
					} else {
						newReply = convo
					}
				}
			}
		} else {
			nodeBuilder, err := c.Settings.Builder()
			if err != nil {
				log.Printf("failed acquiring node builder: %v", err)
			} else {
				author = nodeBuilder.User
				reply, err := nodeBuilder.NewReply(c.ReplyingTo, c.ReplyEditor.Text(), []byte{})
				if err != nil {
					log.Printf("failed building reply: %v", err)
				} else {
					newReply = reply
				}
			}
		}
		if newReply != nil {
			go func() {
				if err := c.ArborState.SubscribableStore.Add(author); err != nil {
					log.Printf("failed adding replying identity to store: %v", err)
					return
				}
				if err := c.ArborState.SubscribableStore.Add(newReply); err != nil {
					log.Printf("failed adding reply to store: %v", err)
					return
				}
			}()
			c.resetReplyState()
		}
	}

}

func (c *ReplyListView) resetReplyState() {
	c.ReplyingTo = nil
	c.ReplyingToAuthor = nil
	c.CreatingConversation = false
	c.ReplyEditor.SetText("")
}

func (c *ReplyListView) statusOf(reply *forest.Reply) sprigTheme.ReplyStatus {
	if c.Focused == nil {
		return sprigTheme.None
	}
	if c.Focused != nil && reply.ID().Equals(c.Focused) {
		return sprigTheme.Selected
	}
	for _, id := range c.Ancestry {
		if id.Equals(reply.ID()) {
			return sprigTheme.Ancestor
		}
	}
	for _, id := range c.Descendants {
		if id.Equals(reply.ID()) {
			return sprigTheme.Descendant
		}
	}
	if c.Conversation != nil && !c.Conversation.Equals(fields.NullHash()) {
		if c.Conversation.Equals(&reply.ConversationID) {
			return sprigTheme.Sibling
		}
	}
	return sprigTheme.None
}

func (c *ReplyListView) Layout(gtx layout.Context) layout.Dimensions {
	key.InputOp{Tag: c, Focus: c.ShouldRequestKeyboardFocus}.Add(gtx.Ops)
	c.ShouldRequestKeyboardFocus = false
	return layout.Stack{}.Layout(gtx,
		layout.Expanded(func(gtx C) D {
			paintOp := paint.ColorOp{Color: c.Theme.Background.Default}
			paintOp.Add(gtx.Ops)
			paint.PaintOp{Rect: f32.Rectangle{
				Max: layout.FPt(gtx.Constraints.Max),
			}}.Add(gtx.Ops)
			return layout.Dimensions{}
		}),
		layout.Stacked(func(gtx C) D {
			return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
				layout.Flexed(1, func(gtx C) D {
					return c.layoutReplyList(gtx)
				}),
				layout.Rigid(func(gtx C) D {
					if c.ReplyingTo != nil || c.CreatingConversation {
						return c.layoutEditor(gtx)
					}
					return layout.Dimensions{}
				}),
			)
		}),
	)
}

const insetUnit = 12

var (
	defaultInset    = unit.Dp(insetUnit)
	ancestorInset   = unit.Dp(2 * insetUnit)
	selectedInset   = unit.Dp(3 * insetUnit)
	descendantInset = unit.Dp(4 * insetUnit)
)

func (c *ReplyListView) layoutReplyList(gtx layout.Context) layout.Dimensions {
	gtx.Constraints.Min = gtx.Constraints.Max

	theme := c.Theme.Theme
	stateIndex := 0
	var dims layout.Dimensions
	c.ArborState.ReplyList.WithReplies(func(replies []ds.ReplyData) {
		if c.Focused == nil && len(replies) > 0 {
			c.Focused = replies[len(replies)-1].ID()
			c.StateRefreshNeeded = true
			c.requestKeyboardFocus()
		}
		log.Printf("beforelistlayout: %v", c.ReplyList.Position)
		dims = c.ReplyList.Layout(gtx, len(replies), func(gtx layout.Context, index int) layout.Dimensions {
			if stateIndex >= len(c.ReplyStates) {
				c.ReplyStates = append(c.ReplyStates, sprigWidget.Reply{})
			}
			state := &c.ReplyStates[stateIndex]
			reply := replies[index]
			collapseMetadata := false
			if index > 0 {
				if replies[index-1].Author.Equals(&reply.Author) && replies[index-1].ID().Equals(reply.ParentID()) {
					collapseMetadata = true
				}
			}
			var community *forest.Community
			author := reply.Author
			var leftInset unit.Value

			status := c.statusOf(reply.Reply)
			switch status {
			case sprigTheme.Selected:
				leftInset = selectedInset
				collapseMetadata = false
				community = reply.Community
			case sprigTheme.Ancestor:
				leftInset = ancestorInset
			case sprigTheme.Descendant:
				leftInset = descendantInset
			case sprigTheme.Sibling:
				leftInset = defaultInset
			default:
				leftInset = defaultInset
			}
			if c.Filtered && (status == sprigTheme.Sibling || status == sprigTheme.None) {
				// do not render
				return layout.Dimensions{}
			}
			stateIndex++
			return layout.Flex{}.Layout(gtx,
				layout.Flexed(1, func(gtx C) D {
					extraWidth := gtx.Px(unit.Dp(5 * insetUnit))
					messageWidth := gtx.Constraints.Max.X - extraWidth
					return layout.Stack{}.Layout(gtx,
						layout.Stacked(func(gtx C) D {
							gtx.Constraints.Min.X = gtx.Constraints.Max.X
							margin := unit.Dp(3)
							if collapseMetadata {
								margin = unit.Dp(0)
							}
							return layout.Inset{
								Top:    margin,
								Bottom: unit.Dp(3),
								Left:   leftInset,
							}.Layout(gtx, func(gtx C) D {
								gtx.Constraints.Max.X = messageWidth
								replyWidget := sprigTheme.Reply(c.Theme, status)
								replyWidget.CollapseMetadata = collapseMetadata
								return replyWidget.Layout(gtx, reply.Reply, author, community)
							})
						}),
						layout.Expanded(func(gtx C) D {
							dims := state.Clickable.Layout(gtx)
							state.Reply = reply.ID()
							return dims
						}),
					)
				}),
				layout.Rigid(func(gtx C) D {
					return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
						if status != sprigTheme.Selected {
							return D{}
						}
						replyButton := material.IconButton(theme, &c.CreateReplyButton, icons.ReplyIcon)
						replyButton.Size = unit.Dp(20)
						replyButton.Inset = layout.UniformInset(unit.Dp(9))
						replyButton.Background = c.Theme.Secondary.Light
						replyButton.Color = c.Theme.Background.Dark
						return replyButton.Layout(gtx)
					})
				}),
			)
		})
	})
	log.Printf("afterlistlayout: %v", c.ReplyList.Position)
	return dims
}

func (c *ReplyListView) layoutEditor(gtx layout.Context) layout.Dimensions {
	theme := c.Theme.Theme
	return layout.Stack{}.Layout(gtx,
		layout.Expanded(func(gtx C) D {
			paintOp := paint.ColorOp{Color: c.Theme.Primary.Light}
			paintOp.Add(gtx.Ops)
			paint.PaintOp{Rect: f32.Rectangle{
				Max: f32.Point{
					X: float32(gtx.Constraints.Max.X),
					Y: float32(gtx.Constraints.Max.Y),
				},
			}}.Add(gtx.Ops)
			return layout.Dimensions{}
		}),
		layout.Stacked(func(gtx C) D {
			return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
				layout.Rigid(func(gtx C) D {
					return layout.Flex{}.Layout(gtx,
						layout.Rigid(func(gtx C) D {
							return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
								if c.CreatingConversation {
									return material.Body1(theme, "New Conversation in:").Layout(gtx)
								}
								return material.Body1(theme, "Replying to:").Layout(gtx)

							})
						}),
						layout.Flexed(1, func(gtx C) D {
							return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
								if c.CreatingConversation {
									var dims layout.Dimensions
									c.ArborState.CommunityList.WithCommunities(func(comms []*forest.Community) {
										dims = c.CommunityList.Layout(gtx, len(comms), func(gtx layout.Context, index int) layout.Dimensions {
											community := comms[index]
											if c.CommunityChoice.Value == "" && index == 0 {
												c.CommunityChoice.Value = community.ID().String()
											}
											radio := material.RadioButton(theme, &c.CommunityChoice, community.ID().String(), string(community.Name.Blob))
											radio.IconColor = c.Theme.Secondary.Default
											return radio.Layout(gtx)
										})
									})
									return dims
								}
								reply := sprigTheme.Reply(c.Theme, sprigTheme.None)
								reply.Highlight = c.Theme.Primary.Default
								reply.MaxLines = 5
								return reply.Layout(gtx, c.ReplyingTo, c.ReplyingToAuthor, nil)
							})
						}),
						layout.Rigid(func(gtx C) D {
							return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
								cancelButton := material.IconButton(theme, &c.CancelReplyButton, icons.CancelReplyIcon)
								cancelButton.Size = unit.Dp(20)
								cancelButton.Inset = layout.UniformInset(unit.Dp(4))
								return cancelButton.Layout(gtx)
							})
						}),
					)
				}),
				layout.Rigid(func(gtx C) D {
					return layout.Flex{}.Layout(gtx,
						layout.Rigid(func(gtx C) D {
							return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
								pasteButton := material.IconButton(theme, &c.PasteIntoReplyButton, icons.PasteIcon)
								pasteButton.Inset = layout.UniformInset(unit.Dp(4))
								pasteButton.Size = unit.Dp(20)
								return pasteButton.Layout(gtx)
							})
						}),
						layout.Flexed(1, func(gtx C) D {
							return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
								return layout.Stack{}.Layout(gtx,
									layout.Expanded(func(gtx C) D {
										stack := op.Push(gtx.Ops)
										paintOp := paint.ColorOp{Color: c.Theme.Background.Light}
										paintOp.Add(gtx.Ops)
										bounds := f32.Rectangle{
											Max: f32.Point{
												X: float32(gtx.Constraints.Max.X),
												Y: float32(gtx.Constraints.Min.Y),
											},
										}
										radii := float32(gtx.Px(unit.Dp(5)))
										clip.RRect{
											Rect: bounds,
											NW:   radii,
											NE:   radii,
											SE:   radii,
											SW:   radii,
										}.Add(gtx.Ops)
										paint.PaintOp{Rect: bounds}.Add(gtx.Ops)
										stack.Pop()
										return layout.Dimensions{}
									}),
									layout.Stacked(func(gtx C) D {
										return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
											editor := material.Editor(theme, &c.ReplyEditor, "type your reply here")
											return editor.Layout(gtx)
										})
									}),
								)
							})
						}),
						layout.Rigid(func(gtx C) D {
							return layout.UniformInset(unit.Dp(6)).Layout(gtx, func(gtx C) D {
								sendButton := material.IconButton(theme, &c.SendReplyButton, icons.SendReplyIcon)
								sendButton.Size = unit.Dp(20)
								sendButton.Inset = layout.UniformInset(unit.Dp(4))
								sendButton.Background = c.Theme.Primary.Default
								sendButton.Color = c.Theme.Background.Light
								return sendButton.Layout(gtx)
							})
						}),
					)
				}),
			)
		}),
	)
}

func (c *ReplyListView) SetManager(mgr ViewManager) {
	c.manager = mgr
}