Complete refactoring SFM App Source Code
This commit is contained in:
24
lib/product/constant/app/api_path_constant.dart
Normal file
24
lib/product/constant/app/api_path_constant.dart
Normal file
@@ -0,0 +1,24 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
class APIPathConstants {
|
||||
static const LOGIN_PATH = "/api/login";
|
||||
static const LOGOUT_PATH = "/api/logout";
|
||||
static const BELL_NOTIFICATIONS_PATH = "/api/notifications/bell-list";
|
||||
static const BELL_UPDATE_READ_NOTIFICATIONS_PATH =
|
||||
"/api/notifications/bell-read";
|
||||
static const DEVICE_NOTIFICATION_SETTINGS = "/api/users/my-device-settings";
|
||||
static const DASHBOARD_DEVICES = "/api/dashboard/devices";
|
||||
static const USER_PATH = "/api/users";
|
||||
static const USER_PROFILE_PATH = "/api/users/profile";
|
||||
static const PROVINCES_PATH = "/api/vn/provinces";
|
||||
static const DISTRICTS_PATH = "/api/vn/districts";
|
||||
static const WARDS_PATH = "/api/vn/wards";
|
||||
static const DEVICE_PATH = "/api/devices";
|
||||
static const DEVICE_REGISTER_PATH = "/api/devices/register";
|
||||
static const DEVICE_UNREGISTER_PATH = "/api/devices/unregister";
|
||||
static const ALL_GROUPS_PATH = "/api/groups/user";
|
||||
static const GROUPS_PATH = "/api/groups";
|
||||
static const JOIN_GROUP_PATH = "/api/groups/join";
|
||||
static const APPROVE_GROUP_PATH = "/api/groups/approve";
|
||||
static const DEVICE_LOGS_PATH = "/api/device-logs";
|
||||
}
|
||||
21
lib/product/constant/app/app_constants.dart
Normal file
21
lib/product/constant/app/app_constants.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
class ApplicationConstants {
|
||||
static const APP_NAME = "Smatec SFM";
|
||||
static const DOMAIN = "sfm.smatec.com.vn";
|
||||
static const MAP_KEY = "AIzaSyDI8b-PUgKUgj5rHdtgEHCwWjUXYJrqYhE";
|
||||
static const LOGIN_PATH = "/login";
|
||||
static const LOGOUT_PATH = "/logout";
|
||||
static const HOME_PATH = "/";
|
||||
static const SETTINGS_PATH = "/settings";
|
||||
static const BELL_PATH = "/bell";
|
||||
static const DEVICES_MANAGER_PATH = "/devices-manager";
|
||||
static const DEVICES_UPDATE_PATH = "/device-update";
|
||||
static const DEVICES_DETAIL_PATH = "/device";
|
||||
static const MAP_PATH = "/map";
|
||||
static const DEVICE_LOGS_PATH = "/device-logs";
|
||||
static const GROUP_PATH = "/groups";
|
||||
static const DEVICE_NOTIFICATIONS_SETTINGS = "/device-notifications-settings";
|
||||
static const OWNER_GROUP = "owner";
|
||||
static const PARTICIPANT_GROUP = "participant";
|
||||
}
|
||||
16
lib/product/constant/enums/app_route_enums.dart
Normal file
16
lib/product/constant/enums/app_route_enums.dart
Normal file
@@ -0,0 +1,16 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
enum AppRoutes {
|
||||
LOGIN,
|
||||
HOME,
|
||||
SETTINGS,
|
||||
DEVICE_NOTIFICATION_SETTINGS,
|
||||
BELL,
|
||||
DEVICES,
|
||||
DEVICE_UPDATE,
|
||||
DEVICE_DETAIL,
|
||||
MAP,
|
||||
HISTORY,
|
||||
GROUPS,
|
||||
GROUP_DETAIL,
|
||||
}
|
||||
3
lib/product/constant/enums/app_theme_enums.dart
Normal file
3
lib/product/constant/enums/app_theme_enums.dart
Normal file
@@ -0,0 +1,3 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
enum AppThemes { LIGHT, DARK, SYSTEM }
|
||||
10
lib/product/constant/enums/local_keys_enums.dart
Normal file
10
lib/product/constant/enums/local_keys_enums.dart
Normal file
@@ -0,0 +1,10 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
enum PreferencesKeys{
|
||||
TOKEN,
|
||||
UID,
|
||||
EXP,
|
||||
ROLE,
|
||||
LANGUAGE_CODE,
|
||||
THEME
|
||||
}
|
||||
7
lib/product/constant/enums/role_enums.dart
Normal file
7
lib/product/constant/enums/role_enums.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
enum RoleEnums{
|
||||
USER,
|
||||
ADMIN,
|
||||
MOD
|
||||
}
|
||||
13
lib/product/constant/icon/icon_constants.dart
Normal file
13
lib/product/constant/icon/icon_constants.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class IconConstants {
|
||||
IconConstants._init();
|
||||
static IconConstants? _instance;
|
||||
static IconConstants get instance => _instance ??= IconConstants._init();
|
||||
|
||||
String get logo => getIcon("");
|
||||
|
||||
String getIcon(String name) => "assets/icons/$name.png";
|
||||
|
||||
Icon getMaterialIcon(IconData icon) => Icon(icon);
|
||||
}
|
||||
9
lib/product/constant/image/image_constants.dart
Normal file
9
lib/product/constant/image/image_constants.dart
Normal file
@@ -0,0 +1,9 @@
|
||||
class ImageConstants {
|
||||
ImageConstants._init();
|
||||
static ImageConstants? _instance;
|
||||
static ImageConstants get instance => _instance ??= ImageConstants._init();
|
||||
|
||||
String get logo => getImage("");
|
||||
|
||||
String getImage(String name) => "assets/images/$name.png";
|
||||
}
|
||||
6
lib/product/constant/lang/language_constants.dart
Normal file
6
lib/product/constant/lang/language_constants.dart
Normal file
@@ -0,0 +1,6 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
class LanguageConstants {
|
||||
static const ENGLISH = "en";
|
||||
static const VIETNAM = "vi";
|
||||
}
|
||||
156
lib/product/constant/navigation/navigation_router.dart
Normal file
156
lib/product/constant/navigation/navigation_router.dart
Normal file
@@ -0,0 +1,156 @@
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:sfm_app/feature/devices/device_detail/device_detail_bloc.dart';
|
||||
import 'package:sfm_app/feature/devices/device_detail/device_detail_screen.dart';
|
||||
import 'package:sfm_app/feature/settings/device_notification_settings/device_notification_settings_bloc.dart';
|
||||
import 'package:sfm_app/feature/settings/device_notification_settings/device_notification_settings_screen.dart';
|
||||
import '../app/app_constants.dart';
|
||||
import '../../../feature/auth/login/bloc/login_bloc.dart';
|
||||
import '../../../feature/auth/login/screen/login_screen.dart';
|
||||
import '../../../feature/bell/bell_bloc.dart';
|
||||
import '../../../feature/bell/bell_screen.dart';
|
||||
import '../../../feature/devices/device_update/device_update_bloc.dart';
|
||||
import '../../../feature/devices/device_update/device_update_screen.dart';
|
||||
import '../../../feature/devices/devices_manager_bloc.dart';
|
||||
import '../../../feature/devices/devices_manager_screen.dart';
|
||||
import '../../../feature/error/not_found_screen.dart';
|
||||
import '../../../feature/inter_family/group_detail/group_detail_bloc.dart';
|
||||
import '../../../feature/inter_family/group_detail/group_detail_screen.dart';
|
||||
import '../../../feature/inter_family/inter_family_bloc.dart';
|
||||
import '../../../feature/inter_family/inter_family_screen.dart';
|
||||
import '../../../feature/log/device_logs_bloc.dart';
|
||||
import '../../../feature/log/device_logs_screen.dart';
|
||||
import '../../../feature/main/main_bloc.dart';
|
||||
import '../../../feature/main/main_screen.dart';
|
||||
import '../../../feature/map/map_bloc.dart';
|
||||
import '../../../feature/map/map_screen.dart';
|
||||
import '../../../feature/settings/settings_bloc.dart';
|
||||
import '../../../feature/settings/settings_screen.dart';
|
||||
import '../../../product/base/bloc/base_bloc.dart';
|
||||
import '../enums/app_route_enums.dart';
|
||||
import '../../../product/shared/shared_transition.dart';
|
||||
|
||||
GoRouter goRouter() {
|
||||
return GoRouter(
|
||||
debugLogDiagnostics: true,
|
||||
errorBuilder: (context, state) => const NotFoundScreen(),
|
||||
initialLocation: ApplicationConstants.LOGIN_PATH,
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
path: ApplicationConstants.LOGIN_PATH,
|
||||
name: AppRoutes.LOGIN.name,
|
||||
builder: (context, state) => BlocProvider(
|
||||
child: const LoginScreen(),
|
||||
blocBuilder: () => LoginBloc(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.HOME_PATH,
|
||||
name: AppRoutes.HOME.name,
|
||||
builder: (context, state) => BlocProvider(
|
||||
child: const MainScreen(),
|
||||
blocBuilder: () => MainBloc(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.SETTINGS_PATH,
|
||||
name: AppRoutes.SETTINGS.name,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: BlocProvider(
|
||||
child: const SettingsScreen(),
|
||||
blocBuilder: () => SettingsBloc(),
|
||||
),
|
||||
transitionsBuilder: transitionsBottomToTop,
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.BELL_PATH,
|
||||
name: AppRoutes.BELL.name,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: BlocProvider(
|
||||
child: const BellScreen(),
|
||||
blocBuilder: () => BellBloc(),
|
||||
),
|
||||
transitionsBuilder: transitionsCustom1),
|
||||
),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.DEVICES_MANAGER_PATH,
|
||||
name: AppRoutes.DEVICES.name,
|
||||
builder: (context, state) => BlocProvider(
|
||||
child: const DevicesManagerScreen(),
|
||||
blocBuilder: () => DevicesManagerBloc(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '${ApplicationConstants.DEVICES_UPDATE_PATH}/:thingID',
|
||||
name: AppRoutes.DEVICE_UPDATE.name,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: BlocProvider(
|
||||
child: DeviceUpdateScreen(
|
||||
thingID: state.pathParameters['thingID']!,
|
||||
),
|
||||
blocBuilder: () => DeviceUpdateBloc(),
|
||||
),
|
||||
transitionsBuilder: transitionsBottomToTop),
|
||||
),
|
||||
GoRoute(
|
||||
path: '${ApplicationConstants.DEVICES_DETAIL_PATH}/:thingID',
|
||||
name: AppRoutes.DEVICE_DETAIL.name,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: BlocProvider(
|
||||
child: DetailDeviceScreen(
|
||||
thingID: state.pathParameters['thingID']!,
|
||||
),
|
||||
blocBuilder: () => DetailDeviceBloc(),
|
||||
),
|
||||
transitionsBuilder: transitionsRightToLeft),
|
||||
),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.MAP_PATH,
|
||||
name: AppRoutes.MAP.name,
|
||||
builder: (context, state) => BlocProvider(
|
||||
child: const MapScreen(),
|
||||
blocBuilder: () => MapBloc(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.DEVICE_LOGS_PATH,
|
||||
name: AppRoutes.HISTORY.name,
|
||||
builder: (context, state) => BlocProvider(
|
||||
child: const DeviceLogsScreen(),
|
||||
blocBuilder: () => DeviceLogsBloc(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.GROUP_PATH,
|
||||
name: AppRoutes.GROUPS.name,
|
||||
builder: (context, state) => BlocProvider(
|
||||
child: const InterFamilyScreen(),
|
||||
blocBuilder: () => InterFamilyBloc(),
|
||||
),
|
||||
),
|
||||
GoRoute(
|
||||
path: '${ApplicationConstants.GROUP_PATH}/:groupId',
|
||||
name: AppRoutes.GROUP_DETAIL.name,
|
||||
pageBuilder: (context, state) {
|
||||
final groupId = state.pathParameters['groupId']!;
|
||||
final role = state.extra! as String;
|
||||
return CustomTransitionPage(
|
||||
child: BlocProvider(
|
||||
child: DetailGroupScreen(group: groupId, role: role),
|
||||
blocBuilder: () => DetailGroupBloc(),
|
||||
),
|
||||
transitionsBuilder: transitionsRightToLeft);
|
||||
}),
|
||||
GoRoute(
|
||||
path: ApplicationConstants.DEVICE_NOTIFICATIONS_SETTINGS,
|
||||
name: AppRoutes.DEVICE_NOTIFICATION_SETTINGS.name,
|
||||
pageBuilder: (context, state) => CustomTransitionPage(
|
||||
child: BlocProvider(
|
||||
child: const DeviceNotificationSettingsScreen(),
|
||||
blocBuilder: () => DeviceNotificationSettingsBloc(),
|
||||
),
|
||||
transitionsBuilder: transitionsRightToLeft),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
class StatusCodeConstants {
|
||||
static const CREATED = 201;
|
||||
static const OK = 200;
|
||||
static const BAD_REQUEST = 400;
|
||||
}
|
||||
Reference in New Issue
Block a user