Skip to content

Commit b796be5

Browse files
committed
Move the close project button to menu
1 parent ec8bc9e commit b796be5

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

lib/screens/editor/editor.dart

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import 'dart:async';
22
import 'dart:io';
33

4-
import 'package:corecoder_develop/util/custom_code_box.dart'
5-
show InnerField;
4+
import 'package:corecoder_develop/util/custom_code_box.dart' show InnerField;
65
import 'package:corecoder_develop/screens/editor/editor_drawer.dart';
76
import 'package:corecoder_develop/util/modules_manager.dart';
87
import 'package:corecoder_develop/util/theme_manager.dart';
@@ -27,7 +26,7 @@ class _EditorPageState extends State<EditorPage> {
2726
late CCSolution project;
2827
List<Document> documentList = [];
2928
List<TabData> tabs = [];
30-
Map<String,TabData> fileEditors = {};
29+
Map<String, TabData> fileEditors = {};
3130
bool autoCompleteShown = false;
3231
List<String> autoComplete = <String>[
3332
"var|hello",
@@ -37,7 +36,7 @@ class _EditorPageState extends State<EditorPage> {
3736
];
3837
double autoCompleteX = 0;
3938
double autoCompleteY = 0;
40-
int? selectedTab = null;
39+
int? selectedTab;
4140

4241
@override
4342
void initState() {
@@ -56,7 +55,7 @@ class _EditorPageState extends State<EditorPage> {
5655
//..border = Border(bottom: BorderSide(color: Colors.green[700]!, width: 3))
5756
..middleGap = 0
5857
..color = ThemeManager.getThemeSchemeColor("background");
59-
themeData.menu..textStyle = const TextStyle(color: Colors.white);
58+
themeData.menu.textStyle = const TextStyle(color: Colors.white);
6059
Radius radius = Radius.zero;
6160
BorderRadiusGeometry? borderRadius =
6261
BorderRadius.only(topLeft: radius, topRight: radius);
@@ -71,10 +70,11 @@ class _EditorPageState extends State<EditorPage> {
7170
shape: BoxShape.rectangle,
7271
color: Colors.black38,
7372
borderRadius: borderRadius)
74-
..selectedStatus.decoration = BoxDecoration(
73+
..selectedStatus.decoration = const BoxDecoration(
7574
color: Colors.black26,
7675
border: Border(top: BorderSide(color: Colors.greenAccent, width: 3)))
77-
..highlightedStatus.decoration = BoxDecoration(color: Colors.black12);
76+
..highlightedStatus.decoration =
77+
const BoxDecoration(color: Colors.black12);
7878
return themeData;
7979
}
8080

@@ -163,7 +163,6 @@ class _EditorPageState extends State<EditorPage> {
163163
late RestartableTimer autoSaveTimer;
164164

165165
void onAutoSave() async {
166-
debugPrint("autosave");
167166
for (var tab in tabs) {
168167
var field = (((tab.content as SingleChildScrollView).child as Container)
169168
.child as InnerField);
@@ -220,7 +219,7 @@ class _EditorPageState extends State<EditorPage> {
220219
}
221220

222221
void openFile(String filepath) async {
223-
if(!fileEditors.containsKey(filepath)) {
222+
if (!fileEditors.containsKey(filepath)) {
224223
var filename = path.basename(filepath);
225224
var content = await File(filepath).readAsString();
226225
//debugPrint(content);
@@ -238,10 +237,10 @@ class _EditorPageState extends State<EditorPage> {
238237
tabs.add(tab);
239238
selectedTab = tabs.length - 1;
240239
});
241-
}else{
240+
} else {
242241
// Tab already exists
243242
var tab = fileEditors[filepath];
244-
if(tab != null){
243+
if (tab != null) {
245244
setState(() {
246245
selectedTab = tabs.indexOf(tab);
247246
});
@@ -274,7 +273,7 @@ class _EditorPageState extends State<EditorPage> {
274273
break;
275274
}
276275
return Tooltip(
277-
verticalOffset: 64,
276+
verticalOffset: 64,
278277
message: desc,
279278
child: InkWell(
280279
//style: TextStyle(padding: MaterialStateProperty.all(EdgeInsets.zero)),
@@ -338,7 +337,7 @@ class _EditorPageState extends State<EditorPage> {
338337
var tabController = TabbedViewController(
339338
tabs,
340339
);
341-
tabController.selectedIndex = tabs.isNotEmpty? selectedTab : null;
340+
tabController.selectedIndex = tabs.isNotEmpty ? selectedTab : null;
342341
final page = Stack(children: [
343342
Column(//direction: Axis.vertical,
344343
children: [
@@ -398,12 +397,15 @@ class _EditorPageState extends State<EditorPage> {
398397
icon: const Icon(Icons.assessment_rounded),
399398
tooltip: "Toggle Console",
400399
),
401-
IconButton(
402-
onPressed: () => {Navigator.pop(context)},
403-
icon: const Icon(Icons.close),
404-
tooltip: "Close Project",
405-
),
406-
IconButton(onPressed: () => {}, icon: const Icon(Icons.more_horiz)),
400+
PopupMenuButton(
401+
child: const Icon(Icons.more_horiz),
402+
tooltip: "Menu",
403+
padding: const EdgeInsets.all(32.0),
404+
itemBuilder: (BuildContext context){
405+
return <PopupMenuEntry>[
406+
PopupMenuItem(child: const Text("Close Project"),onTap:()=> Navigator.pop(context),)
407+
];
408+
},),
407409
const SizedBox(width: 16.0),
408410
],
409411
),

0 commit comments

Comments
 (0)