add update rssi to items
This commit is contained in:
parent
324bfff597
commit
c3f2942b85
0
.logs/2021-05-26T16:34:12Z.log
Normal file
0
.logs/2021-05-26T16:34:12Z.log
Normal file
0
.logs/2021-05-26T16:35:20Z.log
Normal file
0
.logs/2021-05-26T16:35:20Z.log
Normal file
0
.logs/2021-05-26T16:35:32Z.log
Normal file
0
.logs/2021-05-26T16:35:32Z.log
Normal file
0
.logs/2021-05-26T16:45:29Z.log
Normal file
0
.logs/2021-05-26T16:45:29Z.log
Normal file
0
.logs/2021-05-26T16:45:42Z.log
Normal file
0
.logs/2021-05-26T16:45:42Z.log
Normal file
35
tui.go
35
tui.go
@ -129,9 +129,12 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
|
||||
case projVars.DiscoveredDevice:
|
||||
for _, v := range m.choices {
|
||||
for k, v := range m.choices {
|
||||
if strings.HasPrefix(v, fmt.Sprintf("address: %s", msg.ScanResult.Address.String())) {
|
||||
// TODO update RSSI
|
||||
m.choices[k] = fmt.Sprintf("address: %s rssi: %d",
|
||||
msg.ScanResult.Address.String(),
|
||||
msg.ScanResult.RSSI)
|
||||
|
||||
return m, listenForScanResults
|
||||
}
|
||||
}
|
||||
@ -146,7 +149,9 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
fmt.Sprintf("address: %s rssi: %d", msg.ScanResult.Address.String(), msg.ScanResult.RSSI)) */
|
||||
|
||||
m.choices = append(m.choices,
|
||||
fmt.Sprintf("address: %s rssi: %d", msg.ScanResult.Address.String(), msg.ScanResult.RSSI))
|
||||
fmt.Sprintf("address: %s rssi: %d",
|
||||
msg.ScanResult.Address.String(),
|
||||
msg.ScanResult.RSSI))
|
||||
|
||||
return m, listenForScanResults
|
||||
|
||||
@ -199,13 +204,13 @@ func (m model) View() string {
|
||||
s := m.spinner.View(
|
||||
) + lipgloss.NewStyle(
|
||||
).Bold(true,
|
||||
).Foreground(lipgloss.Color("#FAFAFA"),
|
||||
).Background(lipgloss.Color("#7D56F4"),
|
||||
).PaddingTop(0,
|
||||
).PaddingLeft(0,
|
||||
).Width(80,
|
||||
).Render("Scanning for devices",
|
||||
) + "\n\n"
|
||||
).Foreground(lipgloss.Color("#FAFAFA"),
|
||||
).Background(lipgloss.Color("#7D56F4"),
|
||||
).PaddingTop(0,
|
||||
).PaddingLeft(0,
|
||||
).Width(80,
|
||||
).Render("Scanning for devices",
|
||||
) + "\n\n"
|
||||
|
||||
// Iterate over our choices
|
||||
for i, choice := range m.choices {
|
||||
@ -213,13 +218,19 @@ func (m model) View() string {
|
||||
// Is the cursor pointing at this choice?
|
||||
cursor := " " // no cursor
|
||||
if m.cursor == i {
|
||||
cursor = ">" // cursor!
|
||||
//cursor = ">" // cursor!
|
||||
cursor = lipgloss.NewStyle(
|
||||
).Blink(true,
|
||||
).Render(">")
|
||||
}
|
||||
|
||||
// Is this choice selected?
|
||||
checked := " " // not selected
|
||||
if _, ok := m.selected[i]; ok {
|
||||
checked = "x" // selected!
|
||||
//checked = "x" // selected!
|
||||
checked = lipgloss.NewStyle(
|
||||
).Bold(true,
|
||||
).Render("x")
|
||||
}
|
||||
|
||||
// Render the row
|
||||
|
Loading…
Reference in New Issue
Block a user