1+ import 'dart:io' ;
2+
3+ import 'package:file_picker/file_picker.dart' ;
4+ import 'package:filesystem_picker/filesystem_picker.dart' ;
15import 'package:flutter/cupertino.dart' ;
26import 'package:flutter/material.dart' ;
37import 'package:fluttertoast/fluttertoast.dart' ;
@@ -13,8 +17,8 @@ import 'package:open_configurator/globals.dart' as globals;
1317
1418
1519class 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 (
0 commit comments