Skip to content

Commit c97257f

Browse files
committed
Refactor: Project list is now a widget
1 parent af6d5a4 commit c97257f

File tree

2 files changed

+57
-59
lines changed

2 files changed

+57
-59
lines changed

lib/screens/homepage/homepage.dart

Lines changed: 15 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import '../../util/cc_project_structure.dart';
1717
import 'package:corecoder_develop/util/modules_manager.dart'
1818
show Module, ModulesManager, Template;
1919

20+
import 'homepage_projectlist.dart';
21+
2022
/// Updates the file last modified
2123
void touchFile(File file, CCSolution solution) {
2224
var newTime = DateTime.now();
@@ -469,6 +471,9 @@ class _HomePageState extends State<HomePage> {
469471
});
470472
}
471473

474+
//TODO: Implement add project
475+
void onAddProject() {}
476+
472477
@override
473478
Widget build(BuildContext context) {
474479
final query = MediaQuery.of(context);
@@ -495,36 +500,11 @@ class _HomePageState extends State<HomePage> {
495500
icon: const Icon(Icons.settings),
496501
title: const Text("Settings")),
497502
], content: <Widget>[
498-
Padding(
499-
padding: const EdgeInsets.all(16.0),
500-
child: Column(
501-
crossAxisAlignment: CrossAxisAlignment.stretch,
502-
children: [
503-
Row(children: [
504-
const Text(
505-
"Recent Projects",
506-
style: TextStyle(
507-
fontWeight: FontWeight.bold,
508-
fontSize: 24.0,
509-
),
510-
),
511-
const Spacer(flex: 1),
512-
OutlinedButton(
513-
onPressed: () {
514-
refreshRecentProjects();
515-
},
516-
child: const Text("Refresh"),
517-
),
518-
const SizedBox(width: 4,),
519-
OutlinedButton(
520-
onPressed: () {},
521-
child: const Text("Open"),
522-
),
523-
]),
524-
Column(
525-
children: projectsWidgetList,
526-
)
527-
])),
503+
ProjectList(
504+
onAddProject: onAddProject,
505+
onRefresh: refreshRecentProjects,
506+
children: projectsWidgetList,
507+
),
528508
const PluginsBrowser(),
529509
SettingsPage(mm),
530510
])
@@ -533,35 +513,11 @@ class _HomePageState extends State<HomePage> {
533513
/// ==================
534514
/// The android layout
535515
/// ==================
536-
Padding(
537-
padding: const EdgeInsets.all(16.0),
538-
child: Column(
539-
crossAxisAlignment: CrossAxisAlignment.stretch,
540-
children: [
541-
Row(children: [
542-
const Text(
543-
"Recent Projects",
544-
style: TextStyle(
545-
fontWeight: FontWeight.bold,
546-
fontSize: 24.0,
547-
),
548-
),
549-
const Spacer(flex: 1),
550-
OutlinedButton(
551-
onPressed: () {
552-
refreshRecentProjects();
553-
},
554-
child: const Text("Refresh"),
555-
),
556-
OutlinedButton(
557-
onPressed: () {},
558-
child: const Text("Add"),
559-
),
560-
]),
561-
Column(
562-
children: projectsWidgetList,
563-
)
564-
])),
516+
ProjectList(
517+
onAddProject: onAddProject,
518+
onRefresh: refreshRecentProjects,
519+
children: projectsWidgetList,
520+
),
565521
));
566522
return Scaffold(
567523
appBar: CoreCoderApp.isLandscape(context)
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import 'package:flutter/material.dart';
2+
3+
class ProjectList extends StatelessWidget{
4+
final Function onRefresh;
5+
final Function onAddProject;
6+
final List<Widget> children;
7+
const ProjectList({Key? key,required this.onRefresh, required this.onAddProject, required this.children}) : super(key: key);
8+
@override
9+
Widget build(BuildContext context) {
10+
return Padding(
11+
padding: const EdgeInsets.all(16.0),
12+
child: Column(
13+
crossAxisAlignment: CrossAxisAlignment.stretch,
14+
children: [
15+
Row(children: [
16+
const Text(
17+
"Recent Projects",
18+
style: TextStyle(
19+
fontWeight: FontWeight.bold,
20+
fontSize: 24.0,
21+
),
22+
),
23+
const Spacer(flex: 1),
24+
OutlinedButton(
25+
onPressed: () {
26+
onRefresh();
27+
},
28+
child: const Text("Refresh"),
29+
),
30+
const SizedBox(width: 4,),
31+
OutlinedButton(
32+
onPressed: () {},
33+
child: const Text("Open"),
34+
),
35+
]),
36+
Column(
37+
children: children,
38+
)
39+
]));
40+
}
41+
42+
}

0 commit comments

Comments
 (0)