-
Notifications
You must be signed in to change notification settings - Fork 4
/
courseMaster.go
57 lines (45 loc) · 1.38 KB
/
courseMaster.go
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
package main
import (
// "encoding/json"
// "io/ioutil"
// "net/http"
// "github.com/spf13/viper"
// "fmt"
// "log"
// "math"
// "strconv"
// "time"
// "reflect"
// "time"
// "bytes"
// strip "github.com/grokify/html-strip-tags-go"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
// ui "github.com/GideonWolfe/termui/v3"
// "github.com/GideonWolfe/termui/v3/widgets"
)
// based on an input course object, this function generates
// a grid with widgets populated with data from the course
func createCourseGrid(course Course, assignments *[]Assignment, announcements *[]Announcement, assignmentGroups *[]AssignmentGroup) *ui.Grid {
// var assignments *[]Assignment = fetchAssignments(course.ID)
// list to select view of course
l := widgets.NewList()
l.Title = "Pages"
l.Rows = []string{}
l.TextStyle = ui.NewStyle(ui.ColorYellow)
l.WrapText = false
for _, tab := range course.Tabs {
l.Rows = append(l.Rows, tab.Label)
}
courseGrid := ui.NewGrid()
termWidth, termHeight := ui.TerminalDimensions()
courseGrid.SetRect(0, 0, termWidth, termHeight)
courseGrid.Title = "Course Master Grid"
courseGrid.Set(
ui.NewRow(1.0,
ui.NewCol(1.0/6, l), // left column for pages
ui.NewCol(5.0/6,createCourseOverviewGrid(course, assignments, announcements, assignmentGroups)), // column for everything else
),
)
return courseGrid
}