-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
134 lines (128 loc) · 3.12 KB
/
main.js
File metadata and controls
134 lines (128 loc) · 3.12 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
const flutter_dm = new dropMenu({
id:"flutter_dm"
});
const flutter_plugin = new Plugin({
name:'Flutter'
})
let selected_device = [null,null];
flutter_plugin.createData({
device:selected_device
})
flutter_plugin.getData(function(data){
selected_device = data.device;
flutter_dm.setList({
"button": "Flutter",
"list":{
"Run":{
click:function(){
const Flutter = require("flutter-node")
const { exec } = require('child_process');
let _times = 0;
exec(`flutter`,(err)=>{
if(err){
new Notification({
title:'Flutter',
content:'Flutter is not installed',
buttons:{
"Install":{
click:function(){
shell.openExternal("https://flutter.dev/docs/get-started/install")
}
}
}
})
return;
}
})
if(selected_device == [null,null]){
new Notification({
title:'Flutter',
content:'Select a device before running the app.'
})
return;
}
if(graviton.getCurrentDirectory() == null){
new Notification({
title:'Flutter',
content:"Open your app's folder before running the app"
})
return;
}
Flutter.run({
path:graviton.getCurrentDirectory(),
id:selected_device[1]
},function(output,err){
_times++;
if(err){
new Notification({
title:'Flutter',
content:'An error was detected.'
})
return;
}
if(_times == 0){
new Notification({
title:'Flutter',
content:'Running...'
})
}
console.log(output)
})
}
},
"Select device":{
click:function(){
const Flutter = require("flutter-node")
const devices_window = new Dialog({
id:'devices_window',
title:'Devices',
content:`<div id=devices_list>
</div>`,
buttons:{
Close:{
click:{}
}
}
})
Flutter.getDevices(function(list,err){
if(err){
document.getElementById("devices_list").innerHTML = "No devices has been found."
return;
}
list.forEach((dev)=>{
const device_div = document.createElement("div");
if(selected_device[0] == dev[0]) device_div.style = "background:var(--accentColor); color:var(--black-white);";
device_div.classList = "section-2";
device_div.innerText = dev[0];
device_div.onclick = function(){
const childrens = device_div.parentElement.children;
for(let i = 0;i<childrens.length;i++){
childrens[i].style = "";
}
device_div.style = "background:var(--accentColor); color:var(--black-white);";
selected_device = dev;
flutter_plugin.saveData({
device:dev
})
}
document.getElementById("devices_list").appendChild(device_div)
})
})
}
},
"Information":{
click:function(){
new Dialog({
title:'About Flutter plugin',
content:"This plugin is not made by the team of Flutter, it's made by the creator of Graviton.",
buttons:{
Close:{
click:{}
}
}
})
}
}
}
})
})