Skip to content

Commit 5590dfc

Browse files
OC 0.0.7
1 parent 9e5ee83 commit 5590dfc

10 files changed

Lines changed: 170 additions & 107 deletions

lib/main.dart

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@ import 'dart:io';
22
import 'package:flutter/cupertino.dart';
33
import 'package:flutter/material.dart';
44
import 'package:desktop_window/desktop_window.dart';
5+
import 'package:flutter/services.dart';
56
import 'package:open_configurator/pages/home/home_page.dart';
67
import 'package:open_configurator/globals.dart' as globals;
78
import 'package:open_configurator/pages/load_config_page.dart';
89

910
void main() async {
1011
WidgetsFlutterBinding.ensureInitialized();
11-
if (/*Platform.isWindows || */Platform.isLinux || Platform.isMacOS) {
12+
13+
globals.isMobile = !(Platform.isWindows || Platform.isLinux || Platform.isMacOS);
14+
if (globals.isMobile ) {
15+
SystemChrome.setPreferredOrientations([
16+
DeviceOrientation.landscapeLeft,
17+
]);
18+
} else if (/*Platform.isWindows || */Platform.isLinux || Platform.isMacOS) {
1219
await DesktopWindow.setWindowSize(Size(900, 620));
1320
}
14-
globals.isMobile = !(Platform.isWindows || Platform.isLinux || Platform.isMacOS);
1521
runApp(Main());
1622
}
1723

@@ -47,18 +53,6 @@ class _MainState extends State<Main> {
4753
globals.changeColorMode2 = null;
4854
});
4955
},
50-
onSave: () {
51-
final path = globals.pConfig.path;
52-
String newPath;
53-
for (int i=path.length-1; i>-1; i--) {
54-
if (path[i] == ".") {
55-
newPath = path.substring(0, i) + "_OpenConf.plist";
56-
break;
57-
}
58-
}
59-
if (newPath == null) newPath = path + "_OpenConf.plist";
60-
globals.pConfig.write(newPath);
61-
},
6256
),
6357
);
6458
}

lib/pages/home/home_page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import 'package:open_configurator/pages/home/sidebar.dart';
44
import 'package:open_configurator/pages/nvram/nvram_page.dart';
55

