Skip to content

Commit efd240f

Browse files
committed
Fixed solution doesnt have description and updated the homepage design
1 parent c6d1724 commit efd240f

File tree

3 files changed

+45
-42
lines changed

3 files changed

+45
-42
lines changed

lib/homepage.dart

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import 'dart:io';
32

43
import 'package:corecoder_develop/settings.dart';
@@ -14,14 +13,14 @@ import 'package:permission_handler/permission_handler.dart';
1413
import 'util/cc_project_structure.dart';
1514
import 'package:corecoder_develop/util/modules_manager.dart'
1615
show Module, ModulesManager, Template;
16+
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
1717
void loadSolution(
1818
CCSolution solution, BuildContext context, ModulesManager modulesManager) {
1919
/// Load the project
2020
// var template = modulesManager.getTemplateByIdentifier(solution.identifier);
2121
Navigator.pushNamed(context, EditorPage.routeName, arguments: solution);
2222
}
2323

24-
2524
class RecentProjectsManager {
2625
List<CCSolution> projects = List.empty(growable: true);
2726

@@ -46,7 +45,6 @@ class RecentProjectsManager {
4645
}
4746
}
4847

49-
5048
class HomePage extends StatefulWidget {
5149
HomePage({Key? key}) : super(key: key);
5250

@@ -60,9 +58,10 @@ class _HomePageState extends State<HomePage> {
6058
final Future<SharedPreferences> _pref = SharedPreferences.getInstance();
6159
var projectsWidgets = <Widget>[];
6260

63-
void showSettings(){
61+
void showSettings() {
6462
Navigator.pushNamed(context, SettingsPage.routeName);
6563
}
64+
6665
Future<void> showCreateProjectDialog() async {
6766
/// -------------------------------------------------
6867
/// Template Selection
@@ -134,7 +133,7 @@ class _HomePageState extends State<HomePage> {
134133

135134
/// Add it to recent projects
136135
CCSolution? project =
137-
await rpm.addSolution(slnPath);
136+
await rpm.addSolution(slnPath);
138137
if (project != null) {
139138
await rpm.commit(_pref);
140139
Navigator.pop(context, 3);
@@ -162,7 +161,7 @@ class _HomePageState extends State<HomePage> {
162161
children: [
163162
Image(
164163
image:
165-
ResizeImage.resizeIfNeeded(48, 48, t.icon.image)),
164+
ResizeImage.resizeIfNeeded(48, 48, t.icon.image)),
166165
Column(
167166
crossAxisAlignment: CrossAxisAlignment.start,
168167
children: [
@@ -190,14 +189,14 @@ class _HomePageState extends State<HomePage> {
190189
);
191190
})) {
192191
case 0:
193-
// Let's go.
194-
// ...
192+
// Let's go.
193+
// ...
195194
break;
196195
case 1:
197-
// ...
196+
// ...
198197
break;
199198
case null:
200-
// dialog dismissed
199+
// dialog dismissed
201200
break;
202201
}
203202
}
@@ -245,21 +244,24 @@ class _HomePageState extends State<HomePage> {
245244
setState(() {
246245
projectsWidgets.clear();
247246
for (CCSolution p in rpm.projects) {
248-
if(p.name == "") continue; // TODO: add better way to check if project is corrupt
247+
if (p.name == "")
248+
continue; // TODO: add better way to check if project is corrupt
249249
debugPrint(p.name);
250-
projectsWidgets.add(Container(
251-
constraints:
252-
const BoxConstraints(minWidth: 128.0, minHeight: 128.0),
253-
padding: const EdgeInsets.all(4.0),
254-
child: ElevatedButton(
255-
onPressed: () {
256-
loadSolution(p, context, mm);
257-
},
258-
child: Column(children: [
259-
if(p.image != null)
260-
Image(image: ResizeImage.resizeIfNeeded(48, 48, p.image!.image)),
261-
Text(p.name)
262-
]))));
250+
projectsWidgets.add(ListTile(
251+
onTap: () {
252+
loadSolution(p, context, mm);
253+
},
254+
leading: p.image != null
255+
? Image(image: ResizeImage.resizeIfNeeded(48, 48, p.image!.image))
256+
: const Icon(
257+
Icons.insert_drive_file,
258+
size: 48,
259+
),
260+
title: Text(p.name),
261+
subtitle:
262+
Text(p.desc + " Last Modified: " + p.dateModified.toString()),
263+
trailing: IconButton(onPressed: () { }, icon: const Icon(FontAwesomeIcons.ellipsisV),)
264+
));
263265
}
264266
});
265267
}
@@ -268,21 +270,19 @@ class _HomePageState extends State<HomePage> {
268270
Widget build(BuildContext context) {
269271
final page = Center(
270272
child: Container(
271-
padding: const EdgeInsets.all(16.0),
272-
constraints: BoxConstraints(
273-
minHeight: MediaQuery.of(context).size.height,
274-
minWidth: double.infinity),
275-
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
276-
const Text(
277-
"Recent Projects",
278-
),
279-
Wrap(
280-
children: projectsWidgets,
281-
direction: Axis.horizontal,
282-
alignment: WrapAlignment.start,
283-
)
284-
]),
285-
));
273+
padding: const EdgeInsets.all(16.0),
274+
constraints: BoxConstraints(
275+
minHeight: MediaQuery.of(context).size.height,
276+
minWidth: double.infinity),
277+
child: Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
278+
const Text(
279+
"Recent Projects",
280+
),
281+
Column(
282+
children: projectsWidgets,
283+
)
284+
]),
285+
));
286286
return Scaffold(
287287
appBar: AppBar(
288288
title: const Text("CoreCoder Develop"),

lib/modules/module_minecraft.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class MinecraftModule extends Module {
2929
"cc_version": "0.0.1",
3030
"name": args["Name"],
3131
"author": args["Author"],
32-
"description": args["Desc"],
32+
"description": args["Description"],
3333
"identifier": identifier,
3434
// must be unique to every module
3535
"folders": {

lib/util/cc_project_structure.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import 'modules_manager.dart';
1111
/* Class for storing project information */
1212
class CCSolution {
1313
final String name, desc, author, identifier, slnPath, slnFolderPath;
14+
DateTime dateModified;
1415
Image? get image{
1516
var module = ModulesManager.getModuleByIdentifier(identifier);
1617
if(module != null) {
@@ -23,16 +24,18 @@ class CCSolution {
2324
static const decoder = JsonDecoder();
2425

2526
CCSolution(this.name, this.desc, this.author, this.identifier, this.slnPath,
26-
this.slnFolderPath);
27+
this.slnFolderPath, this.dateModified);
2728

2829
static Future<CCSolution?> loadFromFile(String filepath) async{
2930
var file = File(filepath);
31+
var stat = await file.stat();
3032
if (await file.exists()) {
3133
String input = await file.readAsString();
3234
var obj = decoder.convert(input);
3335
try {
36+
3437
var result = CCSolution(obj["name"], obj["description"] ?? "",
35-
obj["author"], obj["identifier"], filepath, file.parent.path);
38+
obj["author"], obj["identifier"], filepath, file.parent.path, stat.modified);
3639

3740
/// Add the solution project folders
3841
var folders = (obj["folders"] as Map);

0 commit comments

Comments
 (0)