Skip to content

Commit cae52aa

Browse files
committed
2 parents dae56d2 + 7f0ca9c commit cae52aa

File tree

7 files changed

+204
-154
lines changed

7 files changed

+204
-154
lines changed

lib/screens/homepage/homepage.dart

Lines changed: 99 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:corecoder_develop/screens/settings/plugins_browser.dart';
44
import 'package:corecoder_develop/screens/settings/settings.dart';
55
import 'package:corecoder_develop/util/cc_project_structure.dart';
66
import 'package:corecoder_develop/util/desktop_tabbar.dart';
7+
import 'package:corecoder_develop/util/theme_manager.dart';
78
import 'package:flutter/material.dart';
89

910
import '../editor/editor.dart';
@@ -138,10 +139,15 @@ class _HomePageState extends State<HomePage> {
138139
Icons.insert_drive_file,
139140
size: 48,
140141
),
141-
title: Text(p.name),
142+
title: Text(
143+
p.name,
144+
style: const TextStyle(
145+
fontWeight: FontWeight.bold
146+
),
147+
),
142148
subtitle: Text(
143149
(p.type == HistoryItemType.solution ? p.solution!.desc : "") +
144-
" Last Modified: " +
150+
"Last Modified: " +
145151
p.dateModified.toString()),
146152
trailing: PopupMenuButton<String>(
147153
onSelected: (String result) {
@@ -271,105 +277,107 @@ class _HomePageState extends State<HomePage> {
271277
builder: (BuildContext context) {
272278
List<Widget> options = List.empty(growable: true);
273279
for (Module m in ModulesManager.modules) {
274-
options.add(Text(
275-
m.name,
276-
style: const TextStyle(fontSize: 21),
277-
));
280+
options.add(
281+
Padding(
282+
padding: const EdgeInsets.fromLTRB(5, 5, 5, 5),
283+
child: Text(m.name,
284+
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold))
285+
)
286+
);
278287
for (Template t in m.templates) {
279288
/// -------------------------------------------------
280289
/// Project Options
281290
/// -------------------------------------------------
282-
options.add(ListTile(
283-
leading: t.icon,
284-
trailing: Text(t.version),
285-
title: Text(t.title),
286-
subtitle: Text(t.desc),
287-
onTap: () async {
288-
/// The options changed later after the window closed
289-
Map<String, dynamic> values = {};
290-
await showDialog<int>(
291-
context: context,
292-
builder: (BuildContext context) {
293-
List<Widget> controls = List.empty(growable: true);
294-
295-
/// Add Options
296-
for (var argName in t.options.keys) {
297-
controls.add(Text(
298-
argName,
299-
textAlign: TextAlign.end,
300-
));
301-
if (t.options[argName] == "String") {
302-
controls.add(TextField(
303-
maxLines: 1,
304-
autofocus: true,
305-
onChanged: (change) {
306-
values[argName] = change;
307-
}));
308-
values[argName] = "";
309-
}
310-
}
311-
312-
/// Add Buttons
313-
var row = Row(
314-
children: [
315-
TextButton(
316-
child: const Text("Cancel"),
317-
onPressed: () {
318-
Navigator.pop(context, 1);
319-
},
320-
),
321-
TextButton(
322-
child: const Text("Create"),
323-
onPressed: () async {
324-
/// Go Ahead and create project asynchronously
325-
var slnPath = await t.onCreated(
326-
values); //TODO: This is prone to error (not checking if the file existed first)
327-
if (slnPath == null) return;
328-
329-
/// Add it to recent projects
330-
CCSolution? project =
331-
await RecentProjectsManager.instance
332-
.addSolution(slnPath);
333-
if (project != null) {
334-
await RecentProjectsManager.instance
335-
.commit(_pref);
336-
Navigator.pop(context, 3);
337-
refreshRecentProjects();
338-
loadSolution(project, context);
339-
}
340-
},
341-
)
342-
],
343-
);
344-
controls.add(row);
345-
// Return the dialog to be opened
346-
return SimpleDialog(
347-
title: Text('Create ${t.title}'),
348-
children: <Widget>[
349-
Padding(
350-
padding:
351-
const EdgeInsets.symmetric(horizontal: 8.0),
352-
child: Column(children: controls))
353-
],
354-
);
355-
},
356-
barrierDismissible: true);
357-
},
358-
));
291+
options.add(
292+
Card(
293+
child: ListTile(
294+
leading: t.icon,
295+
title: Text(t.title),
296+
subtitle: Text(t.desc),
297+
tileColor: ThemeManager.getThemeData().backgroundColor,
298+
onTap: () async {
299+
/// The options changed later after the window closed
300+
Map<String, dynamic> values = {};
301+
await showDialog<int>(
302+
context: context,
303+
builder: (BuildContext context) {
304+
List<Widget> controls = List.empty(growable: true);
305+
306+
/// Add Options
307+
for (var argName in t.options.keys) {
308+
controls.add(Text(
309+
argName,
310+
textAlign: TextAlign.end,
311+
));
312+
if (t.options[argName] == "String") {
313+
controls.add(TextField(
314+
maxLines: 1,
315+
autofocus: true,
316+
onChanged: (change) {
317+
values[argName] = change;
318+
}));
319+
values[argName] = "";
320+
}
321+
}
322+
323+
/// Add Buttons
324+
var row = Row(
325+
children: [
326+
TextButton(
327+
child: const Text("Cancel"),
328+
onPressed: () {
329+
Navigator.pop(context, 1);
330+
},
331+
),
332+
TextButton(
333+
child: const Text("Create"),
334+
onPressed: () async {
335+
/// Go Ahead and create project asynchronously
336+
var slnPath = await t.onCreated(
337+
values); //TODO: This is prone to error (not checking if the file existed first)
338+
if (slnPath == null) return;
339+
340+
/// Add it to recent projects
341+
CCSolution? project =
342+
await RecentProjectsManager.instance
343+
.addSolution(slnPath);
344+
if (project != null) {
345+
await RecentProjectsManager.instance
346+
.commit(_pref);
347+
Navigator.pop(context, 3);
348+
refreshRecentProjects();
349+
loadSolution(project, context);
350+
}
351+
},
352+
)
353+
],
354+
);
355+
controls.add(row);
356+
// Return the dialog to be opened
357+
return SimpleDialog(
358+
title: Text('Create ${t.title}'),
359+
children: <Widget>[
360+
Padding(
361+
padding:
362+
const EdgeInsets.symmetric(horizontal: 8.0),
363+
child: Column(children: controls))
364+
],
365+
);
366+
},
367+
barrierDismissible: true);
368+
},
369+
)
370+
)
371+
);
359372
}
360373
}
361374
return SimpleDialog(
362-
title: const Text('Create new project'),
375+
title: const Center(child:Text('Create new project')),
363376
children: options,
377+
contentPadding: const EdgeInsets.fromLTRB(5, 5, 5, 5),
378+
backgroundColor: ThemeManager.getThemeData().canvasColor,
364379
);
365380
})) {
366-
case 0:
367-
// Let's go.
368-
// ...
369-
break;
370-
case 1:
371-
// ...
372-
break;
373381
case null:
374382
// dialog dismissed
375383
break;

lib/screens/homepage/homepage_projectlist.dart

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@ class ProjectList extends StatelessWidget {
1616
@override
1717
Widget build(BuildContext context) {
1818
return Padding(
19-
padding: const EdgeInsets.all(16.0),
19+
padding: const EdgeInsets.all(5.0),
2020
child:
2121
Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
2222
Row(children: [
23-
const Text(
24-
"Recent Projects",
25-
style: TextStyle(
26-
fontWeight: FontWeight.bold,
27-
fontSize: 24.0,
28-
),
23+
const Padding(
24+
padding: EdgeInsets.all(10),
25+
child: Text(
26+
"Recent Projects",
27+
style: TextStyle(
28+
fontWeight: FontWeight.bold,
29+
fontSize: 24.0,
30+
),
31+
)
2932
),
3033
const Spacer(flex: 1),
3134
OutlinedButton(
@@ -40,16 +43,15 @@ class ProjectList extends StatelessWidget {
4043
OutlinedButton(
4144
onPressed: () async {
4245
FilePickerResult? result =
43-
await FilePicker.platform.pickFiles(
44-
allowMultiple: false
45-
);
46+
await FilePicker.platform.pickFiles(allowMultiple: false);
4647

4748
if (result != null) {
4849
var path = result.files.single.path;
49-
if(path != null) {
50+
if (path != null) {
5051
onAddProject(path);
51-
}else{
52-
debugPrint("[Open Project] error: the resulting path is null");
52+
} else {
53+
debugPrint(
54+
"[Open Project] error: the resulting path is null");
5355
}
5456
} else {
5557
// User canceled the picker

0 commit comments

Comments
 (0)