package formview

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

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

// 修改背景
type UserModifybgpView struct {
	BaseformView
}

func (this *UserModifybgpView) CreateView(t *model.TestCase) fyne.CanvasObject {
	bgpId := widget.NewEntry()
	this.form.AppendItem(widget.NewFormItem("背景ID", bgpId))

	this.form.OnSubmit = func() {
		if err := service.GetPttService().SendToClient(
			t.MainType,
			t.SubType,
			&pb.UserModifybgpReq{BgpId: bgpId.Text},
		); err != nil {
			logrus.Error(err)
			return
		}

	}

	return this.form
}
