@@ -15,10 +15,14 @@ import 'package:corecoder_develop/util/modules_manager.dart'
1515 show Module, ModulesManager, Template;
1616import 'package:font_awesome_flutter/font_awesome_flutter.dart' ;
1717
18+ /// Updates the file last modified
19+ void touchFile (File file, CCSolution solution) {
20+ var newTime = DateTime .now ();
21+ solution.dateModified = newTime;
22+ file.setLastModifiedSync (newTime);
23+ }
1824void loadSolution (
1925 CCSolution solution, BuildContext context, ModulesManager modulesManager) {
20- /// Load the project
21- // var template = modulesManager.getTemplateByIdentifier(solution.identifier);
2226 Navigator .pushNamed (context, EditorPage .routeName, arguments: solution);
2327}
2428
@@ -59,6 +63,7 @@ class _HomePageState extends State<HomePage> {
5963 final Future <SharedPreferences > _pref = SharedPreferences .getInstance ();
6064 var projectsWidgets = < Widget > [];
6165
66+
6267 void showSettings () {
6368 Navigator .pushNamed (context, SettingsPage .routeName);
6469 }
@@ -226,6 +231,7 @@ class _HomePageState extends State<HomePage> {
226231 void initState () {
227232 super .initState ();
228233 loadPrefs ();
234+ refreshRecentProjects ();
229235 }
230236
231237 @override
@@ -248,15 +254,21 @@ class _HomePageState extends State<HomePage> {
248254 }
249255 }
250256
257+
251258 void refreshRecentProjects () {
252259 setState (() {
253260 projectsWidgets.clear ();
261+ rpm.projects.sort ((CCSolution a,CCSolution b){
262+ return b.dateModified.compareTo (a.dateModified);
263+ });
254264 for (CCSolution p in rpm.projects) {
255265 if (p.name == "" )
256266 continue ; // TODO: add better way to check if project is corrupt
257267 debugPrint (p.name);
258268 projectsWidgets.add (ListTile (
259269 onTap: () {
270+ touchFile (File (p.slnPath),p);
271+ refreshRecentProjects ();
260272 loadSolution (p, context, mm);
261273 },
262274 leading: p.image != null
@@ -295,6 +307,11 @@ class _HomePageState extends State<HomePage> {
295307 ),
296308 ),
297309 const Spacer (flex: 1 ),
310+ TextButton (
311+ onPressed: () {refreshRecentProjects ();},
312+ child: const Text ("Refresh" ),
313+ style: ElevatedButton .styleFrom (primary: Colors .black12),
314+ ),
298315 TextButton (
299316 onPressed: () {},
300317 child: const Text ("Add" ),
0 commit comments