From 1e7e10b2f9823155678a8c53741ed0ae80c83088 Mon Sep 17 00:00:00 2001 From: Ani Channarasappa Date: Sun, 27 Dec 2020 13:13:49 -0500 Subject: [PATCH] Removed experimental code --- cmd/main.go | 6 -- internal/ui/render-old.go | 65 --------------------- internal/ui/ui-old.go | 120 -------------------------------------- 3 files changed, 191 deletions(-) delete mode 100644 internal/ui/render-old.go delete mode 100644 internal/ui/ui-old.go diff --git a/cmd/main.go b/cmd/main.go index 067652d..e3e5d23 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -9,12 +9,6 @@ import ( ) func main() { - // fmt.Printf("%#v \n", quote.GetQuotes([]string{"ABNB", "PLTR"})) - - // quotes := []quote.Quote{ - // {Symbol: "AAPL", ShortName: "Apple, Inc.", RegularMarketPrice: 1000.1, RegularMarketChange: 10.1, RegularMarketChangePercent: 1.1}, - // {Symbol: "ABNB", ShortName: "AirBnB, Inc.", RegularMarketPrice: 645.1, RegularMarketChange: 4.1, RegularMarketChangePercent: 0.9}, - // } symbols := []string{ "NET", diff --git a/internal/ui/render-old.go b/internal/ui/render-old.go deleted file mode 100644 index 33713c9..0000000 --- a/internal/ui/render-old.go +++ /dev/null @@ -1,65 +0,0 @@ -package ui - -// import ( -// "log" -// "strconv" -// "ticker-tape/internal/quote" - -// ui "github.com/gizak/termui/v3" -// "github.com/gizak/termui/v3/widgets" - -// . "github.com/novalagung/gubrak" -// ) - -// func convertQuotesToRows(quotes []quote.Quote) [][]string { - -// rows, _ := Reduce(quotes, func(acc [][]string, quote quote.Quote) [][]string { -// return append(acc, []string{ -// quote.ShortName, -// strconv.FormatFloat(quote.RegularMarketPrice, 'f', 2, 64), -// strconv.FormatFloat(quote.RegularMarketChange, 'f', 2, 64), -// strconv.FormatFloat(quote.RegularMarketChangePercent, 'f', 2, 64), -// }) -// }, [][]string{{"Symbol", "RegularMarketPrice", "RegularMarketChange", "RegularMarketChangePercent"}}) - -// return (rows).([][]string) - -// } - -// func renderQuotes(quotes []quote.Quote) { - -// table1 := widgets.NewTable() -// table1.Rows = convertQuotesToRows(quotes) -// table1.TextStyle = ui.NewStyle(ui.ColorWhite) -// table1.BorderStyle = ui.NewStyle(ui.ColorBlack) -// table1.Border = false -// table1.RowStyles[0] = ui.NewStyle(ui.ColorCyan) -// table1.SetRect(0, 0, 50, 10) - -// ui.Render(table1) - -// } - -// func handleInput() { -// uiEvents := ui.PollEvents() -// for { -// select { -// case e := <-uiEvents: -// switch e.ID { -// case "q", "": -// ui.Close() -// return -// } -// } -// } -// } - -// func Render(quotes []quote.Quote) { -// if err := ui.Init(); err != nil { -// log.Fatalf("failed to initialize termui: %v", err) -// } - -// renderQuotes(quotes) -// handleInput() - -// } diff --git a/internal/ui/ui-old.go b/internal/ui/ui-old.go deleted file mode 100644 index 46cbcd5..0000000 --- a/internal/ui/ui-old.go +++ /dev/null @@ -1,120 +0,0 @@ -package ui - -// import ( -// "fmt" -// "strconv" -// "strings" -// "ticker-tape/internal/quote" -// . "ticker-tape/internal/ui/component" - -// "github.com/charmbracelet/bubbles/viewport" -// tea "github.com/charmbracelet/bubbletea" -// "github.com/muesli/reflow/ansi" -// "github.com/muesli/termenv" -// ) - -// var ( -// color = termenv.ColorProfile().Color -// footerHighlightStyle = termenv.Style{}.Foreground(color("#ffc27d")).Background(color("#f37329")).Bold().Styled -// helpStyle = termenv.Style{}.Foreground(color("241")).Styled -// quoteNeutralStyle = termenv.Style{}.Foreground(color("#d4d4d4")).Bold().Styled -// quoteNeutralFadedStyle = termenv.Style{}.Foreground(color("#7e8087")).Styled -// quotePricePositiveStyle = termenv.Style{}.Foreground(color("#d1ff82")).Styled -// quotePriceNegativeStyle = termenv.Style{}.Foreground(color("#ff8c82")).Styled -// ) - -// const ( -// footerHeight = 1 -// ) - -// type Model struct { -// content string -// ready bool -// viewport viewport.Model -// } - -// func (m Model) Init() tea.Cmd { -// return nil -// } - -// func (m Model) Update(message tea.Msg) (tea.Model, tea.Cmd) { -// switch msg := message.(type) { - -// case tea.KeyMsg: -// switch msg.String() { -// case "ctrl+c": -// fallthrough -// case "esc": -// fallthrough -// case "q": -// return m, tea.Quit -// } - -// case tea.WindowSizeMsg: -// verticalMargins := footerHeight - -// if !m.ready { -// m.viewport = viewport.Model{Width: msg.Width, Height: msg.Height - verticalMargins} -// m.viewport.SetContent(m.content) -// m.ready = true -// } else { -// m.viewport.Width = msg.Width -// m.viewport.Height = msg.Height - verticalMargins -// } - -// } - -// return m, nil -// } - -// func (m Model) View() string { -// if !m.ready { -// return "\n Initalizing..." -// } - -// quotes := []quote.Quote{ -// {Symbol: "AAPL", ShortName: "Apple, Inc.", RegularMarketPrice: 1000.1, RegularMarketChange: 10.1, RegularMarketChangePercent: 1.1}, -// {Symbol: "ABNB", ShortName: "AirBnB, Inc.", RegularMarketPrice: 645.1, RegularMarketChange: 4.1, RegularMarketChangePercent: 0.9}, -// } - -// m.viewport.SetContent(quoteSummaries(quotes, m.viewport.Width)) -// return fmt.Sprintf("%s\n%s", m.viewport.View(), footer(m.viewport.Width)) -// } - -// func footer(elementWidth int) string { -// return footerHighlightStyle(" 🚀 ticker-tape ") + helpStyle(" q: exit") -// } - -// func quoteSummaries(q []quote.Quote, elementWidth int) string { -// quoteSummaries := "" -// for _, quote := range q { -// quoteSummaries = quoteSummaries + "\n\n" + quoteSummary(quote, elementWidth) -// } -// return quoteSummaries -// } - -// func quoteSummary(q quote.Quote, elementWidth int) string { - -// firstLine := lineWithGap( -// quoteNeutralStyle(q.Symbol), -// quoteNeutralStyle(convertFloatToString(q.RegularMarketPrice)), -// elementWidth, -// ) -// secondLine := lineWithGap( -// quoteNeutralFadedStyle(q.ShortName), -// quotePricePositiveStyle("↑ "+convertFloatToString(q.RegularMarketChange)+" ("+convertFloatToString(q.RegularMarketChangePercent)+"%)"), -// elementWidth, -// ) - -// return fmt.Sprintf("%s\n%s", firstLine, secondLine) -// } - -// // util -// func lineWithGap(leftText string, rightText string, elementWidth int) string { -// innerGapWidth := elementWidth - ansi.PrintableRuneWidth(leftText) - ansi.PrintableRuneWidth(rightText) -// return leftText + strings.Repeat(" ", innerGapWidth) + rightText -// } - -// func convertFloatToString(f float64) string { -// return strconv.FormatFloat(f, 'f', 2, 64) -// }