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 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..a759c72 --- /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 = "Simple Window With OnGenerate Route"; + 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, + ), + ); + }, + ); + } +} 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..f94436f --- /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 = 'screen-one'; + static const String screenTwo = 'screen-two'; + static const String screenThree = 'screen-three'; + // + 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"), + ) + // + ], + ), + ), + ); + } +} 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, + ), + ), + // + ], + ); + } +} 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: