@@ -10,23 +10,41 @@ import 'package:provider/provider.dart';
1010import 'package:provider/single_child_widget.dart' ;
1111import 'homepage.dart' ;
1212import '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 (CoreCoderApp .isDesktop) {
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
1930class 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,91 @@ 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+ if (CoreCoderApp .isDesktop)
92+ WindowTitleBarBox (
93+ child: Row (children: [
94+ Expanded (
95+ child: MoveWindow (
96+ child: Row (children: [
97+ const SizedBox (
98+ width: 16.0 ,
99+ ),
100+ Image .asset (
101+ "assets/logo.png" ,
102+ isAntiAlias: true ,
103+ filterQuality: FilterQuality .high,
104+ width: 20 ,
105+ height: 20 ,
106+ ),
107+ const SizedBox (
108+ width: 16.0 ,
109+ ),
110+ Text (
111+ "CoreCoder:Develop ${CoreCoderApp .version }" ,
112+ style: Theme .of (context).textTheme.bodyText1! ,
113+ )
114+ ]),
115+ )),
116+ const WindowButtons ()
117+ ])),
118+ if (widget != null ) Expanded (child: widget)
119+ ],
120+ ));
121+ },
122+ )),
65123 providers: < SingleChildWidget > [
66124 ChangeNotifierProvider <DrawerStateInfo >(
67125 create: (_) => DrawerStateInfo ()),
68126 ],
69127 );
70128 }
71129}
130+
131+ class WindowButtons extends StatelessWidget {
132+ const WindowButtons ({Key ? key}) : super (key: key);
133+
134+ @override
135+ Widget build (BuildContext context) {
136+ var theme = Theme .of (context);
137+ var buttonColors = WindowButtonColors (
138+ mouseOver: theme.canvasColor,
139+ mouseDown: theme.backgroundColor,
140+ iconNormal: theme.textTheme.bodyText1? .color,
141+ iconMouseOver: theme.textTheme.bodyText1? .color,
142+ iconMouseDown: theme.textTheme.bodyText1? .color);
143+
144+ var closeButtonColors = WindowButtonColors (
145+ mouseOver: const Color (0xFFD32F2F ),
146+ mouseDown: const Color (0xFFB71C1C ),
147+ iconNormal: theme.textTheme.bodyText1? .color,
148+ iconMouseOver: theme.textTheme.bodyText1? .color);
149+
150+ return Row (
151+ children: [
152+ MinimizeWindowButton (colors: buttonColors),
153+ MaximizeWindowButton (colors: buttonColors),
154+ CloseWindowButton (colors: closeButtonColors),
155+ ],
156+ );
157+ }
158+ }
0 commit comments