-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin.go
More file actions
74 lines (55 loc) · 2.5 KB
/
plugin.go
File metadata and controls
74 lines (55 loc) · 2.5 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package title_bar
import (
flutter "github.com/go-flutter-desktop/go-flutter"
"github.com/go-flutter-desktop/go-flutter/plugin"
)
// TitleBarPlugin handles method calls to
// the plugins.flutter.io/titlebar channel.
type TitleBarPlugin struct{}
const channelName = "plugins.flutter.io/titlebar"
var _ flutter.Plugin = &TitleBarPlugin{} // compile-time type check
// Color struct
type color struct {
alpha int32
red int32
green int32
blue int32
}
// InitPlugin initializes the title bar plugin.
func (p *TitleBarPlugin) InitPlugin(messenger plugin.BinaryMessenger) error {
channel := plugin.NewMethodChannel(messenger, channelName, plugin.StandardMethodCodec{})
channel.HandleFunc("gettitlebarcolor", p.handleGetTitleBarColor)
channel.HandleFunc("settitlebarcolor", p.handleSetTitleBarColor)
channel.HandleFunc("gettitlebartransparency", p.handleGetTitleBarTransparency)
channel.HandleFunc("settitlebartransparency", p.handleSetTitleBarTransparency)
channel.HandleFunc("settitlebarwidget", p.handleSetTitleBarWidget)
setTitleBarTransparency(true)
return nil
}
func (p *TitleBarPlugin) handleGetTitleBarColor(arguments interface{}) (reply interface{}, err error) {
return getTitleBarColor(), nil
}
func (p *TitleBarPlugin) handleSetTitleBarColor(arguments interface{}) (reply interface{}, err error) {
red := arguments.(map[interface{}]interface{})["red"].(int32)
green := arguments.(map[interface{}]interface{})["green"].(int32)
blue := arguments.(map[interface{}]interface{})["blue"].(int32)
alpha := arguments.(map[interface{}]interface{})["alpha"].(int32)
setTitleBarColor(color{red: int32(red), green: int32(green), blue: (blue), alpha: (alpha)})
return nil, nil
}
func (p *TitleBarPlugin) handleGetTitleBarTransparency(arguments interface{}) (reply interface{}, err error) {
return getTitleBarTransparency(), nil
}
func (p *TitleBarPlugin) handleSetTitleBarTransparency(arguments interface{}) (reply interface{}, err error) {
transparency := arguments.(map[interface{}]interface{})["transparency"].(bool)
setTitleBarTransparency(transparency)
return nil, nil
}
func (p *TitleBarPlugin) handleSetTitleBarWidget(arguments interface{}) (reply interface{}, err error) {
hide := arguments.(map[interface{}]interface{})["hide"].(bool)
close := arguments.(map[interface{}]interface{})["close"].(bool)
minimize := arguments.(map[interface{}]interface{})["minimize"].(bool)
resize := arguments.(map[interface{}]interface{})["resize"].(bool)
setTitleBarWidget(hide, close, minimize, resize)
return nil, nil
}