Add datetime components 196-215; Kit.At; inert stepper arrows
Calendars, date and time inputs, pickers, clocks, timers, a sun dial, a season wheel, an agenda and a day schedule. Kit.At rebuilds at a moment (relative times, midnight). Stepper and NumberInput arrows stop under Inert. DateInput parks a popup focus as its own.
This commit is contained in:
38 files changed
+2651
-5
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package datetime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
|
||||
)
|
||||
|
||||
type AgendaOptions struct{}
|
||||
|
||||
// Agenda groups events by day, earliest first.
|
||||
func Agenda(c *ui.Context, events []Event, o AgendaOptions) *ui.Element {
|
||||
k := pixel.K(c)
|
||||
sorted := slices.Clone(events)
|
||||
slices.SortStableFunc(sorted, func(a, b Event) int { return a.Start.Compare(b.Start) })
|
||||
return ui.Column(c).Gap(k.D(2)).Role(ui.RoleList).Children(func() {
|
||||
var last time.Time
|
||||
for i, e := range sorted {
|
||||
if i == 0 || !sameDay(e.Start, last) {
|
||||
head := fmt.Sprintf("%s %d %s", weekdays(k)[e.Start.Weekday()], e.Start.Day(), monthName(k, e.Start.Month()))
|
||||
ui.Box(c).Padding(k.D(4), 0, 0, 0).Children(func() {
|
||||
pixel.Text(c, head, pixel.TextOptions{Slot: pixel.Faint})
|
||||
})
|
||||
}
|
||||
last = e.Start
|
||||
EventChip(c, e, EventChipOptions{})
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in new issue
Block a user