@@ -26,6 +26,9 @@ void touchFile(File file, CCSolution solution) {
26
26
27
27
void loadSolution (CCSolution solution, BuildContext context) {
28
28
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));
29
32
}
30
33
31
34
enum HistoryItemType { solution, singleFile }
@@ -382,6 +385,25 @@ class _HomePageState extends State<HomePage> {
382
385
mm.onFinishedLoading = () {
383
386
refreshRecentProjects ();
384
387
};
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
+ });
385
407
}
386
408
387
409
@override
@@ -510,35 +532,35 @@ class _HomePageState extends State<HomePage> {
510
532
/// ==================
511
533
/// The android layout
512
534
/// ==================
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
+ ])),
542
564
));
543
565
return Scaffold (
544
566
appBar: CoreCoderApp .isLandscape (context)
0 commit comments