initial router setup
parent
c02ea580c7
commit
30c69dd5a8
|
|
@ -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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
final GlobalKey<ScaffoldMessengerState> snackbarKey = GlobalKey<ScaffoldMessengerState>();
|
||||||
|
|
||||||
|
String baseURL = '';
|
||||||
|
String apiVersion = '';
|
||||||
|
|
||||||
|
class Endpoints {
|
||||||
|
static final String version = '$baseURL/version';
|
||||||
|
static final String login = '$baseURL/login';
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lixo/pages/initial_page.dart';
|
import 'package:lixo/routes.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
|
|
@ -10,13 +10,13 @@ class MyApp extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp.router(
|
||||||
title: 'PCastLiveTV',
|
title: 'PCastLiveTV',
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
home: const InitialPage(),
|
routerConfig: router,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
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';
|
import 'package:lixo/components/nc_button.dart';
|
||||||
|
|
||||||
class InitialPage extends StatelessWidget {
|
class InitialPage extends StatelessWidget {
|
||||||
|
|
@ -6,8 +8,7 @@ class InitialPage extends StatelessWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return NcBasePage(
|
||||||
backgroundColor: const Color(0xffa600f9),
|
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
|
@ -16,7 +17,7 @@ class InitialPage extends StatelessWidget {
|
||||||
caption: "Quero me registrar",
|
caption: "Quero me registrar",
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
captionColor: Colors.white,
|
captionColor: Colors.white,
|
||||||
onPressed: _register,
|
onPressed: () => context.go('/register'),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|
@ -25,19 +26,11 @@ class InitialPage extends StatelessWidget {
|
||||||
caption: "Já sou cliente",
|
caption: "Já sou cliente",
|
||||||
backgroundColor: Colors.black,
|
backgroundColor: Colors.black,
|
||||||
captionColor: Colors.white,
|
captionColor: Colors.white,
|
||||||
onPressed: _login,
|
onPressed: () => context.go('/login'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _register() {
|
|
||||||
print("Quero me registrar");
|
|
||||||
}
|
|
||||||
|
|
||||||
void _login() {
|
|
||||||
print("Quero fazer login");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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"),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
18
pubspec.lock
18
pubspec.lock
|
|
@ -88,6 +88,14 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
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:
|
intl:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -104,6 +112,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.1"
|
||||||
|
logging:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: logging
|
||||||
|
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.2.0"
|
||||||
matcher:
|
matcher:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
@ -223,4 +239,4 @@ packages:
|
||||||
version: "0.1.4-beta"
|
version: "0.1.4-beta"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=3.1.0 <4.0.0"
|
dart: ">=3.1.0 <4.0.0"
|
||||||
flutter: ">=2.0.0"
|
flutter: ">=3.7.0"
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ dependencies:
|
||||||
# Use with the CupertinoIcons class for iOS style icons.
|
# Use with the CupertinoIcons class for iOS style icons.
|
||||||
cupertino_icons: ^1.0.2
|
cupertino_icons: ^1.0.2
|
||||||
velocity_x: ^4.1.1
|
velocity_x: ^4.1.1
|
||||||
|
go_router: ^10.1.0
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue