Skip to content

Commit

Permalink
0.0.1-9
Browse files Browse the repository at this point in the history
  • Loading branch information
trueToastedCode committed May 13, 2022
1 parent 3603b48 commit 7fff3c6
Show file tree
Hide file tree
Showing 75 changed files with 1,630 additions and 1,101 deletions.
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
<queries>
<!-- If your app opens https URLs -->
<intent>
<action android:name="android.intent.action.VIEW" />
<data android:scheme="https" />
</intent>
</queries>
<application
android:name="io.flutter.app.FlutterApplication"
android:label="open_configurator"
Expand Down
6 changes: 6 additions & 0 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ PODS:
- Flutter
- SwiftyGif (5.4.3)
- Toast (4.0.0)
- url_launcher (0.0.1):
- Flutter

DEPENDENCIES:
- file_picker (from `.symlinks/plugins/file_picker/ios`)
Expand All @@ -56,6 +58,7 @@ DEPENDENCIES:
- path_provider (from `.symlinks/plugins/path_provider/ios`)
- permission_handler (from `.symlinks/plugins/permission_handler/ios`)
- share (from `.symlinks/plugins/share/ios`)
- url_launcher (from `.symlinks/plugins/url_launcher/ios`)

SPEC REPOS:
trunk:
Expand All @@ -78,6 +81,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/permission_handler/ios"
share:
:path: ".symlinks/plugins/share/ios"
url_launcher:
:path: ".symlinks/plugins/url_launcher/ios"

SPEC CHECKSUMS:
DKImagePickerController: 72fd378f244cef3d27288e0aebf217a4467e4012
Expand All @@ -91,6 +96,7 @@ SPEC CHECKSUMS:
share: 0b2c3e82132f5888bccca3351c504d0003b3b410
SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
url_launcher: 6fef411d543ceb26efce54b05a0a40bfd74cbbef

PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c

Expand Down
5 changes: 5 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>https</string>
<string>http</string>
</array>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
Expand Down
168 changes: 167 additions & 1 deletion lib/globals.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
library open_configurator.globals;

import 'dart:convert';
import 'dart:io' show Directory, File, Platform;
import 'package:filesystem_picker/filesystem_picker.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:open_configurator/services/pconfig.dart';
import 'package:open_configurator/templates/number_widget.dart';
import 'package:path_provider/path_provider.dart';
import 'package:rect_getter/rect_getter.dart';
import 'package:share/share.dart';
import 'package:url_launcher/url_launcher.dart';

import 'templates/checkbox_widget.dart';
import 'templates/data_widget.dart';
import 'templates/string_widget.dart';

const OC_VERSION = '0.8.0';
const DISPLAY_VERSION = '0.0.1-9';

String selectedOCVersion;

bool isDark = true;
Function changeColorMode;
Expand Down Expand Up @@ -79,4 +90,159 @@ List<Widget> buildWidgetsNoTree(List<String> path, int orientation, double width
}
if (widgets.isNotEmpty) widgets.removeLast();
return widgets;
}

const INNER_PADDING = 8.0;
const ITEM_DEFAULT_WIDTH = 500.0;
const ITEM_DEFAULT_HEIGHT = 45.0;

void undoDialog(BuildContext context) {
showDialog(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: Text("Undo"),
content: Text("Do you really want to undo the last change?", style: TextStyle(fontSize: 15)),
actions: <Widget>[
TextButton(
child: Text("No", style: TextStyle(color: Colors.red)),
onPressed: () => Navigator.of(context).pop(),
),
TextButton(
child: Text("Yes", style: TextStyle(color: Colors.blue)),
onPressed: () {
Navigator.of(context).pop();
undoList.last();
undoList.removeLast();
},
),
],
),
);
}

void resetDialog(BuildContext context, Function onReset) {
showDialog(
context: context,
builder: (BuildContext context) => CupertinoAlertDialog(
title: Text("Leave"),
content: Text("Do you really want to leave this configuration?", style: TextStyle(fontSize: 15)),
actions: <Widget>[
TextButton(
child: Text("Yes", style: TextStyle(color: Colors.red)),
onPressed: () {
Navigator.of(context).pop();
onReset();
},
),
TextButton(
child: Text("No", style: TextStyle(color: Colors.blue)),
onPressed: () => Navigator.of(context).pop(),
),
],
),
);
}

