@@ -23,6 +23,7 @@ class PluginsItem {
23
23
String name, author, repo, version, iconUrl, desc, identifier;
24
24
bool isInstalled = false ;
25
25
bool isProcessing = false ;
26
+ String processingMessage = "" ;
26
27
27
28
String get folderName {
28
29
return identifier + "@" + version;
@@ -34,6 +35,7 @@ class PluginsItem {
34
35
35
36
class PluginsBrowserState extends State <PluginsBrowser > {
36
37
List <PluginsItem > items = [];
38
+
37
39
JsonDecoder decoder = const JsonDecoder ();
38
40
GitHub github = GitHub (); // Create an anonymous github client
39
41
bool _isLoadingVisible = false ;
@@ -71,15 +73,28 @@ class PluginsBrowserState extends State<PluginsBrowser> {
71
73
if (! await PluginsManager .checkPluginsExist (
72
74
item.identifier, item.version)) {
73
75
try {
76
+ setState (() {
77
+ item.processingMessage = "Fetching data" ;
78
+ });
74
79
Repository repo = await github.repositories.getRepository (
75
80
RepositorySlug .full (
76
81
item.repo.replaceAll ("https://github.com/" , "" )));
82
+
83
+ setState (() {
84
+ item.processingMessage = "Processing releases" ;
85
+ });
77
86
List <Release > releases =
78
87
await github.repositories.listReleases (repo.slug ()).toList ();
79
88
80
89
if (repo.hasDownloads) {
90
+ setState (() {
91
+ item.processingMessage = "Getting latest update" ;
92
+ });
81
93
var r = releases.first;
82
94
if (r.zipballUrl != null ) {
95
+ setState (() {
96
+ item.processingMessage = "Downloading data" ;
97
+ });
83
98
var bytes = (await http.get (Uri .parse (r.zipballUrl! ))).bodyBytes;
84
99
var path = await PluginsManager .pluginsPath +
85
100
item.folderName +
@@ -89,6 +104,9 @@ class PluginsBrowserState extends State<PluginsBrowser> {
89
104
// Create the folder if not exists
90
105
await Directory (path).create (recursive: true );
91
106
107
+ setState (() {
108
+ item.processingMessage = "Extracting data" ;
109
+ });
92
110
// Extract the contents of the Zip archive to disk.
93
111
for (final file in archive) {
94
112
final filename = (file.name.split ("/" )..removeAt (0 )).join ("/" );
@@ -117,24 +135,29 @@ class PluginsBrowserState extends State<PluginsBrowser> {
117
135
}
118
136
} else {
119
137
debugPrint ("[PluginsManager] The plugins is already installed" );
120
- item.isInstalled = true ;
138
+ setState (() {
139
+ item.isInstalled = true ;
140
+ });
121
141
return false ;
122
142
}
123
- /* Do Something with repo */
124
- if (item.isInstalled) return false ;
125
143
126
144
setState (() {
127
145
item.isProcessing = false ;
128
146
});
147
+
148
+ /* Do Something with repo */
149
+ if (item.isInstalled) {
150
+ return false ;
151
+ }
152
+
129
153
return true ;
130
154
}
131
155
132
156
void reloadPlugins ({String query = "" }) async {
133
157
items.clear ();
134
158
_isLoadingVisible = true ;
135
159
Response resp = await http.get (Uri .parse (
136
- "https://github.com/CoreCoder-Devs/corecoder_plugins/main/plugins.json" )
137
- );
160
+ "https://github.com/CoreCoder-Devs/corecoder_plugins/main/plugins.json" ));
138
161
_isLoadingVisible = false ;
139
162
if (resp.statusCode == 200 ) {
140
163
// OK
@@ -175,9 +198,7 @@ class PluginsBrowserState extends State<PluginsBrowser> {
175
198
),
176
199
body: Column (children: [
177
200
Visibility (
178
- visible: _isLoadingVisible,
179
- child: const Text ('Loading...' )
180
- ),
201
+ visible: _isLoadingVisible, child: const Text ('Loading...' )),
181
202
Column (
182
203
children: List .generate (items.length, (index) {
183
204
var item = items[index];
@@ -186,9 +207,14 @@ class PluginsBrowserState extends State<PluginsBrowser> {
186
207
leading: Image .network (item.iconUrl),
187
208
subtitle: Text (item.desc),
188
209
trailing: (item.isProcessing)
189
- ? const CircularProgressIndicator (
190
- value: null ,
191
- )
210
+ ? Container (
211
+ constraints: BoxConstraints (maxWidth: 256 ),
212
+ child: Row (children: [
213
+ Text (item.processingMessage),
214
+ const CircularProgressIndicator (
215
+ value: null ,
216
+ ),
217
+ ]))
192
218
: (item.isInstalled)
193
219
? ElevatedButton (
194
220
onPressed: () {
0 commit comments