package formview

import (
	"go_dreamfactory/cmd/v2/model"
	"go_dreamfactory/cmd/v2/service"
	"go_dreamfactory/pb"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/theme"
	"fyne.io/fyne/v2/widget"
	"github.com/sirupsen/logrus"
)

type FriendAssistListView struct {
	BaseformView
	friendAssistList func()
}

func (this *FriendAssistListView) CreateView(t *model.TestCase) fyne.CanvasObject {
	this.friendAssistList = func() {
		if err := service.GetPttService().SendToClient(t.MainType, t.SubType,
			&pb.FriendAssistlistReq{}); err != nil {
			logrus.Error(err)
		}
	}
	defer this.friendAssistList()
	refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() {
		this.friendAssistList()
	})

	buttonBar := container.NewHBox(refreshBtn)
	c := container.NewBorder(buttonBar, nil, nil, nil)
	return c
}
