package formview

import (
	"go_dreamfactory/cmd/v2/lib/common"
	"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 UserSignView struct {
	BaseformView
}

func (this *UserSignView) CreateView(t *model.TestCase) fyne.CanvasObject {
	sign := widget.NewMultiLineEntry()
	sign.PlaceHolder = "这个家伙很懒,什么都没有留下"
	this.form.AppendItem(widget.NewFormItem(common.APP_TESTCASE_FORM_SIGN, sign))

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

	}
	return this.form
}
