Documentation ¶
Index ¶
- Variables
- type C
- type Config
- type D
- type Room
- type Rooms
- type RowTracker
- func (rt *RowTracker) Add(r list.Element)
- func (r *RowTracker) Delete(serial list.Serial)
- func (r *RowTracker) Index(ii int) list.Element
- func (r *RowTracker) Latest() list.Element
- func (r *RowTracker) Load(dir list.Direction, relativeTo list.Serial) (loaded []list.Element, more bool)
- func (r *RowTracker) NewRow() list.Element
- func (rt *RowTracker) Send(user, content string) model.Message
- type UI
Constants ¶
This section is empty.
Variables ¶
var ( // SidebarMaxWidth specifies how large the side bar should be on // desktop layouts. SidebarMaxWidth = unit.Dp(250) // Breakpoint at which to switch from desktop to mobile layout. Breakpoint = unit.Dp(600) )
widget.NewIcon(icons.NavigationArrowBack) return icon }()icon, _ :=
var Send *widget.Icon = func() *widget.Icon { icon, _ := widget.NewIcon(icons.ContentSend) return icon }()
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // theme to use {light,dark}. Theme string // usePlato to use plato themed widgets. UsePlato bool // latency specifies maximum latency (in millis) to simulate Latency int // loadSize specifies maximum number of items to load at a time. LoadSize int // bufferSize specifies how many elements to hold in memory before // compacting the list. BufferSize int // ScrollToEnd controls whether the chat interfaces start looking at the beginning // or end of the chat content. ScrollToEnd bool }
type D ¶
type D = layout.Dimensions
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 appwidget.Room // Messages 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. Messages *RowTracker // ListState dynamically manages list state. // This lets us surf across a vast ocean of infinite messages, only ever // rendering what is actualy 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) NewRow ¶
func (r *Room) NewRow()
NewRow generates a new row in the Room's RowTracker and inserts it into the list manager for the room.
func (*Room) SendLocal ¶
SendLocal attempts to send the contents of the edit buffer as a to the model. All of the work of this method is dispatched in a new goroutine so that it can safely be called from layout code without blocking.
func (*Room) SetComposing ¶
SetComposing sets the composing status for a user in this room. Note: doesn't actually verify the user pertains to this room.
type Rooms ¶
Rooms contains a selectable list of rooms.
func (*Rooms) Index ¶
Index returns a pointer to a Room at the given index. Index is bounded by [0, len(rooms)).
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 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 NewExampleData ¶
NewExampleData constructs a RowTracker populated with the provided quantity of messages.
func (*RowTracker) Add ¶
func (rt *RowTracker) Add(r list.Element)
Add a list element as a row of data to track.
func (*RowTracker) Delete ¶
func (r *RowTracker) Delete(serial list.Serial)
Delete removes the element with the provided serial from storage.
func (*RowTracker) Index ¶
func (r *RowTracker) Index(ii int) list.Element
Index returns the element at the given index, or nil.
func (*RowTracker) Latest ¶
func (r *RowTracker) Latest() list.Element
Latest returns the latest element, or nil.
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 // Local user for this client. Local *model.User // Users contains user data. Users *model.Users // RoomList for the sidebar. RoomList widget.List // Modal can show widgets atop the rest of the ui. Modal component.ModalState // Bg is the background color of the content area. Bg color.NRGBA // 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 // AddBtn holds click state for a button that adds a new message to // the current room. AddBtn widget.Clickable // DeleteBtn holds click state for a button that removes a message // from the current room. DeleteBtn widget.Clickable // MessageMenu is the context menu available on messages. MessageMenu component.MenuState // ContextMenuTarget tracks the message state on which the context // menu is currently acting. ContextMenuTarget *model.Message // contains filtered or unexported fields }
UI manages the state for the entire application's UI.