-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathalertDialog.go
57 lines (53 loc) · 1.54 KB
/
alertDialog.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package faithdroid
type FAlertDialog struct {
FBaseView
}
func AlertDialog(a IActivity) *FAlertDialog {
v := &FAlertDialog{}
v.VID = NewToken()
v.ClassName = "AlertDialog"
v.UI = a.GetMyActivity().UI
GlobalVars.UIs[v.UI].NewView(v.ClassName, v.VID)
GlobalVars.ViewMap[v.VID] = v
return v
}
func (v *FAlertDialog) Title(s string) *FAlertDialog {
GlobalVars.UIs[v.UI].ViewSetAttr(v.VID, "Title", s)
return v
}
func (v *FAlertDialog) Append(iv IView) *FAlertDialog {
GlobalVars.UIs[v.UI].ViewSetAttr(v.VID, "View", iv.GetViewId())
return v
}
func (v *FAlertDialog) PositiveButton(text string, onClick func(*FAlertDialog)) *FAlertDialog {
fnId := NewToken()
fn:=func(string) string {
onClick(v)
return ""
}
GlobalVars.EventHandlersMapLock.Lock()
GlobalVars.EventHandlersMap[fnId] = fn
GlobalVars.EventHandlersMapLock.Unlock()
GlobalVars.UIs[v.UI].ViewSetAttr(v.VID, "PositiveButton", JsonArray([]string{text, fnId}))
return v
}
func (v *FAlertDialog) NegativeButton(text string, onClick func(*FAlertDialog)) *FAlertDialog {
fnId := NewToken()
fn:=func(string) string {
onClick(v)
return ""
}
GlobalVars.EventHandlersMapLock.Lock()
GlobalVars.EventHandlersMap[fnId] = fn
GlobalVars.EventHandlersMapLock.Unlock()
GlobalVars.UIs[v.UI].ViewSetAttr(v.VID, "NegativeButton", JsonArray([]string{text, fnId}))
return v
}
func (v *FAlertDialog) Show() *FAlertDialog {
GlobalVars.UIs[v.UI].ViewSetAttr(v.VID, "Show", "")
return v
}
func (v *FAlertDialog) Dismiss() *FAlertDialog {
GlobalVars.UIs[v.UI].ViewSetAttr(v.VID, "Dismiss", "")
return v
}