66
class HomePage extends StatefulWidget {
7-
final Function onSave, onReset;
8-
const HomePage({this.onSave, this.onReset});
7+
final Function onReset;
8+
const HomePage({this.onReset});
99
@override
1010
_HomePageState createState() => _HomePageState();
1111
}
@@ -20,7 +20,7 @@ class _HomePageState extends State<HomePage> {
2020
body: SafeArea(
2121
child: Row(
2222
children: [
23-
SideBar(setPage: _setPage, onSave: widget.onSave, onReset: widget.onReset),
23+
SideBar(setPage: _setPage, onReset: widget.onReset),
2424
Expanded(child: _page),
2525
],
2626
),

lib/pages/home/sidebar.dart

Lines changed: 100 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import 'dart:io';
2+
3+
import 'package:file_picker/file_picker.dart';
4+
import 'package:filesystem_picker/filesystem_picker.dart';
15
import 'package:flutter/cupertino.dart';
26
import 'package:flutter/material.dart';
37
import 'package:fluttertoast/fluttertoast.dart';
@@ -13,8 +17,8 @@ import 'package:open_configurator/globals.dart' as globals;
1317

1418

1519
class SideBar extends StatefulWidget {
16-
final Function setPage, onSave, onReset;
17-
const SideBar({this.setPage, this.onSave, this.onReset});
20+
final Function setPage, onReset;
21+
const SideBar({this.setPage, this.onReset});
1822
@override
1923
_SideBarState createState() => _SideBarState();
2024
}
@@ -48,68 +52,80 @@ class _SideBarState extends State<SideBar> {
4852
@override
4953
Widget build(BuildContext context) {
5054
return Container(
51-
width: globals.isMobile ? 190 : 150,
55+
width: globals.isMobile ? 175 : 170,
5256
height: double.infinity,
5357
color: globals.isDark ? Color(0xff0C0C0D) : null,
5458
child: Column(
5559
children: [
56-
..._ENTRIES.keys.map((String key) => Container(
57-
margin: globals.isMobile ? EdgeInsets.only(bottom: 5) : null,
58-
padding: EdgeInsets.only(right: 12),
59-
width: double.infinity,
60-
height: globals.isMobile ? 35 : 25,
61-
child: ClipRRect(
62-
borderRadius: BorderRadius.circular(25),
63-
child: Material(
64-
color: _selectedPage == key ? Colors.blue : Colors.transparent,
65-
child: InkWell(
66-
onTap: () {
67-
setState(() => _selectedPage = key);
68-
widget.setPage(_getPage(key));
69-
},
70-
child: Padding(
71-
padding: EdgeInsets.only(left: 5),
72-
child: Row(
73-
children: [
74-
Icon(_ENTRIES[key], size: 14, color: globals.isDark ? Colors.white : Colors.black),
75-
SizedBox(width: 4),
76-
Text(key, style: TextStyle(fontSize: globals.isMobile ? 17 : 14, color: globals.isDark ? Colors.white : Colors.black))
77-
],
78-
),
60+
Expanded(
61+
child: Padding(
62+
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
63+
child: ClipRRect(
64+
borderRadius: BorderRadius.only(
65+
bottomLeft: Radius.circular(15),
66+
bottomRight: Radius.circular(15),
67+
),
68+
child: Container(
69+
color: globals.isDark ? Colors.white.withOpacity(0.07) : Colors.white.withOpacity(0.01),
70+
child: ListView(
71+
children: [
72+
..._ENTRIES.keys.map((String key) => Container(
73+
margin: globals.isMobile ? EdgeInsets.only(bottom: 5) : null,
74+
padding: EdgeInsets.only(right: 0),
75+
width: double.infinity,
76+
height: globals.isMobile ? 31 : 25,
77+
child: ClipRRect(
78+
borderRadius: BorderRadius.circular(25),
79+
child: Material(
80+
color: _selectedPage == key ? Colors.blue : Colors.transparent,
81+
child: InkWell(
82+
onTap: () {
83+
setState(() => _selectedPage = key);
84+
widget.setPage(_getPage(key));
85+
},
86+
child: Padding(
87+
padding: EdgeInsets.only(left: 5),
88+
child: Row(
89+
children: [
90+
Icon(_ENTRIES[key], size: 14, color: globals.isDark ? Colors.white : Colors.black),
91+
SizedBox(width: 4),
92+
Text(key, style: TextStyle(fontSize: globals.isMobile ? 17 : 14, color: globals.isDark ? Colors.white : Colors.black))
93+
],
94+
),
95+
),
96+
),
97+
),
98+
),
99+
)).toList(),
100+
],
79101
),
80102
),
81103
),
82104
),
83-
)).toList(),
84-
Expanded(child: Container()),
105+
),
85106
Row(
86107
mainAxisAlignment: MainAxisAlignment.center,
87108
children: [
88-
Column(
89-
crossAxisAlignment: CrossAxisAlignment.center,
90-
children: [
91-
Text("Darkmode", style: TextStyle(fontSize: 13)),
92-
Transform.scale(
93-
scale: 0.7,
94-
child: CupertinoSwitch(
95-
value: globals.isDark,
96-
onChanged: (value) => globals.changeColorMode(),
97-
),
98-
),
99-
],
109+
Text("Darkmode", style: TextStyle(fontSize: 13)),
110+
Transform.scale(
111+
scale: 0.7,
112+
child: CupertinoSwitch(
113+
value: globals.isDark,
114+
onChanged: (value) => globals.changeColorMode(),
115+
),
100116
),
101117
],
102118
),
103-
SizedBox(height: 15),
119+
SizedBox(height: 5),
104120
Row(
105121
mainAxisAlignment: MainAxisAlignment.center,
106122
children: [
107123
SizedBox(width: 3),
108124
Column(
109125
crossAxisAlignment: CrossAxisAlignment.center,
110126
children: [
111-
Text("OpenConfigurator 0.0.1-4", style: TextStyle(fontSize: 10)),
112-
Text("OpenCore 0.6.9", style: TextStyle(fontSize: 10)),
127+
Text("OpenConfigurator 0.0.1-5", style: TextStyle(fontSize: 10)),
128+
Text("OpenCore 0.7.0", style: TextStyle(fontSize: 10)),
113129
],
114130
),
115131
],
@@ -126,21 +142,21 @@ class _SideBarState extends State<SideBar> {
126142
timeInSecForIosWeb: 1,
127143
fontSize: 16.0
128144
);
129-
}else undoDialog();
145+
}else _undoDialog();
130146
},
131147
// icon: Icon(Icons.undo, size: 13),
132148
icon: Icon(Icons.undo, size: globals.isMobile ? 30 : 18),
133149
padding: EdgeInsets.all(0),
134150
splashRadius: 12,
135151
),
136152
IconButton(
137-
onPressed: widget.onSave,
153+
onPressed: _safeDialog,
138154
icon: Icon(Icons.save, size: globals.isMobile ? 25 : 13),
139155
padding: EdgeInsets.all(0),
140156
splashRadius: 12,
141157
),
142158
IconButton(
143-
onPressed: resetDialog,
159+
onPressed: _resetDialog,
144160
icon: Icon(Icons.exit_to_app, size: globals.isMobile ? 25 : 13),
145161
padding: EdgeInsets.all(0),
146162
splashRadius: 12,
@@ -152,7 +168,43 @@ class _SideBarState extends State<SideBar> {
152168
);
153169
}
154170

155-
void undoDialog() {
171+
void _safeDialog() async {
172+
String newPath;
173+
if (globals.isMobile) {
174+
final path = await FilesystemPicker.open(
175+
title: 'Save to folder',
176+
context: context,
177+
rootDirectory: Directory("/sdcard/"),
178+
fsType: FilesystemType.folder,
179+
pickText: 'Save file to this folder',
180+
folderIconColor: Colors.teal,
181+
);
182+
if (path == null) return;
183+
newPath = path + "_OpenConf.plist";
184+
}else {
185+
final path = globals.pConfig.path;
186+
for (int i=path.length-1; i>-1; i--) {
187+
if (path[i] == ".") {
188+
newPath = path.substring(0, i) + "_OpenConf.plist";
189+
break;
190+
}
191+
}
192+
if (newPath == null) newPath = path + "_OpenConf.plist";
193+
}
194+
globals.pConfig.write(newPath);
195+
showDialog(context: context, builder: (BuildContext context) => CupertinoAlertDialog(
196+
title: Text("Done"),
197+
content: Text("Config has been written to \"$newPath\""),
198+
actions: <Widget>[
199+
TextButton(
200+
child: Text("Ok", style: TextStyle(color: Colors.blue)),
201+
onPressed: () => Navigator.of(context).pop(),
202+
),
203+
],
204+
));
205+
}
206+
207+
void _undoDialog() {
156208
showDialog(
157209
context: context,
158210
builder: (BuildContext context) => CupertinoAlertDialog(
@@ -176,7 +228,7 @@ class _SideBarState extends State<SideBar> {
176228
);
177229
}
178230

179-
void resetDialog() {
231+
void _resetDialog() {
180232
showDialog(
181233
context: context,
182234
builder: (BuildContext context) => CupertinoAlertDialog(

lib/pages/load_config_page.dart

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:clipboard/clipboard.dart';
2+
import 'package:file_picker/file_picker.dart';
23
import 'package:flutter/cupertino.dart';
34
import 'package:flutter/material.dart';
45
import 'package:fluttertoast/fluttertoast.dart';
@@ -21,8 +22,10 @@ class _LoadConfigPageState extends State<LoadConfigPage> {
2122
Future<void> _loadConfig() async {
2223
// check permission
2324
bool storageError = false;
24-
25+
// load
26+
String value;
2527
if (Platform.isAndroid) {
28+
// load form android
2629
if (! await Permission.storage.request().isGranted) storageError = true;
2730
else if (! await Permission.manageExternalStorage.request().isGranted) storageError = true;
2831
if (storageError) {
@@ -34,22 +37,26 @@ class _LoadConfigPageState extends State<LoadConfigPage> {
3437
);
3538
return;
3639
}
37-
}
38-
// load
39-
String value = await FlutterClipboard.paste();
40-
if (value == null || value.length == 0) {
41-
// error: clipboard is empty
42-
_showError("Error (Clipboard is empty)");
43-
return;
44-
}
45-
// remove quotation marks
46-
if (value[0] == "\"" && value[value.length-1] == "\"") {
47-
value = value.substring(1, value.length-1);
48-
if (value.length == 0) {
40+
final result = await FilePicker.platform.pickFiles();
41+
if (result == null) return;
42+
value = result.files.single.path;
43+
}else {
44+
// load from desktop os
45+
value = await FlutterClipboard.paste();
46+
if (value == null || value.length == 0) {
4947
// error: clipboard is empty
5048
_showError("Error (Clipboard is empty)");
5149
return;
5250
}
51+
// remove quotation marks
52+
if (value[0] == "\"" && value[value.length-1] == "\"") {
53+
value = value.substring(1, value.length-1);
54+
if (value.length == 0) {
55+
// error: clipboard is empty
56+
_showError("Error (Clipboard is empty)");
57+
return;
58+
}
59+
}
5360
}
5461
// read and parse file
5562
final pConfig = PConfig(path: value);
@@ -122,7 +129,7 @@ class _LoadConfigPageState extends State<LoadConfigPage> {
122129
onTap: _loadConfig,
123130
child: Center(
124131
child: Text(
125-
"Paste path",
132+
Platform.isAndroid ? "Open" : "Paste path",
126133
style: TextStyle(
127134
color: const Color(0xff000000),
128135
fontWeight: FontWeight.bold
@@ -161,7 +168,7 @@ class _LoadConfigPageState extends State<LoadConfigPage> {
161168
style: TextStyle(fontSize: 12),
162169
),
163170
Text(
164-
"Android: /sdcard/...",
171+
"Android: Press Open",
165172
style: TextStyle(fontSize: 12),
166173
),
167174
],

lib/pages/misc/misc_entries_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class _MiscEntriesWidgetState extends State<MiscEntriesWidget> {
2525
"Auxiliary": {"type": "bool", "content": "0"},
2626
"Comment": {"type": "string", "content": ""},
2727
"Enabled": {"type": "bool", "content": "0"},
28+
"Flavour": {"type": "string", "content": "Auto"},
2829
"Name": {"type": "string", "content": ""},
2930
"Path": {"type": "string", "content": ""},
3031
"TextMode": {"type": "bool", "content": "0"},

lib/pages/misc/misc_tools_widget.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class _MiscToolsWidgetState extends State<MiscToolsWidget> {
2525
"Auxiliary": {"type": "bool", "content": "0"},
2626
"Comment": {"type": "string", "content": ""},
2727
"Enabled": {"type": "bool", "content": "0"},
28+
"Flavour": {"type": "string", "content": "Auto"},
2829
"Name": {"type": "string", "content": ""},
2930
"Path": {"type": "string", "content": ""},
3031
"RealPath": {"type": "bool", "content": "0"},

lib/pages/nvram/nvram_add_widget.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ class _NvramAddWidgetState extends State<NvramAddWidget> {
7070
getValue: () => globals.pConfig.pConfig["content"]["NVRAM"]["content"]["Add"]["content"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["content"]["run-efi-updater"]["content"],
7171
setValue: (value) => globals.pConfig.pConfig["content"]["NVRAM"]["content"]["Add"]["content"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["content"]["run-efi-updater"]["content"] = value,
7272
),
73+
SizedBox(height: 4),
74+
StringWidget(
75+
width: 270,
76+
title: "ForceDisplayRotationInEFI",
77+
getValue: () => globals.pConfig.pConfig["content"]["NVRAM"]["content"]["Add"]["content"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["content"]["ForceDisplayRotationInEFI"]["content"],
78+
setValue: (value) => globals.pConfig.pConfig["content"]["NVRAM"]["content"]["Add"]["content"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["content"]["ForceDisplayRotationInEFI"]["content"] = value,
79+
),
7380
],
7481
);
7582
}

0 commit comments

Comments
 (0)