void safeDialog(BuildContext context) async {
if (Platform.isIOS) {
try {
final str = await pConfig.compile();
if (str == null) {
Fluttertoast.showToast(
msg: "Unable to compile config!",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1,
fontSize: 16.0
);
return;
}
final data = utf8.encode(str);
final tempDir = await getApplicationSupportDirectory();
final file = await new File('${tempDir.path}/config.plist').create();
file.writeAsBytesSync(data);
final globalKey = RectGetter.createGlobalKey();
Rect rect = RectGetter.getRectFromKey(globalKey);
if (rect == null) {
// print('Rect is null');
Share.shareFiles([file.path]);
} else {
Share.shareFiles(
[file.path],
sharePositionOrigin: Rect.fromLTWH(
rect.left + 40, rect.top + 20, 2, 2));
}
} catch (e) {
Fluttertoast.showToast(
msg: "Error while saving config!",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1,
fontSize: 16.0
);
return;
}
} else {
String newPath;
if (isMobile) {
final path = await FilesystemPicker.open(
title: 'Save to folder',
context: context,
rootDirectory: Directory("/sdcard/"),
fsType: FilesystemType.folder,
pickText: 'Save file to this folder',
folderIconColor: Colors.teal,
);
if (path == null) return;
newPath = path + "/config.plist";
}else {
final path = pConfig.path;
for (int i=path.length-1; i>-1; i--) {
if (path[i] == ".") {
newPath = path.substring(0, i) + "_OpenConf.plist";
break;
}
}
if (newPath == null) {
newPath = path + "_OpenConf.plist";
}
}
pConfig.write(newPath);
showDialog(context: context, builder: (BuildContext context) => CupertinoAlertDialog(
title: Text("Done"),
content: Text("Config has been written to \"$newPath\""),
actions: <Widget>[
TextButton(
child: Text("Ok", style: TextStyle(color: Colors.blue)),
onPressed: () => Navigator.of(context).pop(),
),
],
));
}
}

openCorePkgPage() async {
const kextUrl = 'https://github.com/acidanthera/OpenCorePkg/releases';
if (await canLaunch(kextUrl)) {
await launch(kextUrl);
} else {
Fluttertoast.showToast(
msg: "Unable to launch url!",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1,
fontSize: 16.0
);
}
}

gatheringFilesPage() async {
const kextUrl = 'https://dortania.github.io/OpenCore-Install-Guide/ktext.html';
if (await canLaunch(kextUrl)) {
await launch(kextUrl);
} else {
Fluttertoast.showToast(
msg: "Unable to launch url!",
toastLength: Toast.LENGTH_SHORT,
timeInSecForIosWeb: 1,
fontSize: 16.0
);
}
}
54 changes: 42 additions & 12 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:desktop_window/desktop_window.dart';
import 'package:flutter/services.dart';
import 'package:open_configurator/pages/home/home_page.dart';
import 'package:open_configurator/pages/0.8.0/home/home_page.dart';
import 'package:open_configurator/globals.dart' as globals;
import 'package:open_configurator/pages/load_config_page.dart';
import 'package:sizer/sizer.dart';
Expand All @@ -22,6 +22,9 @@ void main() async {
} else if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
await DesktopWindow.setWindowSize(Size(900, 620));
}
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
));
runApp(Main());
}

Expand All @@ -31,7 +34,42 @@ class Main extends StatefulWidget {
}

class _MainState extends State<Main> {
void _onConfigLoaded() => setState(() {});

_reset() {
setState(() {
globals.pConfig = null;
globals.undoList = [];
globals.changeColorMode = null;
globals.changeColorMode2 = null;
globals.selectedOCVersion = null;
});
}

Widget _homePage() {
switch(globals.selectedOCVersion) {
case '0.8.0': return HomePage080(onReset: _reset);
}
return Scaffold(
body: SizedBox.expand(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text('Selected unimplemented version'),
TextButton(
onPressed: _reset,
child: Text('Ok')
),
],
),
),
);
}

void _onConfigLoaded(String selectedOCVersion) => setState(() {
globals.selectedOCVersion = selectedOCVersion;
});

@override
Widget build(BuildContext context) {
globals.changeColorMode = () {
Expand All @@ -42,22 +80,14 @@ class _MainState extends State<Main> {
}catch (e) {}
});
};

return MaterialApp(
theme: globals.isDark ? ThemeData.dark() : null,
home: globals.pConfig == null
? LoadConfigPage(
onConfigLoaded: _onConfigLoaded,
)
: HomePage(
onReset: () {
setState(() {
globals.pConfig = null;
globals.undoList = [];
globals.changeColorMode = null;
globals.changeColorMode2 = null;
});
},
),
: _homePage(),
);
}
}
33 changes: 33 additions & 0 deletions lib/pages/0.8.0/acpi/acpi_add_widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/cupertino.dart';
import 'package:open_configurator/templates/dict_array_widget.dart';
import 'package:open_configurator/globals.dart' as globals;

class AcpiAddWidget extends StatefulWidget {
@override
_AcpiAddWidgetState createState() => _AcpiAddWidgetState();
}

class _AcpiAddWidgetState extends State<AcpiAddWidget> {
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: globals.INNER_PADDING),
DictArrayWidget(
getArray: () => globals.pConfig.getValue(["content", "ACPI", "content", "Add", "content"], null),
setArray: (value) => globals.pConfig.setValue(["content", "ACPI", "content", "Add", "content"], value, null),
width: globals.ITEM_DEFAULT_WIDTH,
itemHeight: globals.ITEM_DEFAULT_HEIGHT,
keyForHeader: "Path",
getDummyEntry: () => {
"Comment": {"type": "string", "content": "My SSDT"},
"Enabled": {"type": "bool", "content": "0"},
"Path": {"type": "string", "content": "SSDT-*.aml"},
},
),
SizedBox(height: globals.INNER_PADDING),
],
);
}
}
Loading

0 comments on commit 7fff3c6

Please sign in to comment.