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/container" "fyne.io/fyne/v2/widget" "github.com/sirupsen/logrus" "github.com/spf13/cast" ) type HeroStrengthenUpStarView struct { BaseformView } func (this *HeroStrengthenUpStarView) CreateView(t *model.TestCase) fyne.CanvasObject { heroObjID := widget.NewEntry() //HeroRace heroRaceId := widget.NewEntry() heroRaceId.PlaceHolder = common.APP_TESTCASE_FORM_LABEL_OID heroRaceAmount := widget.NewEntry() heroRaceAmount.PlaceHolder = common.APP_TESTCASE_FORM_LABEL_NUM heroRaceId2 := widget.NewEntry() heroRaceId2.PlaceHolder = common.APP_TESTCASE_OPTIONS heroRaceAmount2 := widget.NewEntry() heroRaceAmount2.PlaceHolder = common.APP_TESTCASE_OPTIONS //Hero heroId := widget.NewEntry() heroId.PlaceHolder = common.APP_TESTCASE_FORM_LABEL_OID heroAmount := widget.NewEntry() heroAmount.PlaceHolder = common.APP_TESTCASE_FORM_LABEL_NUM heroId2 := widget.NewEntry() heroId2.PlaceHolder = common.APP_TESTCASE_OPTIONS heroAmount2 := widget.NewEntry() heroAmount2.PlaceHolder = common.APP_TESTCASE_OPTIONS heroRace := container.NewGridWithColumns(2, heroRaceId, heroRaceAmount, heroRaceId2, heroRaceAmount2) hero := container.NewGridWithColumns(2, heroId, heroAmount, heroId2, heroAmount2) this.form.AppendItem(widget.NewFormItem(common.APP_TESTCASE_FORM_LABEL_HEROOBJID, heroObjID)) this.form.AppendItem(widget.NewFormItem(common.APP_TESTCASE_FORM_LABEL_RACECARD, heroRace)) this.form.AppendItem(widget.NewFormItem(common.APP_TESTCASE_FORM_LABEL_CARD, hero)) this.form.OnSubmit = func() { // heroRace var heroRace []*pb.CostCardData if heroRaceId.Text != "" && heroRaceAmount.Text != "" { heroRace = append(heroRace, &pb.CostCardData{ CostCardObj: heroRaceId.Text, Amount: cast.ToInt32(heroRaceAmount.Text), }) } if heroRaceId2.Text != "" && heroRaceAmount2.Text != "" { heroRace = append(heroRace, &pb.CostCardData{ CostCardObj: heroRaceId2.Text, Amount: cast.ToInt32(heroRaceAmount2.Text), }) } //hero var hero []*pb.CostCardData if heroId.Text != "" && heroAmount.Text != "" { hero = append(hero, &pb.CostCardData{ CostCardObj: heroId.Text, Amount: cast.ToInt32(heroAmount.Text), }) } if heroId2.Text != "" && heroAmount2.Text != "" { hero = append(hero, &pb.CostCardData{ CostCardObj: heroId2.Text, Amount: cast.ToInt32(heroAmount2.Text), }) } if err := service.GetPttService().SendToClient(t.MainType, t.SubType, &pb.HeroStrengthenUpStarReq{ HeroObjID: heroObjID.Text, HeroRace: heroRace, Hero: hero, }); err != nil { logrus.Error(err) return } } return this.form }