Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Commit db3a3e5

Browse files
committed
🎉 First commit
0 parents  commit db3a3e5

6 files changed

Lines changed: 6697 additions & 0 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
.cache/
3+
parcel/
4+
dist/

license.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Copyright (c) Marc Espín Sanz
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "So ftware"), to deal
5+
in the Software without restriction, including without limit ation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense , and/or sell
7+
copies of the Software, and to permit persons to whom the So ftware is
8+
furnished to do so, subject to the following conditions:
9+
The above copyright notice and this permission notice shall be included in all
10+
copies or substantial portions of the Software.
11+
12+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KI ND, EXPRESS OR
13+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18+
SOFTWARE.

main.js

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
import Flutter from 'flutter-node'
2+
3+
function entry({
4+
StatusBarItem,
5+
ContextMenu,
6+
RunningConfig
7+
}){
8+
let _devices = [
9+
{
10+
name:'No devices found.'
11+
}
12+
]
13+
let _app;
14+
const button = new StatusBarItem({
15+
label:'Detecting devices',
16+
action:(e)=>{
17+
new ContextMenu({
18+
list:[
19+
...
20+
_devices.map(function(dev){
21+
return {
22+
label:dev.name,
23+
action:()=>{
24+
}
25+
}
26+
}),
27+
{},
28+
{
29+
label:'Run',
30+
action(e){
31+
new ContextMenu({
32+
list:[
33+
...
34+
RunningConfig.data.workspaceConfig.folders.map(function(folder){
35+
return {
36+
label:folder.path,
37+
action:()=>{
38+
_app = new Flutter.app({
39+
path:RunningConfig.data.workspaceConfig.folders[0].path.replace(/\\/g,'\\\\'),
40+
deviceId:_devices[0].id
41+
})
42+
_app.run({
43+
onData:function(data){
44+
console.log(data)
45+
},
46+
onExit:function(data){
47+
console.log(data)
48+
},
49+
onClose:function(data){
50+
console.log(data)
51+
}
52+
})
53+
RunningConfig.on('tabSaved',function({
54+
parentFolder
55+
}){
56+
if(parentFolder == folder.path){ //Check if the modified tab is from the flutter app
57+
_app.reload()
58+
}
59+
})
60+
}
61+
}
62+
})
63+
],
64+
x:e.pageX,
65+
y:e.pageY,
66+
parent:e.target
67+
})
68+
}
69+
},
70+
{
71+
label:'Hot reload',
72+
action(){
73+
_app.reload()
74+
}
75+
}
76+
],
77+
x:e.pageX,
78+
y:e.pageY,
79+
parent:e.target
80+
})
81+
}
82+
})
83+
Flutter.isInstalled().then(res=>{
84+
if( !res ){
85+
button.setLabel('Flutter is not installed')
86+
}
87+
})
88+
Flutter.getDevices().then(function(res){
89+
if(res.devices.length == 0){
90+
button.setLabel('No devices found')
91+
}else{
92+
button.setLabel(res.devices[0].name)
93+
_devices = res.devices
94+
}
95+
})
96+
97+
}
98+
99+
module.exports = {
100+
entry
101+
}

0 commit comments

Comments
 (0)