Skip to content

Commit 75c25d2

Browse files
authored
Merge pull request #20 from Hanprogramer/main
Merge from main
2 parents dc5bb16 + cd326ef commit 75c25d2

14 files changed

+507
-204
lines changed

lib/editor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ class _EditorPageState extends State<EditorPage> {
327327
var tabController = TabbedViewController(
328328
tabs,
329329
);
330-
tabController.selectedIndex = selectedTab;
330+
tabController.selectedIndex = tabs.isNotEmpty? selectedTab : null;
331331
final page = Stack(children: [
332332
Column(//direction: Axis.vertical,
333333
children: [

lib/homepage.dart

Lines changed: 223 additions & 180 deletions
Large diffs are not rendered by default.

lib/main.dart

Lines changed: 101 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,41 @@ import 'package:provider/provider.dart';
1010
import 'package:provider/single_child_widget.dart';
1111
import 'homepage.dart';
1212
import 'editor_drawer.dart';
13+
import 'package:bitsdojo_window/bitsdojo_window.dart';
1314

14-
void main() async{
15+
void main() async {
1516
runApp(const CoreCoderApp());
17+
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
18+
doWhenWindowReady(() {
19+
const initialSize = Size(800, 600);
20+
appWindow.minSize = const Size(256, 256);
21+
appWindow.size = initialSize;
22+
appWindow.alignment = Alignment.center;
23+
appWindow.show();
24+
});
25+
}
1626
}
1727

28+
const borderColor = Color(0xFF3BBA73);
1829

1930
class CoreCoderApp extends StatefulWidget {
2031
const CoreCoderApp({Key? key}) : super(key: key);
21-
32+
static const String version = "v0.0.1";
33+
static bool isDesktop = (Platform.isWindows || Platform.isLinux || Platform.isMacOS);
34+
static bool isLandscape(BuildContext context){
35+
var q = MediaQuery.of(context);
36+
return q.orientation == Orientation.landscape || q.size.width > q.size.height;
37+
}
2238
@override
2339
State<StatefulWidget> createState() {
2440
return CoreCoderAppState();
2541
}
2642
}
2743

28-
class CoreCoderAppState extends State<CoreCoderApp>{
44+
class CoreCoderAppState extends State<CoreCoderApp> {
2945
String themeName = "core-coder-dark";
46+
var borderColor = Colors.black;
47+
3048
@override
3149
void initState() {
3250
super.initState();
@@ -35,7 +53,7 @@ class CoreCoderAppState extends State<CoreCoderApp>{
3553
themeName = ThemeManager.currentTheme.value;
3654
});
3755
});
38-
if(Platform.isWindows) {
56+
if (Platform.isWindows) {
3957
/// On windows, get the runtime arguments
4058
/// this is provided by windows when you "Open with" CoreCoder
4159
/// the result is a string to the absolute path of the file
@@ -50,22 +68,89 @@ class CoreCoderAppState extends State<CoreCoderApp>{
5068
@override
5169
Widget build(BuildContext context) {
5270
return MultiProvider(
53-
child: MaterialApp(
54-
debugShowCheckedModeBanner: false,
55-
title: 'CoreCoder Develop',
56-
theme: ThemeManager.getThemeData(themeName:themeName),
57-
//home: HomePage(),
58-
initialRoute: "/",
59-
routes: {
60-
"/": (context) => HomePage(),
61-
EditorPage.routeName: (context) => const EditorPage(),
62-
PluginsBrowser.routeName: (context) => const PluginsBrowser()
63-
},
64-
),
71+
child: WindowBorder(
72+
color: borderColor,
73+
child: MaterialApp(
74+
debugShowCheckedModeBanner: false,
75+
title: 'CoreCoder Develop',
76+
theme: ThemeManager.getThemeData(themeName: themeName),
77+
//home: HomePage(),
78+
initialRoute: "/",
79+
routes: {
80+
"/": (context) => HomePage(),
81+
EditorPage.routeName: (context) => const EditorPage(),
82+
PluginsBrowser.routeName: (context) => const PluginsBrowser()
83+
},
84+
builder: (BuildContext context, Widget? widget) {
85+
borderColor = Theme.of(context).primaryColor;
86+
return Container(
87+
color: Theme.of(context).colorScheme.background,
88+
child: Column(
89+
children: [
90+
// The title bar
91+
WindowTitleBarBox(
92+
child: Row(children: [
93+
Expanded(
94+
child: MoveWindow(
95+
child: Row(children: [
96+
const SizedBox(
97+
width: 16.0,
98+
),
99+
Image.asset(
100+
"assets/logo.png",
101+
isAntiAlias: true,
102+
filterQuality: FilterQuality.high,
103+
width: 20,
104+
height: 20,
105+
),
106+
const SizedBox(
107+
width: 16.0,
108+
),
109+
Text(
110+
"CoreCoder:Develop ${CoreCoderApp.version}",
111+
style: Theme.of(context).textTheme.bodyText1!,
112+
)
113+
]),
114+
)),
115+
const WindowButtons()
116+
])),
117+
if (widget != null) Expanded(child: widget)
118+
],
119+
));
120+
},
121+
)),
65122
providers: <SingleChildWidget>[
66123
ChangeNotifierProvider<DrawerStateInfo>(
67124
create: (_) => DrawerStateInfo()),
68125
],
69126
);
70127
}
71128
}
129+
130+
final buttonColors = WindowButtonColors(
131+
iconNormal: borderColor,
132+
mouseOver: Color(0xFFF6A00C),
133+
mouseDown: Color(0xFF805306),
134+
iconMouseOver: Color(0xFF805306),
135+
iconMouseDown: Color(0xFFFFD500));
136+
137+
final closeButtonColors = WindowButtonColors(
138+
mouseOver: const Color(0xFFD32F2F),
139+
mouseDown: const Color(0xFFB71C1C),
140+
iconNormal: borderColor,
141+
iconMouseOver: Colors.white);
142+
143+
class WindowButtons extends StatelessWidget {
144+
const WindowButtons({Key? key}) : super(key: key);
145+
146+
@override
147+
Widget build(BuildContext context) {
148+
return Row(
149+
children: [
150+
MinimizeWindowButton(colors: buttonColors),
151+
MaximizeWindowButton(colors: buttonColors),
152+
CloseWindowButton(colors: closeButtonColors),
153+
],
154+
);
155+
}
156+
}

lib/plugins_browser.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@ class PluginsBrowserState extends State<PluginsBrowser> {
141141
obj[key]["identifier"], isInstalled
142142
));
143143
}
144+
setState(() {}); // refresh
144145
}
145-
setState(() {}); // refresh
146146
}
147147

148148
@override

lib/settings.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:corecoder_develop/main.dart';
12
import 'package:corecoder_develop/plugins_browser.dart';
23
import 'package:corecoder_develop/util/modules_manager.dart';
34
import 'package:corecoder_develop/util/theme_manager.dart';
@@ -62,7 +63,7 @@ class SettingsPageState extends State<SettingsPage> {
6263
(dynamic val) => {ThemeManager.setTheme(val)},
6364
SettingsPageItemType.TypeStringList,
6465
<String>["core-coder-dark", "core-coder-light"],
65-
"Atom One Dark")
66+
ThemeManager.currentTheme.value)
6667
];
6768

6869
Widget generateListItem(int index, BuildContext context) {
@@ -251,10 +252,11 @@ class SettingsPageState extends State<SettingsPage> {
251252
}))
252253
]),
253254
/// About page
254-
Column(children:const [
255-
Text("CoreCoder Develop"),
256-
Text("v0.0.1 dev beta"),
257-
])
255+
ListTile(
256+
leading: Image.asset("assets/logo.png"),
257+
title: const Text("CoreCoder Develop"),
258+
subtitle: const Text(CoreCoderApp.version),
259+
)
258260
],
259261
);
260262
},future: PluginsManager.pluginsPath,)));

lib/util/custom_code_box.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ class InnerField extends StatelessWidget {
156156
onUnAutoComplete!.call();
157157
}
158158
},
159+
onChange: (String lastToken) { if(onChange!=null) onChange!(language, lastToken); }
159160
);
160161
codeField = CodeField(
161162
onCursorPosChanged: setCursorOffset,

lib/util/desktop_tabbar.dart

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
import 'package:corecoder_develop/util/theme_manager.dart';
2+
import 'package:flutter/cupertino.dart';
3+
import 'package:flutter/material.dart';
4+
import 'package:tabbed_view/tabbed_view.dart';
5+
6+
class DesktopTabBar extends StatefulWidget {
7+
final double tabSize;
8+
final List<Widget> content;
9+
final List<DesktopTabData> tabs;
10+
11+
const DesktopTabBar(
12+
{Key? key,
13+
this.tabSize = 256.0,
14+
required this.content,
15+
required this.tabs})
16+
: super(key: key);
17+
18+
@override
19+
State createState() => DesktopTabBarState();
20+
}
21+
22+
class DesktopTabBarState extends State<DesktopTabBar> {
23+
Color? colorBackground;
24+
Color? colorBackgroundSecondary;
25+
int selectedTab = 0;
26+
27+
List<Widget> get tabs {
28+
return List.generate(widget.tabs.length, (index) {
29+
var item = widget.tabs[index];
30+
return DesktopTab(
31+
icon: item.icon, title: item.title, onClick: () {
32+
setState(() {
33+
selectedTab = index;
34+
});
35+
}, isActive: selectedTab == index);
36+
});
37+
}
38+
39+
@override
40+
void initState() {
41+
super.initState();
42+
}
43+
44+
@override
45+
Widget build(BuildContext context) {
46+
var query = MediaQuery.of(context);
47+
48+
colorBackground = ThemeManager.getThemeSchemeColor("backgroundTertiary");
49+
colorBackgroundSecondary =
50+
ThemeManager.getThemeSchemeColor("backgroundSecondary");
51+
return Container(
52+
color: colorBackground,
53+
constraints: BoxConstraints(maxHeight: query.size.height - 200),
54+
child: Flex(
55+
direction: Axis.horizontal,
56+
crossAxisAlignment: CrossAxisAlignment.stretch,
57+
children: <Widget>[
58+
Container(
59+
padding: const EdgeInsets.all(16.0),
60+
child: SingleChildScrollView(
61+
child: Column(
62+
children: tabs,
63+
crossAxisAlignment: CrossAxisAlignment.stretch,
64+
),
65+
),
66+
constraints: BoxConstraints(
67+
minWidth: widget.tabSize, maxWidth: widget.tabSize),
68+
),
69+
Expanded(
70+
child: Container(
71+
color: colorBackgroundSecondary,
72+
child: widget.content[selectedTab],
73+
))
74+
],
75+
));
76+
}
77+
}
78+
79+
class DesktopTabData {
80+
final Widget icon, title;
81+
82+
DesktopTabData({required this.icon, required this.title});
83+
}
84+
85+
class DesktopTab extends StatelessWidget {
86+
final Widget icon, title;
87+
final Function() onClick;
88+
final bool isActive;
89+
90+
const DesktopTab(
91+
{Key? key,
92+
required this.icon,
93+
required this.title,
94+
required this.onClick,
95+
required this.isActive})
96+
: super(key: key);
97+
98+
@override
99+
Widget build(BuildContext context) {
100+
return TextButton(
101+
style: ButtonStyle(
102+
backgroundColor:(isActive)? MaterialStateProperty.all(Theme.of(context).canvasColor) : null,
103+
padding: MaterialStateProperty.all(const EdgeInsets.all(16.0)),
104+
foregroundColor: MaterialStateProperty.all(
105+
Theme.of(context).textTheme.bodyText1?.color)),
106+
onPressed: onClick,
107+
child: Row(
108+
children: [
109+
icon,
110+
const SizedBox(
111+
width: 16.0,
112+
),
113+
title
114+
],
115+
),
116+
);
117+
}
118+
}

lib/util/theme_manager.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,16 @@ class ThemeManager {
3939
brightness: brightness,
4040
backgroundColor: backgroundColor,
4141
canvasColor: backgroundSecondary,
42+
primaryColor: primaryColor,
43+
primaryColorDark: Colors.red,
44+
primarySwatch: Colors.red,
4245
colorScheme: ColorScheme.fromSwatch(brightness: brightness).copyWith(
4346
primary: primaryColor,
4447
brightness: brightness,
48+
background: backgroundColor,
49+
4550
),
51+
4652
scaffoldBackgroundColor: backgroundSecondary,
4753
appBarTheme: AppBarTheme(
4854
backgroundColor: backgroundColor,

lib/util/themes.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ const editorThemes = {
233233
// Controls
234234
"background": Color(0xFF191919),
235235
"backgroundSecondary": Color(0xFF202020),
236+
"backgroundTertiary": Color(0xFF2B2B2B),
236237
"foreground": Color(0xFFFFFFFF),
237238

238239
// Color symbols
@@ -253,6 +254,7 @@ const editorThemes = {
253254
// Controls
254255
"background": Color(0xFFE5E5E5),
255256
"backgroundSecondary": Color(0xFFFFFFFF),
257+
"backgroundTertiary": Color(0xFFDCDCDC),
256258
"foreground": Color(0xFF000000),
257259

258260
// Color symbols

0 commit comments

Comments
 (0)