Skip to content

Commit 9c8c262

Browse files
committed
refactor: folder structure
1 parent 0d26417 commit 9c8c262

27 files changed

+115
-82
lines changed

lib/src/app.dart

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,38 @@
1+
import 'package:auth/src/app_router.dart';
12
import 'package:auth/src/features/home/home_screen.dart';
2-
import 'package:auth/src/features/auth/screens/login_screen.dart';
3-
import 'package:auth/src/features/auth/screens/recover_screen.dart';
4-
import 'package:auth/src/features/auth/screens/register_screen.dart';
53
import 'package:flutter/material.dart';
64

7-
class MyApp extends StatelessWidget {
5+
class MyApp extends StatefulWidget {
86
static GlobalKey<NavigatorState> materialKey = GlobalKey();
97

8+
MyApp({Key? key}) : super(key: key);
9+
10+
@override
11+
_MyAppState createState() => _MyAppState();
12+
}
13+
14+
class _MyAppState extends State<MyApp> {
15+
final _appRouter = AppRouter();
16+
1017
@override
1118
Widget build(BuildContext context) {
1219
return MaterialApp(
1320
navigatorKey: MyApp.materialKey,
1421
debugShowCheckedModeBanner: false,
1522
initialRoute: HomeScreen.routeName,
16-
routes: {
17-
HomeScreen.routeName: (context) => HomeScreen(),
18-
LoginScreen.routeName: (context) => LoginScreen(),
19-
RegisterScreen.routeName: (context) => RegisterScreen(),
20-
RecoverScreen.routeName: (context) => RecoverScreen(),
21-
},
22-
onGenerateRoute: (settings) => MaterialPageRoute(
23-
settings: settings,
24-
builder: (context) => HomeScreen(),
25-
),
23+
onGenerateRoute: _appRouter.onGenerateRoute,
2624
theme: ThemeData(
2725
primaryColor: Color(0xff4C525C),
2826
accentColor: Color(0xffFFAE48),
2927
highlightColor: Color(0xff58BFE6),
3028
),
3129
);
3230
}
31+
32+
@override
33+
void dispose() {
34+
super.dispose();
35+
36+
_appRouter.dispose();
37+
}
3338
}

lib/src/app_router.dart

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import 'dart:math';
2+
3+
import 'package:auth/src/features/auth/views/screens/login_screen.dart';
4+
import 'package:auth/src/features/auth/views/screens/register_screen.dart';
5+
import 'package:auth/src/features/home/home_screen.dart';
6+
import 'package:flutter/material.dart';
7+
8+
class AppRouter {
9+
Route onGenerateRoute(RouteSettings settings) {
10+
switch (settings.name) {
11+
case HomeScreen.routeName:
12+
return MaterialPageRoute(builder: (_) => HomeScreen());
13+
case LoginScreen.routeName:
14+
return MaterialPageRoute(builder: (_) => LoginScreen());
15+
case RegisterScreen.routeName:
16+
return MaterialPageRoute(builder: (_) => RegisterScreen());
17+
default:
18+
return MaterialPageRoute(builder: (_) => HomeScreen());
19+
}
20+
}
21+
22+
void dispose() {}
23+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import 'package:bloc/bloc.dart';
2+
import 'package:meta/meta.dart';
3+
4+
part 'auth_state.dart';
5+
6+
class AuthCubit extends Cubit<AuthState> {
7+
AuthCubit() : super(AuthInitial());
8+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
part of 'auth_cubit.dart';
2+
3+
@immutable
4+
abstract class AuthState {}
5+
6+
class AuthInitial extends AuthState {}
File renamed without changes.
File renamed without changes.

lib/src/features/auth/providers/auth_provider.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import 'dart:io';
22

3-
import 'package:auth/src/features/auth/models/tokens.dart';
4-
import 'package:auth/src/features/auth/models/user.dart';
5-
import 'package:auth/src/features/auth/screens/login_screen.dart';
6-
import 'package:auth/src/shared/http/api.dart';
7-
import 'package:auth/src/shared/http/interceptors/dialog_interceptor.dart';
8-
import 'package:auth/src/shared/widgets/alert_widget.dart';
3+
import 'package:auth/src/features/auth/logic/models/tokens.dart';
4+
import 'package:auth/src/features/auth/logic/models/user.dart';
5+
import 'package:auth/src/features/auth/views/screens/login_screen.dart';
96
import 'package:auth/src/constants/environments.dart';
7+
import 'package:auth/src/shared/logic/http/api.dart';
8+
import 'package:auth/src/shared/logic/http/interceptors/dialog_interceptor.dart';
9+
import 'package:auth/src/shared/views/widgets/alert_widget.dart';
1010
import 'package:flutter/material.dart';
1111
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';
1212
import 'package:flutter_secure_storage/flutter_secure_storage.dart' as store;

lib/src/features/auth/screens/login_screen.dart renamed to lib/src/features/auth/views/screens/login_screen.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import 'package:auth/src/features/auth/providers/auth_provider.dart';
2+
import 'package:auth/src/features/auth/views/screens/recover_screen.dart';
3+
import 'package:auth/src/features/auth/views/screens/register_screen.dart';
24
import 'package:auth/src/features/home/home_screen.dart';
3-
import 'package:auth/src/features/auth/screens/recover_screen.dart';
4-
import 'package:auth/src/features/auth/screens/register_screen.dart';
5-
import 'package:auth/src/shared/widgets/circles_background.dart';
6-
import 'package:auth/src/shared/widgets/go_back.dart';
7-
import 'package:auth/src/shared/widgets/main_text_field.dart';
8-
import 'package:auth/src/shared/widgets/next_button.dart';
9-
import 'package:auth/src/shared/widgets/scrollable_form.dart';
10-
import 'package:auth/src/shared/widgets/underlined_button.dart';
5+
import 'package:auth/src/shared/views/widgets/circles_background.dart';
6+
import 'package:auth/src/shared/views/widgets/go_back.dart';
7+
import 'package:auth/src/shared/views/widgets/main_text_field.dart';
8+
import 'package:auth/src/shared/views/widgets/next_button.dart';
9+
import 'package:auth/src/shared/views/widgets/scrollable_form.dart';
10+
import 'package:auth/src/shared/views/widgets/underlined_button.dart';
1111
import 'package:flutter/material.dart';
1212
import 'package:flutter_signin_button/button_list.dart';
1313
import 'package:flutter_signin_button/button_view.dart';

lib/src/features/auth/screens/recover_screen.dart renamed to lib/src/features/auth/views/screens/recover_screen.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import 'package:auth/src/features/auth/providers/auth_provider.dart';
2-
import 'package:auth/src/features/auth/screens/login_screen.dart';
3-
import 'package:auth/src/features/auth/screens/register_screen.dart';
4-
import 'package:auth/src/shared/widgets/alert_widget.dart';
5-
import 'package:auth/src/shared/widgets/circles_background.dart';
6-
import 'package:auth/src/shared/widgets/go_back.dart';
7-
import 'package:auth/src/shared/widgets/main_text_field.dart';
8-
import 'package:auth/src/shared/widgets/next_button.dart';
9-
import 'package:auth/src/shared/widgets/scrollable_form.dart';
10-
import 'package:auth/src/shared/widgets/underlined_button.dart';
2+
import 'package:auth/src/features/auth/views/screens/login_screen.dart';
3+
import 'package:auth/src/features/auth/views/screens/register_screen.dart';
4+
import 'package:auth/src/shared/views/widgets/alert_widget.dart';
5+
import 'package:auth/src/shared/views/widgets/circles_background.dart';
6+
import 'package:auth/src/shared/views/widgets/go_back.dart';
7+
import 'package:auth/src/shared/views/widgets/main_text_field.dart';
8+
import 'package:auth/src/shared/views/widgets/next_button.dart';
9+
import 'package:auth/src/shared/views/widgets/scrollable_form.dart';
10+
import 'package:auth/src/shared/views/widgets/underlined_button.dart';
1111
import 'package:flutter/material.dart';
1212
import 'package:provider/provider.dart';
1313

lib/src/features/auth/screens/register_screen.dart renamed to lib/src/features/auth/views/screens/register_screen.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import 'package:auth/src/features/auth/providers/auth_provider.dart';
2+
import 'package:auth/src/features/auth/views/screens/login_screen.dart';
23
import 'package:auth/src/features/home/home_screen.dart';
3-
import 'package:auth/src/features/auth/screens/login_screen.dart';
4-
import 'package:auth/src/shared/widgets/circles_background.dart';
5-
import 'package:auth/src/shared/widgets/go_back.dart';
6-
import 'package:auth/src/shared/widgets/main_text_field.dart';
7-
import 'package:auth/src/shared/widgets/next_button.dart';
8-
import 'package:auth/src/shared/widgets/scrollable_form.dart';
9-
import 'package:auth/src/shared/widgets/underlined_button.dart';
4+
import 'package:auth/src/shared/views/widgets/circles_background.dart';
5+
import 'package:auth/src/shared/views/widgets/go_back.dart';
6+
import 'package:auth/src/shared/views/widgets/main_text_field.dart';
7+
import 'package:auth/src/shared/views/widgets/next_button.dart';
8+
import 'package:auth/src/shared/views/widgets/scrollable_form.dart';
9+
import 'package:auth/src/shared/views/widgets/underlined_button.dart';
1010
import 'package:flutter/material.dart';
1111
import 'package:flutter_signin_button/flutter_signin_button.dart';
1212
import 'package:provider/provider.dart';

0 commit comments

Comments
 (0)