summaryrefslogtreecommitdiff
path: root/client/user_messages.go
blob: 80b8fcc079bd794dc0c69aca33181c6a7422ab63 (plain)
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
package main

import (
	"citrons.xyz/talk/tui"
	"fmt"
)

type nameChangeMsg struct {
	index int
	uid string
	oldName string
	newName string
}

type userStatusMsg struct {
	index int
	uid string
	username string
	status string
}

func (m nameChangeMsg) Id() string {
	return fmt.Sprintf("name change.%d", m.index)
}

func (m userStatusMsg) Id() string {
	return fmt.Sprintf("user status.%d", m.index)
}

func (m nameChangeMsg) Show(odd bool) {
	tui.Push("", tui.Box {Width: tui.Fill, Height: tui.TextSize})
	tui.Text("nick: ", &tui.Style {
		Fg: tui.BrightBlack, Bg: colorDefault[odd],
	})
	tui.Text(m.oldName, &tui.Style {
		Fg: tui.White, Bg: colorDefault[odd], Italic: true,
	})
	tui.Text(" -> ", &tui.Style {
		Fg: tui.BrightBlack, Bg: colorDefault[odd],
	})
	tui.Text(m.newName, &tui.Style {
		Fg: tui.White, Bg: colorDefault[odd], Bold: true,
	})
	tui.Pop()
}

func (m userStatusMsg) Show(odd bool) {
	tui.Push("", tui.Box {Width: tui.Fill, Height: tui.TextSize})
	tui.Text("status: ", &tui.Style {
		Fg: tui.BrightBlack, Bg: colorDefault[odd],
	})
	tui.Text(m.username, &tui.Style {
		Fg: tui.White, Bg: colorDefault[odd], Bold: true,
	})
	tui.Text(" : ", &tui.Style {
		Fg: tui.BrightBlack, Bg: colorDefault[odd],
	})
	tui.Text(m.status, nil)
	tui.Pop()
}