Skip to content
Myr

Exit example after pretend loading is completed

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Christian Rocha · committed by Christian Rocha · parent 5999ff4 · Browse files · 1 file+24 added−8 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+24 added−8 removed

  • other:+24 added−8 removed

1 file+24 added−8 removed

modified:example/main.go+24 added-8 removed
15 unmodified lines
16 Chosen bool17 Ticks int18 Frames int19 Progress float6420 Loaded bool21}2223type tickMsg struct{}2425type frameMsg struct{}2627func main() {28 p := tea.NewProgram(28 Model{0, false, 10, 0, 0},29 Model{0, false, 10, 0, 0, false},30 update,31 view,32 []tea.Sub{tick, frame},33 )
78 unmodified lines
112 return m, tea.Quit113 }114115 case frameMsg:116 if !m.Loaded {115 m.Frames += 1116 m.Progress = ease.OutBounce(float64(m.Frames) / float64(120))117 if m.Progress > 1 {118 m.Progress = 1117 m.Frames += 1118 m.Progress = ease.OutBounce(float64(m.Frames) / float64(60))119 if m.Progress >= 1 {120 m.Progress = 1121 m.Loaded = true122 m.Ticks = 3123 }124 }120 return m, nil125126 case tickMsg:127 if m.Loaded {128 if m.Ticks == 0 {129 return m, tea.Quit130 }131 m.Ticks -= 1132 }133 }134135 return m, nil136}
38 unmodified lines
175 msg = "Carrot planting?\n\nCool, we'll need libgarden and vegeutils..."176 case 1:177 msg = "A trip to the market?\n\nOkay, then we should install marketkit and libshopping..."178 case 2:168 msg = "Reading time?\n\nOkay, cool, then we’ll need a library. Yes, a literal library..."179 msg = "Reading time?\n\nOkay, cool, then we’ll need a library. Yes, an actual library."180 default:181 msg = "It’s always good to see friends.\n\nFetching social-skills and conversationutils..."182 }183184 label := "Downloading..."185 if m.Loaded {186 label = fmt.Sprintf("Downloaded. Exiting in %d...", m.Ticks)187 }188173 return "\n" + msg + "\n\n\n\n\n Downloading...\n" + progressbar(80, m.Progress) + "%"189 return msg + "\n\n\n\n\n\n " + label + "\n" + progressbar(80, m.Progress) + "%"190}191192func checkbox(label string, checked bool) string {193 check := " "
15 unmodified lines