@@ -26,6 +26,9 @@ void touchFile(File file, CCSolution solution) {
2626
2727void loadSolution (CCSolution solution, BuildContext context) {
2828 Navigator .pushNamed (context, EditorPage .routeName, arguments: solution);
29+ // Save the last solution opened to preferences
30+ SharedPreferences .getInstance ()
31+ .then ((value) => value.setString ("lastOpenedPath" , solution.slnPath));
2932}
3033
3134enum HistoryItemType { solution, singleFile }
@@ -382,6 +385,25 @@ class _HomePageState extends State<HomePage> {
382385 mm.onFinishedLoading = () {
383386 refreshRecentProjects ();
384387 };
388+
389+ /// Check the last opened projects
390+ SharedPreferences .getInstance ().then ((inst) async {
391+ var isAutoOpen = inst.getBool ("openLastProjectOnStartup" );
392+ if (isAutoOpen != null && isAutoOpen) {
393+ var val = inst.getString ("lastOpenedPath" );
394+ debugPrint ("Loading last opened $val " );
395+ if (val != null ) {
396+ if (val.endsWith (".ccsln.json" )) {
397+ var sln = await CCSolution .loadFromFile (val);
398+ if (sln != null ) {
399+ loadSolution (sln, context);
400+ }
401+ } else {
402+ //TODO: handle loading single file
403+ }
404+ }
405+ }
406+ });
385407 }
386408
387409 @override
@@ -510,35 +532,35 @@ class _HomePageState extends State<HomePage> {
510532 /// ==================
511533 /// The android layout
512534 /// ==================
513- Padding (
514- padding: const EdgeInsets .all (16.0 ),
515- child: Column (
516- crossAxisAlignment: CrossAxisAlignment .stretch,
517- children: [
518- Row (children: [
519- const Text (
520- "Recent Projects" ,
521- style: TextStyle (
522- fontWeight: FontWeight .bold,
523- fontSize: 24.0 ,
524- ),
525- ),
526- const Spacer (flex: 1 ),
527- OutlinedButton (
528- onPressed: () {
529- refreshRecentProjects ();
530- },
531- child: const Text ("Refresh" ),
532- ),
533- OutlinedButton (
534- onPressed: () {},
535- child: const Text ("Add" ),
536- ),
537- ]),
538- Column (
539- children: projectsWidgetList,
540- )
541- ])),
535+ Padding (
536+ padding: const EdgeInsets .all (16.0 ),
537+ child: Column (
538+ crossAxisAlignment: CrossAxisAlignment .stretch,
539+ children: [
540+ Row (children: [
541+ const Text (
542+ "Recent Projects" ,
543+ style: TextStyle (
544+ fontWeight: FontWeight .bold,
545+ fontSize: 24.0 ,
546+ ),
547+ ),
548+ const Spacer (flex: 1 ),
549+ OutlinedButton (
550+ onPressed: () {
551+ refreshRecentProjects ();
552+ },
553+ child: const Text ("Refresh" ),
554+ ),
555+ OutlinedButton (
556+ onPressed: () {},
557+ child: const Text ("Add" ),
558+ ),
559+ ]),
560+ Column (
561+ children: projectsWidgetList,
562+ )
563+ ])),
542564 ));
543565 return Scaffold (
544566 appBar: CoreCoderApp .isLandscape (context)
0 commit comments