main.go

  1// inbox_view is a small helper that renders a mock inbox with realistic emails
  2// for screenshot generation. It wraps the real Inbox component in a model
  3// that forwards window size events properly.
  4package main
  5
  6import (
  7	"fmt"
  8	"os"
  9	"time"
 10
 11	tea "charm.land/bubbletea/v2"
 12	"github.com/floatpane/matcha/config"
 13	"github.com/floatpane/matcha/fetcher"
 14	"github.com/floatpane/matcha/tui"
 15)
 16
 17// wrapper forwards all messages to the FolderInbox and ensures it renders correctly.
 18type wrapper struct {
 19	folderInbox *tui.FolderInbox
 20}
 21
 22func (w wrapper) Init() tea.Cmd {
 23	return w.folderInbox.Init()
 24}
 25
 26func (w wrapper) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
 27	m, cmd := w.folderInbox.Update(msg)
 28	if fi, ok := m.(*tui.FolderInbox); ok {
 29		w.folderInbox = fi
 30	}
 31	return w, cmd
 32}
 33
 34func (w wrapper) View() tea.View {
 35	v := w.folderInbox.View()
 36	v.AltScreen = true
 37	return v
 38}
 39
 40func main() {
 41	now := time.Now()
 42
 43	accounts := []config.Account{
 44		{
 45			ID:         "demo-user",
 46			Name:       "Matcha Client",
 47			Email:      "matcha@floatpane.com",
 48			FetchEmail: "matcha@floatpane.com",
 49		},
 50	}
 51
 52	emails := []fetcher.Email{
 53		{
 54			UID:       1012,
 55			From:      "Alice Park <alice.park@example.com>",
 56			To:        []string{"matcha@floatpane.com"},
 57			Subject:   "Quick sync on the API migration?",
 58			Date:      now.Add(-12 * time.Minute),
 59			MessageID: "<api-migration-012@example.com>",
 60			AccountID: "demo-user",
 61		},
 62		{
 63			UID:       1011,
 64			From:      "GitHub <notifications@github.com>",
 65			To:        []string{"matcha@floatpane.com"},
 66			Subject:   "[floatpane/matcha] Fix: resolve inbox pagination issue (#281)",
 67			Date:      now.Add(-47 * time.Minute),
 68			MessageID: "<gh-notif-281@github.com>",
 69			AccountID: "demo-user",
 70		},
 71		{
 72			UID:       1010,
 73			From:      "Sarah Chen <sarah.chen@example.com>",
 74			To:        []string{"team@example.com"},
 75			Subject:   "New Dashboard Redesign - Preview & Feedback",
 76			Date:      now.Add(-2 * time.Hour),
 77			MessageID: "<dashboard-redesign-001@example.com>",
 78			AccountID: "demo-user",
 79			Attachments: []fetcher.Attachment{
 80				{Filename: "dashboard-mockup.png", MIMEType: "image/png"},
 81			},
 82		},
 83		{
 84			UID:       1009,
 85			From:      "David Kim <david.kim@example.com>",
 86			To:        []string{"matcha@floatpane.com"},
 87			Subject:   "Re: Quarterly budget review notes",
 88			Date:      now.Add(-5 * time.Hour),
 89			MessageID: "<budget-review-009@example.com>",
 90			AccountID: "demo-user",
 91		},
 92		{
 93			UID:       1008,
 94			From:      "Stripe <receipts@stripe.com>",
 95			To:        []string{"matcha@floatpane.com"},
 96			Subject:   "Your receipt from Acme Corp - Invoice #4821",
 97			Date:      now.Add(-23 * time.Hour),
 98			MessageID: "<stripe-receipt-4821@stripe.com>",
 99			AccountID: "demo-user",
100		},
101		{
102			UID:       1007,
103			From:      "Maria Gonzalez <maria.g@example.com>",
104			To:        []string{"matcha@floatpane.com"},
105			Subject:   "Design system tokens - final version attached",
106			Date:      now.Add(-1*24*time.Hour - 6*time.Hour),
107			MessageID: "<design-tokens-007@example.com>",
108			AccountID: "demo-user",
109			Attachments: []fetcher.Attachment{
110				{Filename: "design-tokens-v3.json", MIMEType: "application/json"},
111			},
112		},
113		{
114			UID:       1006,
115			From:      "Linear <notifications@linear.app>",
116			To:        []string{"matcha@floatpane.com"},
117			Subject:   "MAT-342: Implement keyboard shortcuts for compose view",
118			Date:      now.Add(-2*24*time.Hour - 3*time.Hour),
119			MessageID: "<linear-342@linear.app>",
120			AccountID: "demo-user",
121		},
122		{
123			UID:       1005,
124			From:      "James Wright <j.wright@example.com>",
125			To:        []string{"matcha@floatpane.com"},
126			Subject:   "Onboarding docs are ready for review",
127			Date:      now.Add(-3*24*time.Hour - 1*time.Hour),
128			MessageID: "<onboarding-005@example.com>",
129			AccountID: "demo-user",
130		},
131		{
132			UID:       1004,
133			From:      "Vercel <notifications@vercel.com>",
134			To:        []string{"matcha@floatpane.com"},
135			Subject:   "Deployment successful: matcha-docs-8f3a2b1",
136			Date:      now.Add(-4*24*time.Hour - 8*time.Hour),
137			MessageID: "<vercel-deploy-004@vercel.com>",
138			AccountID: "demo-user",
139		},
140		{
141			UID:       1003,
142			From:      "Lena Muller <lena.m@example.com>",
143			To:        []string{"matcha@floatpane.com"},
144			Subject:   "Conference talk proposal - Rethinking TUI Design",
145			Date:      now.Add(-5*24*time.Hour - 2*time.Hour),
146			MessageID: "<conference-003@example.com>",
147			AccountID: "demo-user",
148		},
149		{
150			UID:       1002,
151			From:      "GitHub <notifications@github.com>",
152			To:        []string{"matcha@floatpane.com"},
153			Subject:   "[floatpane/matcha] Release v1.4.0 published",
154			Date:      now.Add(-5*24*time.Hour - 14*time.Hour),
155			MessageID: "<gh-release-140@github.com>",
156			AccountID: "demo-user",
157		},
158		{
159			UID:       1001,
160			From:      "Omar Hassan <omar.h@example.com>",
161			To:        []string{"matcha@floatpane.com"},
162			Subject:   "Re: Open source contribution guidelines",
163			Date:      now.Add(-6*24*time.Hour - 5*time.Hour),
164			MessageID: "<oss-contrib-001@example.com>",
165			AccountID: "demo-user",
166		},
167	}
168
169	folders := []string{
170		"INBOX",
171		"Drafts",
172		"Sent",
173		"Archive",
174		"Receipts",
175		"GitHub",
176		"Trash",
177	}
178
179	folderInbox := tui.NewFolderInbox(folders, accounts)
180	folderInbox.SetEmails(emails, accounts)
181
182	p := tea.NewProgram(wrapper{folderInbox: folderInbox})
183	if _, err := p.Run(); err != nil {
184		fmt.Fprintf(os.Stderr, "Error: %v\n", err)
185		os.Exit(1)
186	}
187}