diff --git a/lib/components/nc_base_page.dart b/lib/components/nc_base_page.dart new file mode 100644 index 0000000..96066e1 --- /dev/null +++ b/lib/components/nc_base_page.dart @@ -0,0 +1,15 @@ +import 'package:flutter/material.dart'; + +class NcBasePage extends StatelessWidget { + const NcBasePage({super.key, required this.body}); + + final Widget body; + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: const Color(0xffa600f9), + body: body, + ); + } +} diff --git a/lib/globals.dart b/lib/globals.dart new file mode 100644 index 0000000..9f08976 --- /dev/null +++ b/lib/globals.dart @@ -0,0 +1,11 @@ +import 'package:flutter/material.dart'; + +final GlobalKey snackbarKey = GlobalKey(); + +String baseURL = ''; +String apiVersion = ''; + +class Endpoints { + static final String version = '$baseURL/version'; + static final String login = '$baseURL/login'; +} diff --git a/lib/main.dart b/lib/main.dart index 8774285..3a0bfbb 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:lixo/pages/initial_page.dart'; +import 'package:lixo/routes.dart'; void main() { runApp(const MyApp()); @@ -10,13 +10,13 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( + return MaterialApp.router( title: 'PCastLiveTV', theme: ThemeData( useMaterial3: true, ), debugShowCheckedModeBanner: false, - home: const InitialPage(), + routerConfig: router, ); } } diff --git a/lib/pages/initial_page.dart b/lib/pages/initial_page.dart index 69a5e11..7d20c6c 100644 --- a/lib/pages/initial_page.dart +++ b/lib/pages/initial_page.dart @@ -1,4 +1,6 @@ import 'package:flutter/material.dart'; +import 'package:go_router/go_router.dart'; +import 'package:lixo/components/nc_base_page.dart'; import 'package:lixo/components/nc_button.dart'; class InitialPage extends StatelessWidget { @@ -6,8 +8,7 @@ class InitialPage extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: const Color(0xffa600f9), + return NcBasePage( body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, @@ -16,7 +17,7 @@ class InitialPage extends StatelessWidget { caption: "Quero me registrar", backgroundColor: Colors.black, captionColor: Colors.white, - onPressed: _register, + onPressed: () => context.go('/register'), ), const SizedBox( height: 40, @@ -25,19 +26,11 @@ class InitialPage extends StatelessWidget { caption: "Já sou cliente", backgroundColor: Colors.black, captionColor: Colors.white, - onPressed: _login, + onPressed: () => context.go('/login'), ), ], ), ), ); } - - void _register() { - print("Quero me registrar"); - } - - void _login() { - print("Quero fazer login"); - } } diff --git a/lib/pages/login_page.dart b/lib/pages/login_page.dart new file mode 100644 index 0000000..f2d4f62 --- /dev/null +++ b/lib/pages/login_page.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:lixo/components/nc_base_page.dart'; + +class LoginPage extends StatelessWidget { + const LoginPage({super.key}); + + @override + Widget build(BuildContext context) { + return const NcBasePage( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Login Page"), + ], + ), + ), + ); + } +} diff --git a/lib/pages/register_page.dart b/lib/pages/register_page.dart new file mode 100644 index 0000000..c7df27f --- /dev/null +++ b/lib/pages/register_page.dart @@ -0,0 +1,20 @@ +import 'package:flutter/material.dart'; +import 'package:lixo/components/nc_base_page.dart'; + +class RegisterPage extends StatelessWidget { + const RegisterPage({super.key}); + + @override + Widget build(BuildContext context) { + return const NcBasePage( + body: Center( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Register Page"), + ], + ), + ), + ); + } +} diff --git a/lib/routes.dart b/lib/routes.dart new file mode 100644 index 0000000..35f0648 --- /dev/null +++ b/lib/routes.dart @@ -0,0 +1,26 @@ +import 'package:go_router/go_router.dart'; +import 'package:lixo/pages/initial_page.dart'; +import 'package:lixo/pages/login_page.dart'; +import 'package:lixo/pages/register_page.dart'; + +// GoRouter configuration +final router = GoRouter( + initialLocation: '/', + routes: [ + GoRoute( + name: 'home', // Optional, add name to your routes. Allows you navigate by name instead of path + path: '/', + builder: (context, state) => const InitialPage(), + ), + GoRoute( + name: 'login', + path: '/login', + builder: (context, state) => const LoginPage(), + ), + GoRoute( + name: 'register', + path: '/register', + builder: (context, state) => const RegisterPage(), + ), + ], +); diff --git a/pubspec.lock b/pubspec.lock index d0cea06..e1af582 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -88,6 +88,14 @@ packages: description: flutter source: sdk version: "0.0.0" + go_router: + dependency: "direct main" + description: + name: go_router + sha256: "2aa884667eeda3a1c461f31e72af1f77984ab0f29450d8fb12ec1f7bc53eea14" + url: "https://pub.dev" + source: hosted + version: "10.1.0" intl: dependency: transitive description: @@ -104,6 +112,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" matcher: dependency: transitive description: @@ -223,4 +239,4 @@ packages: version: "0.1.4-beta" sdks: dart: ">=3.1.0 <4.0.0" - flutter: ">=2.0.0" + flutter: ">=3.7.0" diff --git a/pubspec.yaml b/pubspec.yaml index b8222c0..4157aad 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 velocity_x: ^4.1.1 + go_router: ^10.1.0 dev_dependencies: flutter_test: