From 1f8865293dbe97475fbe7edb9cd3a6d9744e4bc5 Mon Sep 17 00:00:00 2001 From: Kavisi <68240897+kekavc24@users.noreply.github.com> Date: Sat, 19 Nov 2022 15:55:52 +0300 Subject: [PATCH 1/7] style: moved default example to separate folder --- .../example/lib/{ => example_with_no_routes}/main.dart | 2 +- .../example/lib/{ => example_with_no_routes}/switch.dart | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename bitsdojo_window/example/lib/{ => example_with_no_routes}/main.dart (98%) rename bitsdojo_window/example/lib/{ => example_with_no_routes}/switch.dart (100%) diff --git a/bitsdojo_window/example/lib/main.dart b/bitsdojo_window/example/lib/example_with_no_routes/main.dart similarity index 98% rename from bitsdojo_window/example/lib/main.dart rename to bitsdojo_window/example/lib/example_with_no_routes/main.dart index 68d9c6d..c59b86d 100644 --- a/bitsdojo_window/example/lib/main.dart +++ b/bitsdojo_window/example/lib/example_with_no_routes/main.dart @@ -12,7 +12,7 @@ void main() { win.minSize = initialSize; win.size = initialSize; win.alignment = Alignment.center; - win.title = "Custom window with Flutter"; + win.title = "Custom Window With No Navigation Flutter"; win.show(); }); } diff --git a/bitsdojo_window/example/lib/switch.dart b/bitsdojo_window/example/lib/example_with_no_routes/switch.dart similarity index 100% rename from bitsdojo_window/example/lib/switch.dart rename to bitsdojo_window/example/lib/example_with_no_routes/switch.dart From 088c2cf15a87a48305518b29865babc377f2c6d3 Mon Sep 17 00:00:00 2001 From: Kavisi <68240897+kekavc24@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:06:55 +0300 Subject: [PATCH 2/7] chore: added animations --- bitsdojo_window/example/pubspec.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/bitsdojo_window/example/pubspec.yaml b/bitsdojo_window/example/pubspec.yaml index fcc3df2..3dc5588 100644 --- a/bitsdojo_window/example/pubspec.yaml +++ b/bitsdojo_window/example/pubspec.yaml @@ -23,6 +23,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.1 + animations: ^2.0.7 dev_dependencies: flutter_test: From 1bea7f8e76eaf44f5a19b79b3758a469f3ce5fba Mon Sep 17 00:00:00 2001 From: Kavisi <68240897+kekavc24@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:25:23 +0300 Subject: [PATCH 3/7] feat: added title bar with custom color --- .../title_bar.dart | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/title_bar.dart diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/title_bar.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/title_bar.dart new file mode 100644 index 0000000..1475047 --- /dev/null +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/title_bar.dart @@ -0,0 +1,84 @@ +import 'package:bitsdojo_window/bitsdojo_window.dart'; +import 'package:flutter/material.dart'; + +class ExamplWithOnGenerateRouteTitleBar extends StatelessWidget { + const ExamplWithOnGenerateRouteTitleBar({ + Key? key, + required this.child, + }) : super(key: key); + + final Widget child; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Column( + children: [ + // + WindowTitleBarBox( + child: MoveWindow( + child: Container( + color: Colors.deepOrange, // Enter any color you prefer + child: Row( + children: const [ + // + Padding( + padding: EdgeInsets.only(left: 10), + child: Text( + "App With Simple OnGenerateRoute Navigation", + style: TextStyle( + fontSize: 12, + color: Colors.white, + ), + ), + ), + + Spacer(), + + ActionButtons() + // + ], + ), + ), + ), + ), + + Flexible(child: child) + // + ], + ), + ); + } +} + +class ActionButtons extends StatelessWidget { + const ActionButtons({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Row( + children: [ + // + MinimizeWindowButton( + animate: false, + colors: WindowButtonColors( + iconNormal: Colors.white, + ), + ), + MaximizeWindowButton( + animate: false, + colors: WindowButtonColors( + iconNormal: Colors.white, + ), + ), + CloseWindowButton( + animate: false, + colors: WindowButtonColors( + iconNormal: Colors.white, + ), + ), + // + ], + ); + } +} From a7b6c0a0b208a8a6ae8bf5d2aeab6e96a82cc5a5 Mon Sep 17 00:00:00 2001 From: Kavisi <68240897+kekavc24@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:26:33 +0300 Subject: [PATCH 4/7] feat: added simple router using onGenerateRoute create three simple screens --- .../routes.dart | 52 +++++++++++++++++++ .../screen_one.dart | 38 ++++++++++++++ .../screen_three.dart | 38 ++++++++++++++ .../screen_two.dart | 38 ++++++++++++++ 4 files changed, 166 insertions(+) create mode 100644 bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart create mode 100644 bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_one.dart create mode 100644 bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_three.dart create mode 100644 bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_two.dart diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart new file mode 100644 index 0000000..78d65e1 --- /dev/null +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart @@ -0,0 +1,52 @@ +import 'package:animations/animations.dart'; +import 'package:flutter/material.dart'; + +import 'screen_one.dart'; +import 'screen_three.dart'; +import 'screen_two.dart'; + +class Routes { + // + static const String screenOne = 'splash'; + static const String screenTwo = 'loader'; + static const String screenThree = 'login'; + // + static Route fadeThrough(RouteSettings settings, WidgetBuilder page, + {int duration = 500}) { + return PageRouteBuilder( + settings: settings, + transitionDuration: Duration(milliseconds: duration), + pageBuilder: (context, animation, secondaryAnimation) => page(context), + transitionsBuilder: (context, animation, secondaryAnimation, child) { + return FadeScaleTransition(animation: animation, child: child); + }, + ); + } + // +} + +class AppRouter { + // + Route onGenerateRoute(RouteSettings settings) { + // + return Routes.fadeThrough(settings, (context) { + // + switch (settings.name) { + case Routes.screenOne: + return const ScreenOne(); + + case Routes.screenTwo: + return const ScreenTwo(); + + case Routes.screenThree: + return const ScreenThree(); + + default: + return const SizedBox.shrink(); + } + // + }); + // + } + // +} diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_one.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_one.dart new file mode 100644 index 0000000..9846e46 --- /dev/null +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_one.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; + +import 'routes.dart'; + +class ScreenOne extends StatefulWidget { + const ScreenOne({Key? key}) : super(key: key); + + @override + State createState() => _ScreenOneState(); +} + +class _ScreenOneState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // + Text( + "This is screen one", + style: Theme.of(context).textTheme.headlineMedium, + ), + + const SizedBox(height: 20), + + ElevatedButton( + onPressed: () => Navigator.pushNamed(context, Routes.screenTwo), + child: const Text("Go To Screen Two"), + ) + // + ], + ), + ), + ); + } +} diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_three.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_three.dart new file mode 100644 index 0000000..a1a2bba --- /dev/null +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_three.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; + +import 'routes.dart'; + +class ScreenThree extends StatefulWidget { + const ScreenThree({Key? key}) : super(key: key); + + @override + State createState() => _ScreenThreeState(); +} + +class _ScreenThreeState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // + Text( + "This is screen three", + style: Theme.of(context).textTheme.headlineMedium, + ), + + const SizedBox(height: 20), + + ElevatedButton( + onPressed: () => Navigator.pushNamed(context, Routes.screenOne), + child: const Text("Go Back To Screen One"), + ) + // + ], + ), + ), + ); + } +} diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_two.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_two.dart new file mode 100644 index 0000000..b55af8c --- /dev/null +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/screen_two.dart @@ -0,0 +1,38 @@ +import 'package:flutter/material.dart'; + +import 'routes.dart'; + +class ScreenTwo extends StatefulWidget { + const ScreenTwo({Key? key}) : super(key: key); + + @override + State createState() => _ScreenTwoState(); +} + +class _ScreenTwoState extends State { + @override + Widget build(BuildContext context) { + return Scaffold( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + // + Text( + "This is screen two", + style: Theme.of(context).textTheme.headlineMedium, + ), + + const SizedBox(height: 20), + + ElevatedButton( + onPressed: () => Navigator.pushNamed(context, Routes.screenThree), + child: const Text("Go To Screen Three"), + ) + // + ], + ), + ), + ); + } +} From f7b458c5d777f83a99630f7b588d48e728c2b7c1 Mon Sep 17 00:00:00 2001 From: Kavisi <68240897+kekavc24@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:27:49 +0300 Subject: [PATCH 5/7] feat: created main.dart added app router class with initial route a7b6c0a added title bar to appear before navigator --- .../main.dart | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart new file mode 100644 index 0000000..1eb6f67 --- /dev/null +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart @@ -0,0 +1,47 @@ +import 'package:bitsdojo_window/bitsdojo_window.dart'; +import 'package:flutter/material.dart'; + +import 'routes.dart'; +import 'title_bar.dart'; + +void main() { + runApp(const MyApp()); + doWhenWindowReady(() { + final win = appWindow; + const initialSize = Size(600, 450); + win.minSize = initialSize; + win.size = initialSize; + win.alignment = Alignment.center; + win.title = "Custom Window With No Navigation Flutter"; + win.show(); + }); +} + +class MyApp extends StatefulWidget { + const MyApp({Key? key}) : super(key: key); + + @override + State createState() => _MyAppState(); +} + +class _MyAppState extends State { + // + // Router + final AppRouter router = AppRouter(); + + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + builder: (context, child) { + // + return ExamplWithOnGenerateRouteTitleBar( + child: Navigator( + initialRoute: Routes.screenOne, + onGenerateRoute: router.onGenerateRoute, + ), + ); + }, + ); + } +} From c8e411e239b76e9f99a792417e50acd39b1101d1 Mon Sep 17 00:00:00 2001 From: Kavisi <68240897+kekavc24@users.noreply.github.com> Date: Sat, 19 Nov 2022 16:29:19 +0300 Subject: [PATCH 6/7] refractor: changed window title to reflect example --- .../example/lib/example_with_simple_onGenerateRoute/main.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart index 1eb6f67..a759c72 100644 --- a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/main.dart @@ -12,7 +12,7 @@ void main() { win.minSize = initialSize; win.size = initialSize; win.alignment = Alignment.center; - win.title = "Custom Window With No Navigation Flutter"; + win.title = "Simple Window With OnGenerate Route"; win.show(); }); } From c1d23549848fb99ec5b3c28208de817329df8795 Mon Sep 17 00:00:00 2001 From: Kavisi <68240897+kekavc24@users.noreply.github.com> Date: Sat, 19 Nov 2022 17:47:47 +0300 Subject: [PATCH 7/7] refractor: fixed wrong names in routes --- .../lib/example_with_simple_onGenerateRoute/routes.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart index 78d65e1..f94436f 100644 --- a/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart +++ b/bitsdojo_window/example/lib/example_with_simple_onGenerateRoute/routes.dart @@ -7,9 +7,9 @@ import 'screen_two.dart'; class Routes { // - static const String screenOne = 'splash'; - static const String screenTwo = 'loader'; - static const String screenThree = 'login'; + static const String screenOne = 'screen-one'; + static const String screenTwo = 'screen-two'; + static const String screenThree = 'screen-three'; // static Route fadeThrough(RouteSettings settings, WidgetBuilder page, {int duration = 500}) {