Skip to content

Commit 0da27c7

Browse files
committed
Plugins templates implementation done
1 parent 990916d commit 0da27c7

File tree

7 files changed

+233
-170
lines changed

7 files changed

+233
-170
lines changed

.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_ios","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_ios-2.0.7\\\\","dependencies":[]},{"name":"permission_handler","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-8.3.0\\\\","dependencies":[]},{"name":"shared_preferences_ios","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_ios-2.0.8\\\\","dependencies":[]},{"name":"url_launcher","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-6.0.15\\\\","dependencies":[]}],"android":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_android","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_android-2.0.9\\\\","dependencies":[]},{"name":"permission_handler","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-8.3.0\\\\","dependencies":[]},{"name":"shared_preferences_android","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_android-2.0.9\\\\","dependencies":[]},{"name":"url_launcher","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-6.0.15\\\\","dependencies":[]}],"macos":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_macos","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.3\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-2.0.2\\\\","dependencies":[]},{"name":"url_launcher_macos","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_macos-2.0.2\\\\","dependencies":[]}],"linux":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_linux","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.1.2\\\\","dependencies":[]},{"name":"shared_preferences_linux","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_linux-2.0.3\\\\","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_linux-2.0.2\\\\","dependencies":[]}],"windows":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_windows","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.4\\\\","dependencies":[]},{"name":"shared_preferences_windows","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_windows-2.0.3\\\\","dependencies":["path_provider_windows"]},{"name":"url_launcher_windows","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_windows-2.0.2\\\\","dependencies":[]}],"web":[{"name":"shared_preferences_web","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-2.0.2\\\\","dependencies":[]},{"name":"url_launcher_web","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_web-2.0.4\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_jscore","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_ios","shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_ios","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-12-13 12:12:32.625939","version":"2.5.3"}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_ios","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_ios-2.0.7\\\\","dependencies":[]},{"name":"permission_handler","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-8.3.0\\\\","dependencies":[]},{"name":"shared_preferences_ios","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_ios-2.0.8\\\\","dependencies":[]},{"name":"url_launcher","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-6.0.15\\\\","dependencies":[]}],"android":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_android","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_android-2.0.9\\\\","dependencies":[]},{"name":"permission_handler","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\permission_handler-8.3.0\\\\","dependencies":[]},{"name":"shared_preferences_android","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_android-2.0.9\\\\","dependencies":[]},{"name":"url_launcher","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher-6.0.15\\\\","dependencies":[]}],"macos":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_macos","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_macos-2.0.3\\\\","dependencies":[]},{"name":"shared_preferences_macos","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_macos-2.0.2\\\\","dependencies":[]},{"name":"url_launcher_macos","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_macos-2.0.2\\\\","dependencies":[]}],"linux":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_linux","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_linux-2.1.2\\\\","dependencies":[]},{"name":"shared_preferences_linux","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_linux-2.0.3\\\\","dependencies":["path_provider_linux"]},{"name":"url_launcher_linux","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_linux-2.0.2\\\\","dependencies":[]}],"windows":[{"name":"flutter_jscore","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\flutter_jscore-1.0.0\\\\","dependencies":[]},{"name":"path_provider_windows","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\path_provider_windows-2.0.4\\\\","dependencies":[]},{"name":"shared_preferences_windows","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_windows-2.0.3\\\\","dependencies":["path_provider_windows"]},{"name":"url_launcher_windows","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_windows-2.0.2\\\\","dependencies":[]}],"web":[{"name":"shared_preferences_web","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\shared_preferences_web-2.0.2\\\\","dependencies":[]},{"name":"url_launcher_web","path":"D:\\\\Programming\\\\Flutter\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\url_launcher_web-2.0.4\\\\","dependencies":[]}]},"dependencyGraph":[{"name":"flutter_jscore","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_ios","path_provider_linux","path_provider_macos","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_ios","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_android","shared_preferences_ios","shared_preferences_linux","shared_preferences_macos","shared_preferences_web","shared_preferences_windows"]},{"name":"shared_preferences_android","dependencies":[]},{"name":"shared_preferences_ios","dependencies":[]},{"name":"shared_preferences_linux","dependencies":["path_provider_linux"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"shared_preferences_windows","dependencies":["path_provider_windows"]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-12-14 10:16:06.527916","version":"2.5.3"}

lib/homepage.dart

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@ void touchFile(File file, CCSolution solution) {
2424
file.setLastModifiedSync(newTime);
2525
}
2626

27-
void loadSolution(
28-
CCSolution solution, BuildContext context, ModulesManager modulesManager) {
27+
void loadSolution(CCSolution solution, BuildContext context) {
2928
Navigator.pushNamed(context, EditorPage.routeName, arguments: solution);
3029
}
3130

3231
class RecentProjectsManager {
32+
static RecentProjectsManager? _instance;
33+
34+
static RecentProjectsManager get instance {
35+
_instance ??= RecentProjectsManager();
36+
return _instance!;
37+
}
38+
3339
List<CCSolution> projects = List.empty(growable: true);
3440

3541
/// Commit the recent projects to the pref
@@ -43,6 +49,10 @@ class RecentProjectsManager {
4349
});
4450
}
4551

52+
static void staticCommit(){
53+
instance.commit(SharedPreferences.getInstance());
54+
}
55+
4656
/// Add a solution file to the list
4757
Future<CCSolution?> addSolution(String slnPath) async {
4858
// Prevent project with same solution to be loaded
@@ -70,8 +80,7 @@ class HomePage extends StatefulWidget {
7080
}
7181

7282
class _HomePageState extends State<HomePage> {
73-
ModulesManager mm = ModulesManager();
74-
RecentProjectsManager rpm = RecentProjectsManager();
83+
late ModulesManager mm;
7584
final Future<SharedPreferences> _pref = SharedPreferences.getInstance();
7685
var projectsWidgets = <Widget>[];
7786

@@ -151,15 +160,16 @@ class _HomePageState extends State<HomePage> {
151160
/// Go Ahead and create project asynchronously
152161
var slnPath = await t.onCreated(
153162
values); //TODO: This is prone to error (not checking if the file existed first)
154-
if(slnPath == null) return;
163+
if (slnPath == null) return;
164+
155165
/// Add it to recent projects
156166
CCSolution? project =
157-
await rpm.addSolution(slnPath);
167+
await RecentProjectsManager.instance.addSolution(slnPath);
158168
if (project != null) {
159-
await rpm.commit(_pref);
169+
await RecentProjectsManager.instance.commit(_pref);
160170
Navigator.pop(context, 3);
161171
refreshRecentProjects();
162-
loadSolution(project, context, mm);
172+
loadSolution(project, context);
163173
}
164174
},
165175
)
@@ -204,9 +214,9 @@ class _HomePageState extends State<HomePage> {
204214
debugPrint("LOADING PREFS");
205215
var pref = await _pref;
206216
// Read recent projects list
207-
rpm.clear();
217+
RecentProjectsManager.instance.clear();
208218
for (var sln in pref.getStringList("recentProjectsSln") ?? []) {
209-
await rpm.addSolution(sln);
219+
await RecentProjectsManager.instance.addSolution(sln);
210220
//debugPrint(sln);
211221
}
212222
debugPrint("DONE");
@@ -216,8 +226,8 @@ class _HomePageState extends State<HomePage> {
216226
@override
217227
void initState() {
218228
super.initState();
229+
mm = ModulesManager(context);
219230
refreshRecentProjects();
220-
221231
}
222232

223233
@override
@@ -268,10 +278,10 @@ class _HomePageState extends State<HomePage> {
268278
await loadPrefs();
269279
setState(() {
270280
projectsWidgets.clear();
271-
rpm.projects.sort((CCSolution a, CCSolution b) {
281+
RecentProjectsManager.instance.projects.sort((CCSolution a, CCSolution b) {
272282
return b.dateModified.compareTo(a.dateModified);
273283
});
274-
for (CCSolution p in rpm.projects) {
284+
for (CCSolution p in RecentProjectsManager.instance.projects) {
275285
if (p.name == "") {
276286
continue;
277287
} // TODO: add better way to check if project is corrupt
@@ -281,12 +291,13 @@ class _HomePageState extends State<HomePage> {
281291
onTap: () {
282292
touchFile(File(p.slnPath), p);
283293
refreshRecentProjects();
284-
loadSolution(p, context, mm);
294+
loadSolution(p, context);
285295
},
286-
leading: p.image ?? const Icon(
287-
Icons.insert_drive_file,
288-
size: 48,
289-
),
296+
leading: p.image ??
297+
const Icon(
298+
Icons.insert_drive_file,
299+
size: 48,
300+
),
290301
title: Text(p.name),
291302
subtitle: Text(
292303
p.desc + " Last Modified: " + p.dateModified.toString()),

0 commit comments

Comments
 (0)