Skip to content

Commit d6e6328

Browse files
committed
Lots of UI Improvements
1 parent 96c45f2 commit d6e6328

File tree

8 files changed

+136
-91
lines changed

8 files changed

+136
-91
lines changed

lib/modules/jsapi.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,12 @@ class CoreCoder {
139139
var _onCreate = obj.getProperty('onCreate');
140140
if (_onCreate.isObject) {
141141
onCreate = (Map<String, dynamic> args) async {
142+
debugPrint("[Template onCreate] Creating JSObject");
142143
var optionsObj = JSObject.make(context,
143144
JSClass.create(JSClassDefinition(className: "OptionsObj")));
145+
debugPrint("[Template onCreate] Iterating through keys");
144146
for (var key in args.keys) {
147+
debugPrint("[Template onCreate] $key");
145148
var value = args[key];
146149
if (value is String) {
147150
optionsObj.setProperty(key, JSValue.makeString(context, value),
@@ -154,10 +157,12 @@ class CoreCoder {
154157
}
155158
}
156159
JSValuePointer? err;
160+
debugPrint("[Template onCreate] Calling JS Function");
157161
JSValue result = _onCreate.toObject().callAsFunction(
158162
JSObject(context, _obj),
159163
JSValuePointer.array([optionsObj.toValue()]),
160164
exception: err);
165+
debugPrint("[Template onCreate] Checking result error.");
161166
if (err != null && err.getValue(context).isObject) {
162167
var errObj = err.getValue(context).toObject();
163168
var name = errObj.getProperty("name").string;

lib/modules/module_jsplugins.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class JsModule extends Module {
222222
ModulesManager modulesManager, BuildContext buildContext) async {
223223
this.buildContext = buildContext;
224224
context =
225-
jscore.JSContext.createInGroup(group: jscore.JSContextGroup.create());
225+
jscore.JSContext.createInGroup(group: null);
226226
globalObj = context.globalObject;
227227
_globalObjPtr = globalObj.pointer;
228228
CoreCoder.module = this;

lib/screens/homepage/homepage.dart

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ class _HomePageState extends State<HomePage> {
126126
result.add(Card(
127127
//TODO: refactor this as a widget elsewhere, then reference that widget from here
128128
child: ListTile(
129+
130+
shape: RoundedRectangleBorder(
131+
borderRadius: BorderRadius.circular(4),
132+
side: BorderSide(color: Theme.of(context).dividerColor),
133+
),
129134
onTap: () {
130135
if (p.type == HistoryItemType.solution) {
131136
touchFile(File(p.solution!.slnPath), p.solution!);
@@ -401,6 +406,9 @@ class _HomePageState extends State<HomePage> {
401406
);
402407
});
403408
for (var path in paths) {
409+
if(path.endsWith("."))
410+
path = path.substring(0,path.length - 2);
411+
debugPrint(path);
404412
Directory target = Directory(path);
405413
text = path;
406414
await target.delete(recursive: true);
@@ -499,7 +507,13 @@ class _HomePageState extends State<HomePage> {
499507
const SizedBox(width: 16.0),
500508
],
501509
),
502-
body: SingleChildScrollView(child: page),
510+
body: Container(
511+
512+
decoration: BoxDecoration(
513+
image: DecorationImage(
514+
image: ThemeManager.getImage("mainBG")!.image, fit: BoxFit.cover)),
515+
child:SingleChildScrollView(child: page,)
516+
),
503517
floatingActionButton: FloatingActionButton(
504518
onPressed: () => showCreateProjectDialog(),
505519
child: const Icon(Icons.create_new_folder),

lib/screens/homepage/homepage_project_create.dart

Lines changed: 94 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ import 'package:shared_preferences/shared_preferences.dart';
1010

1111
import 'homepage.dart';
1212

13-
class HomePageProjectCreate extends StatelessWidget {
13+
class HomePageProjectCreate extends StatefulWidget {
1414
final Function refreshProjects;
15-
1615
const HomePageProjectCreate({Key? key, required this.refreshProjects})
1716
: super(key: key);
1817

18+
@override
19+
State<StatefulWidget> createState() => HomePageProjectCreateState();
20+
21+
}
22+
class HomePageProjectCreateState extends State<HomePageProjectCreate>{
23+
Widget? dialog;
1924
Future<SharedPreferences> get _pref async {
2025
return await SharedPreferences.getInstance();
2126
}
@@ -33,6 +38,73 @@ class HomePageProjectCreate extends StatelessWidget {
3338
style:
3439
const TextStyle(fontSize: 18, fontWeight: FontWeight.bold))));
3540
for (Template t in m.templates) {
41+
List<Widget> controls = List.empty(growable: true);
42+
43+
/// The options changed later after the window closed
44+
Map<String, dynamic> values = {};
45+
46+
/// Add Options
47+
for (var argName in t.options.keys) {
48+
controls.add(Row(children: [
49+
const Icon(Icons.subdirectory_arrow_right_outlined),
50+
Text(
51+
argName,
52+
textAlign: TextAlign.start,
53+
)
54+
]));
55+
var optionVal = (t.options[argName] ?? "");
56+
if (optionVal.startsWith("String")) {
57+
var splt = optionVal.split("|");
58+
var hint = splt.length > 1 ? splt[1] : argName;
59+
controls.add(Padding(
60+
padding: const EdgeInsets.only(bottom: 16.0),
61+
child: TextField(
62+
decoration: InputDecoration(hintText: hint),
63+
maxLines: 1,
64+
autofocus: true,
65+
onChanged: (change) {
66+
values[argName] = change;
67+
})));
68+
values[argName] = "";
69+
}
70+
}
71+
72+
/// Add Buttons
73+
var row = Row(
74+
mainAxisAlignment: MainAxisAlignment.end,
75+
children: [
76+
TextButton(
77+
child: const Text("Cancel"),
78+
onPressed: () {
79+
setState(() {
80+
dialog = null;
81+
});
82+
},
83+
),
84+
ElevatedButton(
85+
child: const Text("Create"),
86+
onPressed: () async {
87+
/// Go Ahead and create project asynchronously
88+
var slnPath = await t.onCreated(
89+
values); //TODO: This is prone to error (not checking if the file existed first)
90+
if (slnPath == null) return;
91+
92+
/// Add it to recent projects
93+
CCSolution? project =
94+
await RecentProjectsManager.instance.addSolution(slnPath);
95+
if (project != null) {
96+
await RecentProjectsManager.instance
97+
.commit(SharedPreferences.getInstance());
98+
//Navigator.pop(context, 3);
99+
//refreshProjects();
100+
loadSolution(project, context);
101+
}
102+
},
103+
)
104+
],
105+
);
106+
controls.add(row);
107+
36108
/// -------------------------------------------------
37109
/// Project Options
38110
/// -------------------------------------------------
@@ -43,24 +115,30 @@ class HomePageProjectCreate extends StatelessWidget {
43115
subtitle: Text(t.desc),
44116
tileColor: ThemeManager.getThemeData().backgroundColor,
45117
onTap: () async {
46-
Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) => ProjectWizard(t,refreshProjects)));
118+
setState(() {
119+
dialog = ProjectWizard(
120+
t,
121+
children: controls,
122+
);
123+
});
47124
},
48125
)));
49126
}
50127
}
51128
return Scaffold(
52-
appBar: AppBar(
53-
title: const Center(child: Text('Create new project')),
54-
),
55-
body: SingleChildScrollView(
56-
child: Padding(
57-
padding: const EdgeInsets.all(16.0),
58-
child: Column(
59-
children: options,
60-
crossAxisAlignment: CrossAxisAlignment.stretch,
61-
))),
62-
//contentPadding: const EdgeInsets.fromLTRB(5, 5, 5, 5),
63-
backgroundColor: ThemeManager.getThemeData().canvasColor,
64-
);
129+
appBar: AppBar(
130+
title: const Center(child: Text('Create new project')),
131+
),
132+
body: Stack(children: [
133+
SingleChildScrollView(
134+
child: Padding(
135+
padding: const EdgeInsets.all(16.0),
136+
child: Column(
137+
children: options,
138+
crossAxisAlignment: CrossAxisAlignment.stretch,
139+
))),
140+
if(dialog != null)
141+
Positioned.fill(child: dialog!)
142+
]));
65143
}
66144
}

lib/screens/homepage/homepage_project_wizard.dart

Lines changed: 4 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -7,77 +7,12 @@ import 'homepage.dart';
77

88
class ProjectWizard extends StatelessWidget {
99
final Template template;
10-
final Function refreshProjects;
10+
final List<Widget> children;
1111

12-
const ProjectWizard(this.template, this.refreshProjects, {Key? key}) : super(key: key);
12+
const ProjectWizard(this.template, {Key? key, required this.children}) : super(key: key);
1313

1414
@override
1515
Widget build(BuildContext context) {
16-
17-
List<Widget> controls = List.empty(growable: true);
18-
/// The options changed later after the window closed
19-
Map<String, dynamic> values = {};
20-
21-
/// Add Options
22-
for (var argName in template.options.keys) {
23-
controls.add(Row(children: [
24-
const Icon(Icons.subdirectory_arrow_right_outlined),
25-
Text(
26-
argName,
27-
textAlign: TextAlign.start,
28-
)
29-
]));
30-
var optionVal = (template.options[argName] ?? "");
31-
if (optionVal.startsWith("String")) {
32-
var splt = optionVal.split("|");
33-
var hint = splt.length > 1? splt[1] : argName;
34-
controls.add(Padding(
35-
padding: const EdgeInsets.only(bottom: 16.0),
36-
child: TextField(
37-
decoration: InputDecoration(hintText: hint),
38-
maxLines: 1,
39-
autofocus: true,
40-
onChanged: (change) {
41-
values[argName] = change;
42-
})));
43-
values[argName] = "";
44-
}
45-
}
46-
47-
/// Add Buttons
48-
var row = Row(
49-
mainAxisAlignment: MainAxisAlignment.end,
50-
children: [
51-
TextButton(
52-
child: const Text("Cancel"),
53-
onPressed: () {
54-
Navigator.pop(context, 1);
55-
},
56-
),
57-
ElevatedButton(
58-
child: const Text("Create"),
59-
onPressed: () async {
60-
/// Go Ahead and create project asynchronously
61-
var slnPath = await template.onCreated(
62-
values); //TODO: This is prone to error (not checking if the file existed first)
63-
if (slnPath == null) return;
64-
65-
/// Add it to recent projects
66-
CCSolution? project = await RecentProjectsManager
67-
.instance
68-
.addSolution(slnPath);
69-
if (project != null) {
70-
await RecentProjectsManager.instance.commit(SharedPreferences.getInstance());
71-
Navigator.pop(context, 3);
72-
refreshProjects();
73-
loadSolution(project, context);
74-
}
75-
},
76-
)
77-
],
78-
);
79-
controls.add(row);
80-
8116
return Scaffold(
8217
appBar: AppBar(
8318
title: Text('Create ${template.title}'),
@@ -86,9 +21,9 @@ class ProjectWizard extends StatelessWidget {
8621
child: Column(
8722
children: <Widget>[
8823
Padding(
89-
padding: const EdgeInsets.symmetric(horizontal: 16.0),
24+
padding: const EdgeInsets.all(16.0),
9025
child: Column(
91-
children: controls,
26+
children: children,
9227
crossAxisAlignment: CrossAxisAlignment.stretch,
9328
))
9429
],

lib/util/desktop_tabbar.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,18 @@ class DesktopTabBarState extends State<DesktopTabBar> {
4343
Widget build(BuildContext context) {
4444
var query = MediaQuery.of(context);
4545

46-
colorBackground = ThemeManager.getThemeSchemeColor("backgroundTertiary");
47-
colorBackgroundSecondary =
48-
ThemeManager.getThemeSchemeColor("backgroundSecondary");
46+
colorBackground = Colors.transparent;//ThemeManager.getThemeSchemeColor("backgroundTertiary");
47+
colorBackgroundSecondary = Colors.transparent;
48+
//ThemeManager.getThemeSchemeColor("backgroundSecondary");
4949
return Container(
50-
color: colorBackground,
50+
color: Colors.black12,
5151
constraints: BoxConstraints(maxHeight: query.size.height - 200),
5252
child: Flex(
5353
direction: Axis.horizontal,
5454
crossAxisAlignment: CrossAxisAlignment.stretch,
5555
children: <Widget>[
5656
Container(
57+
color: Theme.of(context).backgroundColor,
5758
padding: const EdgeInsets.all(16.0),
5859
child: SingleChildScrollView(
5960
child: Column(

lib/util/theme_manager.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:convert';
2+
13
import 'package:flutter/material.dart';
24
import './themes.dart';
35

@@ -16,6 +18,12 @@ class ThemeManager {
1618
var scheme = editor!["scheme"] as Map<String, Color>;
1719
return scheme[name];
1820
}
21+
static Image? getImage(String name, {String? themeName}){
22+
themeName ??= currentTheme.value; // if name is not mentioned
23+
var editor = editorThemes[themeName];
24+
var scheme = (editor!["images"] ?? <String,String>{}) as Map<String, String>;
25+
return Image.memory( base64Decode( scheme[name] ?? "" ) ) ;
26+
}
1927

2028
static Color? getThemeColor(String name, {String? themeName}){
2129
themeName ??= currentTheme.value; // if name is not mentioned

lib/util/themes.dart

Lines changed: 4 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)