无红点时key也返回
This commit is contained in:
parent
d9a1a7584d
commit
e6cb3b71b2
@ -1,22 +1,35 @@
|
||||
package formview
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/cmd/v2/lib/common"
|
||||
"go_dreamfactory/cmd/v2/model"
|
||||
"go_dreamfactory/cmd/v2/service"
|
||||
"go_dreamfactory/cmd/v2/service/observer"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
"strings"
|
||||
|
||||
"fyne.io/fyne/v2"
|
||||
"fyne.io/fyne/v2/container"
|
||||
"fyne.io/fyne/v2/theme"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
type ReddotView struct {
|
||||
reddotList func()
|
||||
BaseformView
|
||||
itemList *common.ItemList
|
||||
flag bool
|
||||
}
|
||||
|
||||
func (this *ReddotView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
this.itemList = common.NewItemList()
|
||||
|
||||
this.itemList.ItemList = this.itemList.CreateList()
|
||||
|
||||
reddotTypeEntry := widget.NewEntry()
|
||||
|
||||
this.form.AppendItem(widget.NewFormItem("红点类型", reddotTypeEntry))
|
||||
@ -33,5 +46,51 @@ func (this *ReddotView) CreateView(t *model.TestCase) fyne.CanvasObject {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
return this.form
|
||||
|
||||
this.reddotList = func() {
|
||||
if err := service.GetPttService().SendToClient(
|
||||
string(comm.ModuleReddot),
|
||||
"getall",
|
||||
&pb.ReddotGetAllReq{}); err != nil {
|
||||
logrus.Error(err)
|
||||
}
|
||||
}
|
||||
|
||||
defer this.reddotList()
|
||||
|
||||
refreshBtn := widget.NewButtonWithIcon("", theme.ViewRefreshIcon(), func() {
|
||||
this.itemList.Reset()
|
||||
this.reddotList()
|
||||
})
|
||||
|
||||
this.dataListener()
|
||||
buttonBar := container.NewHBox(refreshBtn)
|
||||
c := container.NewBorder(buttonBar, this.form, nil, nil, this.itemList.ItemList)
|
||||
return c
|
||||
}
|
||||
|
||||
func (this *ReddotView) dataListener() {
|
||||
this.obs.AddListener(observer.EVENT_REQ_RSP, observer.Listener{
|
||||
OnNotify: func(d interface{}, args ...interface{}) {
|
||||
data := d.(*pb.UserMessage)
|
||||
if !(data.MainType == string(comm.ModuleReddot) &&
|
||||
data.SubType == "getall") {
|
||||
return
|
||||
}
|
||||
rsp := &pb.ReddotGetAllResp{}
|
||||
|
||||
if !comm.ProtoUnmarshal(data, rsp) {
|
||||
logrus.Error("unmarshal err")
|
||||
}
|
||||
|
||||
for k, v := range rsp.Reddot {
|
||||
item := common.Item{
|
||||
Id: cast.ToString(k),
|
||||
Text: fmt.Sprintf("%v - %v", k, v),
|
||||
}
|
||||
this.itemList.AddItem(item)
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -141,9 +141,8 @@ func (this *Sociaty) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (
|
||||
for _, v := range rid {
|
||||
switch v {
|
||||
case comm.Reddot3:
|
||||
if ok := this.modelSociaty.IsSign(session.GetUserId(), sociaty); !ok {
|
||||
reddot[comm.Reddot3] = true
|
||||
}
|
||||
tf := this.modelSociaty.IsSign(session.GetUserId(), sociaty)
|
||||
reddot[comm.Reddot3] = tf
|
||||
case comm.Reddot29:
|
||||
reddot[comm.Reddot29] = applyReddot
|
||||
}
|
||||
|
@ -144,28 +144,21 @@ func (this *ModuleTask) Reddot(session comm.IUserSession, rid ...comm.ReddotType
|
||||
for _, v := range rid {
|
||||
switch v {
|
||||
case comm.Reddot1:
|
||||
if ok, _ := this.modelTask.noReceiveTask(session.GetUserId(), comm.TASK_DAILY); ok {
|
||||
reddot[comm.Reddot1] = ok
|
||||
break
|
||||
}
|
||||
tf, _ := this.modelTask.noReceiveTask(session.GetUserId(), comm.TASK_DAILY)
|
||||
reddot[comm.Reddot1] = tf
|
||||
case comm.Reddot2:
|
||||
if ok, _ := this.modelTask.noReceiveTask(session.GetUserId(), comm.TASK_WEEKLY); ok {
|
||||
reddot[comm.Reddot2] = ok
|
||||
break
|
||||
}
|
||||
tf, _ := this.modelTask.noReceiveTask(session.GetUserId(), comm.TASK_WEEKLY)
|
||||
reddot[comm.Reddot2] = tf
|
||||
|
||||
case comm.Reddot4:
|
||||
if ok, _ := this.modelTask.noReceiveTask(session.GetUserId(), comm.TASK_ACHIEVE); ok {
|
||||
reddot[comm.Reddot4] = ok
|
||||
break
|
||||
}
|
||||
tf, _ := this.modelTask.noReceiveTask(session.GetUserId(), comm.TASK_ACHIEVE)
|
||||
reddot[comm.Reddot4] = tf
|
||||
case comm.Reddot27:
|
||||
if ok,_:= this.modelTaskActive.noReceiveTaskActive(session.GetUserId(), comm.TASK_DAILY);ok{
|
||||
reddot[comm.Reddot27] = ok
|
||||
}
|
||||
tf, _ := this.modelTaskActive.noReceiveTaskActive(session.GetUserId(), comm.TASK_DAILY)
|
||||
reddot[comm.Reddot27] = tf
|
||||
case comm.Reddot28:
|
||||
if ok,_:= this.modelTaskActive.noReceiveTaskActive(session.GetUserId(), comm.TASK_WEEKLY);ok{
|
||||
reddot[comm.Reddot28] = ok
|
||||
}
|
||||
tf, _ := this.modelTaskActive.noReceiveTaskActive(session.GetUserId(), comm.TASK_WEEKLY)
|
||||
reddot[comm.Reddot28] = tf
|
||||
}
|
||||
}
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user