Documentation
¶
Index ¶
- Variables
- func AddAlbumsToUi(rooms *Rooms, artMap map[string][]model.Message, channel *Room, ...)
- func MapDto(ui *UI, channels *model.Rooms, albums *model.Messages, g *gen.Generator)
- type CachedImage
- type Channel
- type ChannelConfig
- type ChannelStyle
- type Image
- type Room
- func (r *Room) ClearSync(siteId uint32)
- func (r *Room) DeleteRow(serial list.Serial)
- func (r *Room) DownloadAlbum(siteId uint32, albumId []string, trackQuality string)
- func (r *Room) DownloadArtist(siteId uint32, artistId string, trackQuality string)
- func (r *Room) RunSearch(searchText string)
- func (r *Room) SyncArtist(rooms *Rooms, siteId uint32)
- type Rooms
- func (r *Rooms) Active() *Room
- func (r *Rooms) DeleteChannel(index int, siteId uint32) []*Room
- func (r *Rooms) GetBaseChannel() *Room
- func (r *Rooms) GetChannelById(artistId string) *Room
- func (r *Rooms) Index(index int) *Room
- func (r *Rooms) SelectAndFill(siteId uint32, index int, albs []model.Message, invalidator func(), ...)
- type Row
- type RowConfig
- type RowStyle
- type RowTracker
- func (rt *RowTracker) Add(r list.Element)
- func (rt *RowTracker) AddAll(r []list.Element)
- func (rt *RowTracker) Delete(serial list.Serial)
- func (rt *RowTracker) DeleteAll()
- func (rt *RowTracker) Index(ii int) list.Element
- func (rt *RowTracker) Latest() list.Element
- func (rt *RowTracker) Load(dir list.Direction, relativeTo list.Serial) (loaded []list.Element, more bool)
- type SeparatorStyle
- type UI
Constants ¶
This section is empty.
Variables ¶
var ( // SidebarMaxWidth specifies how large the sidebar should be on // desktop layouts. SidebarMaxWidth = unit.Dp(250) // Breakpoint at which to switch from desktop to mobile layout. Breakpoint = unit.Dp(600) )
Functions ¶
func AddAlbumsToUi ¶
Types ¶
type CachedImage ¶
type CachedImage struct {
// contains filtered or unexported fields
}
CachedImage is a cacheable image operation.
func (*CachedImage) Cache ¶
func (img *CachedImage) Cache(src image.Image) *CachedImage
Cache the image if it is not already. First call will compute the image operation, subsequent calls will noop. When reloaded, cache will re-populated on next invocation.
func (CachedImage) Op ¶
func (img CachedImage) Op() paint.ImageOp
Op returns the concrete image operation.
func (*CachedImage) Reload ¶
func (img *CachedImage) Reload()
Reload tells the CachedImage to repopulate the cache.
type Channel ¶
type Channel struct { // ContextArea holds the clicks state for the right-click context menu. component.ContextArea widget.Clickable Image CachedImage Active bool }
Channel selector state.
type ChannelConfig ¶
type ChannelConfig struct { // Name of the room as raw text. Name string // Image of the room. Image image.Image // Content of the latest message as raw text. Content string // Count of the latest message. Count string }
ChannelConfig configures room item display.
type ChannelStyle ¶
type ChannelStyle struct { *Channel Image Image Name material.LabelStyle Summary material.LabelStyle Count material.LabelStyle Indicator color.NRGBA Overlay color.NRGBA // Menu configures the right-click context menu for channel. Menu component.MenuStyle }
func CreateChannel ¶
func CreateChannel(th *material.Theme, interact *Channel, menu *component.MenuState, room *ChannelConfig) ChannelStyle
CreateChannel creates a style type that can lay out the data for a room.
func (ChannelStyle) Layout ¶
func (room ChannelStyle) Layout(gtx layout.Context) layout.Dimensions
type Image ¶
type Image struct { widget.Image widget.Clickable // Radii specifies the amount of rounding. Radii unit.Dp // Width and Height specify respective dimensions. // If left empty, dimensions will be unconstrained. Width, Height unit.Dp }
Image lays out an image with optionally rounded corners.
type Room ¶
type Room struct { // Room model defines the backend data describing a room. *model.Room // Interact defines the interactive state for a room widget. Interact Channel // RowTracker implements what would be a backend data model. // This would be the facade to your business api. // This is the source of truth. // This type gets asked to create messages and queried for message history. RowTracker *RowTracker // ListState dynamically manages list state. // This lets us surf across a vast ocean of infinite messages, only ever // rendering what is actually viewable. // The widget.List consumes this during layout. ListState *list.Manager // List implements the raw scrolling, adding scrollbars and responding // to mousewheel / touch fling gestures. List widget.List // Editor contains the edit buffer for composing messages. Editor widget.Editor sync.Mutex }
Room is a unique conversation context. Note(jfm): Allocates model and interact, not sure about that. Avoids the UI needing to allocate two lists (interact/model) for the rooms.
func (*Room) DeleteRow ¶
DeleteRow removes the row with the provided serial from both the row tracker and the list manager for the room.
func (*Room) DownloadAlbum ¶
func (*Room) DownloadArtist ¶
func (*Room) SyncArtist ¶
type Rooms ¶
Rooms contains a selectable list of rooms.
func (*Rooms) GetBaseChannel ¶
func (*Rooms) GetChannelById ¶
type Row ¶
type Row struct { // ContextArea holds the clicks state for the right-click context menu. component.ContextArea // Image contains the cached image op for the message. Avatar CachedImage // Message widget.Clickable Active bool Selected widget.Bool }
Row holds persistent state for a single row of a chat.
type RowStyle ¶
type RowStyle struct { *Row Image Image Name material.LabelStyle Summary material.LabelStyle TimeStamp material.LabelStyle Type material.LabelStyle Selected material.CheckBoxStyle Indicator color.NRGBA Overlay color.NRGBA // Menu configures the right-click context menu for this message. Menu component.MenuStyle }
type RowTracker ¶
type RowTracker struct { // SimulateLatency is the maximum latency in milliseconds to // simulate on loads. // SimulateLatency int sync.Mutex Rows []list.Element SerialToIndex map[list.Serial]int // Users *model.Users Messages *model.Messages // Local *model.User Generator *gen.Generator // MaxLoads specifies the number of elements a given load in either // direction can return. MaxLoads int ScrollToEnd bool }
RowTracker is a stand-in for an application's data access logic. It stores a set of chat messages and can load them on request. It simulates network latency during the load operations for realism.
func (*RowTracker) Add ¶
func (rt *RowTracker) Add(r list.Element)
Add a list element as a row of data to track.
func (*RowTracker) AddAll ¶
func (rt *RowTracker) AddAll(r []list.Element)
func (*RowTracker) Delete ¶
func (rt *RowTracker) Delete(serial list.Serial)
Delete removes the element with the provided serial from storage.
func (*RowTracker) DeleteAll ¶
func (rt *RowTracker) DeleteAll()
func (*RowTracker) Index ¶
func (rt *RowTracker) Index(ii int) list.Element
Index returns the element at the given index, or nil.
func (*RowTracker) Latest ¶
func (rt *RowTracker) Latest() list.Element
Latest returns the latest element, or nil.
type SeparatorStyle ¶
type SeparatorStyle struct { Message material.LabelStyle TextMargin layout.Inset LineMargin layout.Inset LineWidth unit.Dp }
SeparatorStyle configures the presentation of the unread indicator.
func DateSeparator ¶
func DateSeparator(th *material.Theme, date time.Time) SeparatorStyle
DateSeparator makes a SeparatorStyle with indicating the transition to the date provided in the time.Time.
func UnreadSeparator ¶
func UnreadSeparator(th *material.Theme) SeparatorStyle
UnreadSeparator fills in a SeparatorStyle with sensible defaults.
func (SeparatorStyle) Layout ¶
func (u SeparatorStyle) Layout(gtx layout.Context) layout.Dimensions
Layout the Separator.
type UI ¶
type UI struct { // Loader loads resources asynchronously. // Deallocates stale resources. // Stale is defined as "not being scheduled frequently". async.Loader // Rooms is the root of the data, containing messages chunked by // room. // It also contains interact state, rather than maintaining two // separate lists for the model and state. Rooms Rooms // RowTracker *model.Messages // RoomList for the sidebar. RoomList widget.List // Back button navigates out of a room. Back widget.Clickable // InsideRoom if we are currently in the room view. // Used to decide when to render the sidebar on small viewports. InsideRoom bool // channel menu SyncBtn, DownloadChannelBtn, DownloadChannelHqBtn, DownloadChannelLowBtn, CopyChannelBtn, DeleteBtn widget.Clickable // message menu CopyAlbBtn, CopyAlbArtistBtn, DownloadBtn, DownloadHqBtn, DownloadLowBtn widget.Clickable // MessageMenu is the context menu available on messages. MessageMenu component.MenuState // ChannelMenu is the context menu available on channel. ChannelMenu component.MenuState // ContextMenuTarget tracks the message state on which the context // menu is currently acting. ContextMenuTarget *model.Message ChannelMenuTarget *Room Invalidator func() Conf *page.Config SiteId uint32 RadioButtonsGroup widget.Enum // contains filtered or unexported fields }
UI manages the state for the entire application's UI.
func (*UI) AddChannel ¶
func (*UI) Layout ¶
func (ui *UI) Layout(gtx layout.Context) layout.Dimensions
Layout the application UI.