Go Router Implementation
This commit is contained in:
parent
d6c475cf3a
commit
6984ae85ab
@ -1,293 +1,349 @@
|
||||
import 'package:external_repos/external_repos.dart';
|
||||
// import 'package:external_repos/external_repos.dart';
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
// import 'package:go_router/go_router.dart';
|
||||
// import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
// import 'package:uae_stat/domain/use_cases/auth_use_case.dart';
|
||||
// import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
// import 'package:uae_stat/domain/use_cases/preferences_use_case.dart';
|
||||
// import 'package:uae_stat/infrastructure/services/packages/go_router.dart';
|
||||
// import 'package:uae_stat/presentation/components/logged_in_home_scaffold.dart';
|
||||
// import 'package:uae_stat/presentation/components/my_bottom_nav_bar.dart';
|
||||
// import 'package:uae_stat/presentation/components/my_drawer.dart';
|
||||
// import 'package:uae_stat/presentation/routes/auth_routes/login_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/auth_routes/register_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/competitiveness_flow/report_flow/list_reports_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/competitiveness_flow/report_flow/report_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/country_profile_flow/country_statistics_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/country_profile_flow/list_countries_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/list_uae_numbers_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_aircraft_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_gdp_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_hotels_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_inflation_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_trade_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_area_of_national_reserves_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_oil_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_water_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/electricity_consumption_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/electricity_production_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_general_education_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_higher_education_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_hospitals_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_labor_force_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_population_body.dart';
|
||||
// import 'package:uae_stat/presentation/routes/drawer_routes/feedback_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/drawer_routes/manage_user_router.dart';
|
||||
// import 'package:uae_stat/presentation/routes/drawer_routes/my_favorites_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/drawer_routes/privacy_policy_route.dart';
|
||||
// import 'package:uae_stat/presentation/routes/drawer_routes/profile/reset_pw_route.dart';
|
||||
//
|
||||
// import '../presentation/routes/drawer_routes/profile/profile_route.dart';
|
||||
//
|
||||
// part 'my_router.g.dart';
|
||||
//
|
||||
// class _MyRouter {
|
||||
// const _MyRouter({
|
||||
// required this.isLoggedIn,
|
||||
// });
|
||||
//
|
||||
// final bool isLoggedIn;
|
||||
//
|
||||
// static FutureOr<String?> rootRedirect(
|
||||
// BuildContext context,
|
||||
// GoRouterState state,
|
||||
// ) {
|
||||
// final defaultLanguage = PreferencesUseCase.defaultPrefs.language.name;
|
||||
// if (state.fullPath == '/') {
|
||||
// return '/$defaultLanguage/home';
|
||||
// }
|
||||
// final currentLocale = state.pathParameters['locale'];
|
||||
// if (currentLocale == null) {
|
||||
// return '$defaultLanguage/${state.pathWithParameters}';
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Iterable<GoRoute> get authRoutes => [
|
||||
// GoRoute(
|
||||
// path: 'Profile',
|
||||
// redirect: (context, state) =>
|
||||
// isLoggedIn ? null : '${context.language.name}/profile',
|
||||
// builder: (context, state) => const ProfileRoute(),
|
||||
// ),
|
||||
// GoRoute(
|
||||
// path: 'login',
|
||||
// redirect: (context, state) =>
|
||||
// isLoggedIn ? '${context.language.name}/profile' : null,
|
||||
// builder: (context, state) => const ProfileRoute(),
|
||||
// //builder: (context, state) => const LoginRoute(),
|
||||
// ),
|
||||
// // GoRoute(
|
||||
// // path: 'register',
|
||||
// // redirect: (context, state) =>
|
||||
// // isLoggedIn ? '${context.language.name}/profile' : null,
|
||||
// // builder: (context, state) => const RegisterRoute(),
|
||||
// // ),
|
||||
// ];
|
||||
//
|
||||
// static final Iterable<GoRoute> bottomBarRoutes = BottomNavBarItem.values.map(
|
||||
// (e) => switch (e) {
|
||||
// BottomNavBarItem.home => GoRoute(
|
||||
// path: e.routePath,
|
||||
// pageBuilder: (context, state) => const NoTransitionPage(
|
||||
// child: HomeRoute(),
|
||||
// ),
|
||||
// ),
|
||||
// BottomNavBarItem.uaeNumbers => GoRoute(
|
||||
// path: e.routePath,
|
||||
// pageBuilder: (context, state) => const NoTransitionPage(
|
||||
// child: ListUAENumbersRoute(),
|
||||
// ),
|
||||
// routes: [
|
||||
// ...IndicatorEnum.values.map(
|
||||
// (ie) => GoRoute(
|
||||
// path: ie.name,
|
||||
// builder: (context, state) => switch (ie) {
|
||||
// // environment
|
||||
// IndicatorEnum.nationalReservesArea =>
|
||||
// const AreaOfNationalReservesBody(),
|
||||
// IndicatorEnum.crudeOilProduction => const OilBody(),
|
||||
// IndicatorEnum.exportOilQuantity => const OilBody(),
|
||||
// IndicatorEnum.electricityProduction =>
|
||||
// const ElectricityProductionBody(),
|
||||
// IndicatorEnum.electricityConsumption =>
|
||||
// const ElectricityConsumptionBody(),
|
||||
// IndicatorEnum.desalinatedWaterProduction => const WaterBody(),
|
||||
// IndicatorEnum.municipalWaste => throw UnimplementedError(),
|
||||
// // trade
|
||||
// IndicatorEnum.inflationRate => const InflationBody(),
|
||||
// IndicatorEnum.gdpConstant => const GdpBody(),
|
||||
// IndicatorEnum.gdpGrowthConstant => const GdpBody(),
|
||||
// IndicatorEnum.aircraftMovement => const AircraftBody(),
|
||||
// IndicatorEnum.tradeValue => const TradeBody(),
|
||||
// IndicatorEnum.hotelGuests => const HotelsBody(),
|
||||
// // social
|
||||
// IndicatorEnum.studentsGeneral => const GeneralEducationBody(),
|
||||
// IndicatorEnum.studentsHigher => const HigherEducationBody(),
|
||||
// IndicatorEnum.hospitalsGovernment => const HospitalsBody(),
|
||||
// IndicatorEnum.hospitalsPrivate => const HospitalsBody(),
|
||||
// IndicatorEnum.laborForce => const LaborForceBody(),
|
||||
// IndicatorEnum.population => const PopulationBody(),
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// BottomNavBarItem.competitiveness => GoRoute(
|
||||
// path: e.routePath,
|
||||
// pageBuilder: (context, state) => const NoTransitionPage(
|
||||
// child: ListReportsRoute(),
|
||||
// ),
|
||||
// routes: [
|
||||
// GoRoute(
|
||||
// path: ':reportCode',
|
||||
// builder: (context, state) => ReportRoute(
|
||||
// reportCode: state.pathParameters['reportCode'] as String,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// BottomNavBarItem.countryStatistics => GoRoute(
|
||||
// path: e.routePath,
|
||||
// pageBuilder: (context, state) => const NoTransitionPage(
|
||||
// child: ListCountriesRoute(),
|
||||
// ),
|
||||
// routes: [
|
||||
// GoRoute(
|
||||
// path: ':alpha2CountryCode',
|
||||
// redirect: (context, state) {
|
||||
// final code = state.pathParameters['alpha2CountryCode'];
|
||||
// if (code == null) return 'country-profile';
|
||||
// return null;
|
||||
// },
|
||||
// builder: (context, state) {
|
||||
// final alpha2Code = state.pathParameters['alpha2CountryCode']!;
|
||||
// final country = ISOCountry.fromAlpha2(alpha2Code);
|
||||
// return CountryProfileRoute(country: country);
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// },
|
||||
// );
|
||||
//
|
||||
// Iterable<GoRoute> get _drawerRoutes => [
|
||||
// GoRoute(
|
||||
// path: 'profile',
|
||||
// redirect: (context, state) {
|
||||
// if (isLoggedIn) return null;
|
||||
// return '/${context.language.name}/login';
|
||||
// },
|
||||
// pageBuilder: (context, state) => const NoTransitionPage(
|
||||
// child: ProfileRoute(),
|
||||
// ),
|
||||
// routes: [
|
||||
// GoRoute(
|
||||
// path: 'reset-pw',
|
||||
// builder: (context, state) => const ResetPwRoute(),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ...DrawerItems.values.map(
|
||||
// (e) => GoRoute(
|
||||
// path: e.routePath,
|
||||
// pageBuilder: (context, state) => NoTransitionPage(
|
||||
// child: switch (e) {
|
||||
// DrawerItems.favorites => const MyFavoritesRoute(),
|
||||
// //DrawerItems.feedback => const FeedbackRoute(),
|
||||
// DrawerItems.feedback => FeedbackForm(),
|
||||
// DrawerItems.privacyPolicy => const PrivacyPolicyRoute(),
|
||||
// DrawerItems.manageuser => ManageUserRouter()
|
||||
// // DrawerItems.userGuide => const NotificationsRoute(),
|
||||
// // DrawerItems.notifications => const UserGuideRoute(),
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ];
|
||||
//
|
||||
// ShellRoute get inAppRoutes => ShellRoute(
|
||||
// builder: (context, state, child) => LoggedInHomeScaffold(
|
||||
// body: child,
|
||||
// ),
|
||||
// routes: [
|
||||
// ...bottomBarRoutes,
|
||||
// ..._drawerRoutes,
|
||||
// ],
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// String? _pathCache;
|
||||
//
|
||||
// @riverpod
|
||||
// Future<GoRouter> router(RouterRef ref) async {
|
||||
// final routerKey = GlobalKey<NavigatorState>(
|
||||
// debugLabel: 'routerKey',
|
||||
// );
|
||||
// final isLoggedIn = await ref.watch(
|
||||
// authUseCaseProvider.future.select(
|
||||
// (session) async => (await session) != null,
|
||||
// ),
|
||||
// );
|
||||
// final language = await ref.watch(
|
||||
// preferencesUseCaseProvider.future.select(
|
||||
// (asyncPrefs) async => (await asyncPrefs).language,
|
||||
// ),
|
||||
// );
|
||||
// final myRouter = _MyRouter(
|
||||
// isLoggedIn: isLoggedIn,
|
||||
// );
|
||||
// final router = GoRouter(
|
||||
// navigatorKey: routerKey,
|
||||
// initialLocation: _pathCache ?? '/$language/home',
|
||||
// routes: <RouteBase>[
|
||||
// GoRoute(
|
||||
// redirect: _MyRouter.rootRedirect,
|
||||
// path: '/:locale',
|
||||
// routes: [
|
||||
// myRouter.inAppRoutes,
|
||||
// // ...myRouter.authRoutes,
|
||||
// ]
|
||||
// .map(
|
||||
// (e) => ShellRoute(
|
||||
// builder: (context, state, child) {
|
||||
// final goRouterState = GoRouterState.of(context);
|
||||
// final locale = goRouterState.pathParameters['locale']!;
|
||||
// final language = LanguageLocale.fromName(locale);
|
||||
// return Localizations.override(
|
||||
// context: context,
|
||||
// delegates: GlobalMaterialLocalizations.delegates,
|
||||
// locale: Locale(
|
||||
// switch (language) {
|
||||
// LanguageLocale.enUS => 'en',
|
||||
// LanguageLocale.arAE => 'ar',
|
||||
// },
|
||||
// ),
|
||||
// child: Directionality(
|
||||
// textDirection: switch (language) {
|
||||
// LanguageLocale.enUS => TextDirection.ltr,
|
||||
// LanguageLocale.arAE => TextDirection.rtl,
|
||||
// },
|
||||
// child: child,
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// routes: [e],
|
||||
// ),
|
||||
// )
|
||||
// .toList(),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// ref.onDispose(
|
||||
// () {
|
||||
// _pathCache =
|
||||
// ref.state.valueOrNull?.routeInformationProvider.value.uri.toString();
|
||||
// router.dispose();
|
||||
// },
|
||||
// );
|
||||
//
|
||||
// return router;
|
||||
// }
|
||||
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:uae_stat/domain/use_cases/auth_use_case.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/domain/use_cases/preferences_use_case.dart';
|
||||
import 'package:uae_stat/infrastructure/services/packages/go_router.dart';
|
||||
import 'package:uae_stat/presentation/components/logged_in_home_scaffold.dart';
|
||||
import 'package:uae_stat/presentation/components/my_bottom_nav_bar.dart';
|
||||
import 'package:uae_stat/presentation/components/my_drawer.dart';
|
||||
import 'package:uae_stat/presentation/routes/auth_routes/login_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/auth_routes/register_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/competitiveness_flow/report_flow/list_reports_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/competitiveness_flow/report_flow/report_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/country_profile_flow/country_statistics_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/country_profile_flow/list_countries_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/home_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/list_uae_numbers_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_aircraft_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_gdp_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_hotels_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_inflation_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/economy/_trade_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_area_of_national_reserves_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_oil_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/_water_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/electricity_consumption_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/environment/electricity_production_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_general_education_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_higher_education_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_hospitals_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_labor_force_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/bottom_bar_routes/tab_routes/uae_numbers_routes/sub_routes/social/_population_body.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/feedback_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/manage_user_router.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/my_favorites_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/privacy_policy_route.dart';
|
||||
import 'package:uae_stat/presentation/routes/drawer_routes/profile/reset_pw_route.dart';
|
||||
|
||||
import '../presentation/routes/drawer_routes/profile/profile_route.dart';
|
||||
import '../domain/use_cases/preferences_use_case.dart';
|
||||
import '../presentation/Screens/changepassword.dart';
|
||||
import '../presentation/Screens/confirm_password.dart';
|
||||
import '../presentation/Screens/otp_verification.dart';
|
||||
import '../presentation/Screens/profilepage.dart';
|
||||
import '../presentation/routes/auth_routes/login_route.dart';
|
||||
import '../presentation/routes/bottom_bar_routes/tab_routes/home_route.dart';
|
||||
|
||||
part 'my_router.g.dart';
|
||||
|
||||
class _MyRouter {
|
||||
const _MyRouter({
|
||||
required this.isLoggedIn,
|
||||
});
|
||||
|
||||
final bool isLoggedIn;
|
||||
|
||||
static FutureOr<String?> rootRedirect(
|
||||
BuildContext context,
|
||||
GoRouterState state,
|
||||
) {
|
||||
final defaultLanguage = PreferencesUseCase.defaultPrefs.language.name;
|
||||
if (state.fullPath == '/') {
|
||||
return '/$defaultLanguage/home';
|
||||
}
|
||||
final currentLocale = state.pathParameters['locale'];
|
||||
if (currentLocale == null) {
|
||||
return '$defaultLanguage/${state.pathWithParameters}';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Iterable<GoRoute> get authRoutes => [
|
||||
GoRoute(
|
||||
path: 'Profile',
|
||||
redirect: (context, state) =>
|
||||
isLoggedIn ? null : '${context.language.name}/profile',
|
||||
builder: (context, state) => const ProfileRoute(),
|
||||
),
|
||||
GoRoute(
|
||||
path: 'login',
|
||||
redirect: (context, state) =>
|
||||
isLoggedIn ? '${context.language.name}/profile' : null,
|
||||
builder: (context, state) => const ProfileRoute(),
|
||||
//builder: (context, state) => const LoginRoute(),
|
||||
),
|
||||
// GoRoute(
|
||||
// path: 'register',
|
||||
// redirect: (context, state) =>
|
||||
// isLoggedIn ? '${context.language.name}/profile' : null,
|
||||
// builder: (context, state) => const RegisterRoute(),
|
||||
// ),
|
||||
];
|
||||
|
||||
static final Iterable<GoRoute> bottomBarRoutes = BottomNavBarItem.values.map(
|
||||
(e) => switch (e) {
|
||||
BottomNavBarItem.home => GoRoute(
|
||||
path: e.routePath,
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: HomeRoute(),
|
||||
),
|
||||
),
|
||||
BottomNavBarItem.uaeNumbers => GoRoute(
|
||||
path: e.routePath,
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: ListUAENumbersRoute(),
|
||||
),
|
||||
routes: [
|
||||
...IndicatorEnum.values.map(
|
||||
(ie) => GoRoute(
|
||||
path: ie.name,
|
||||
builder: (context, state) => switch (ie) {
|
||||
// environment
|
||||
IndicatorEnum.nationalReservesArea =>
|
||||
const AreaOfNationalReservesBody(),
|
||||
IndicatorEnum.crudeOilProduction => const OilBody(),
|
||||
IndicatorEnum.exportOilQuantity => const OilBody(),
|
||||
IndicatorEnum.electricityProduction =>
|
||||
const ElectricityProductionBody(),
|
||||
IndicatorEnum.electricityConsumption =>
|
||||
const ElectricityConsumptionBody(),
|
||||
IndicatorEnum.desalinatedWaterProduction => const WaterBody(),
|
||||
IndicatorEnum.municipalWaste => throw UnimplementedError(),
|
||||
// trade
|
||||
IndicatorEnum.inflationRate => const InflationBody(),
|
||||
IndicatorEnum.gdpConstant => const GdpBody(),
|
||||
IndicatorEnum.gdpGrowthConstant => const GdpBody(),
|
||||
IndicatorEnum.aircraftMovement => const AircraftBody(),
|
||||
IndicatorEnum.tradeValue => const TradeBody(),
|
||||
IndicatorEnum.hotelGuests => const HotelsBody(),
|
||||
// social
|
||||
IndicatorEnum.studentsGeneral => const GeneralEducationBody(),
|
||||
IndicatorEnum.studentsHigher => const HigherEducationBody(),
|
||||
IndicatorEnum.hospitalsGovernment => const HospitalsBody(),
|
||||
IndicatorEnum.hospitalsPrivate => const HospitalsBody(),
|
||||
IndicatorEnum.laborForce => const LaborForceBody(),
|
||||
IndicatorEnum.population => const PopulationBody(),
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
BottomNavBarItem.competitiveness => GoRoute(
|
||||
path: e.routePath,
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: ListReportsRoute(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: ':reportCode',
|
||||
builder: (context, state) => ReportRoute(
|
||||
reportCode: state.pathParameters['reportCode'] as String,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
BottomNavBarItem.countryStatistics => GoRoute(
|
||||
path: e.routePath,
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: ListCountriesRoute(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: ':alpha2CountryCode',
|
||||
redirect: (context, state) {
|
||||
final code = state.pathParameters['alpha2CountryCode'];
|
||||
if (code == null) return 'country-profile';
|
||||
return null;
|
||||
},
|
||||
builder: (context, state) {
|
||||
final alpha2Code = state.pathParameters['alpha2CountryCode']!;
|
||||
final country = ISOCountry.fromAlpha2(alpha2Code);
|
||||
return CountryProfileRoute(country: country);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
},
|
||||
);
|
||||
|
||||
Iterable<GoRoute> get _drawerRoutes => [
|
||||
GoRoute(
|
||||
path: 'profile',
|
||||
redirect: (context, state) {
|
||||
if (isLoggedIn) return null;
|
||||
return '/${context.language.name}/login';
|
||||
},
|
||||
pageBuilder: (context, state) => const NoTransitionPage(
|
||||
child: ProfileRoute(),
|
||||
),
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: 'reset-pw',
|
||||
builder: (context, state) => const ResetPwRoute(),
|
||||
),
|
||||
],
|
||||
),
|
||||
...DrawerItems.values.map(
|
||||
(e) => GoRoute(
|
||||
path: e.routePath,
|
||||
pageBuilder: (context, state) => NoTransitionPage(
|
||||
child: switch (e) {
|
||||
DrawerItems.favorites => const MyFavoritesRoute(),
|
||||
//DrawerItems.feedback => const FeedbackRoute(),
|
||||
DrawerItems.feedback => FeedbackForm(),
|
||||
DrawerItems.privacyPolicy => const PrivacyPolicyRoute(),
|
||||
DrawerItems.manageuser => ManageUserRouter()
|
||||
// DrawerItems.userGuide => const NotificationsRoute(),
|
||||
// DrawerItems.notifications => const UserGuideRoute(),
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
];
|
||||
|
||||
ShellRoute get inAppRoutes => ShellRoute(
|
||||
builder: (context, state, child) => LoggedInHomeScaffold(
|
||||
body: child,
|
||||
),
|
||||
routes: [
|
||||
...bottomBarRoutes,
|
||||
..._drawerRoutes,
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String? _pathCache;
|
||||
|
||||
@riverpod
|
||||
Future<GoRouter> router(RouterRef ref) async {
|
||||
final routerKey = GlobalKey<NavigatorState>(
|
||||
debugLabel: 'routerKey',
|
||||
);
|
||||
final isLoggedIn = await ref.watch(
|
||||
authUseCaseProvider.future.select(
|
||||
(session) async => (await session) != null,
|
||||
final GoRouter router = GoRouter(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => LoginRoute(),
|
||||
),
|
||||
);
|
||||
final language = await ref.watch(
|
||||
preferencesUseCaseProvider.future.select(
|
||||
(asyncPrefs) async => (await asyncPrefs).language,
|
||||
GoRoute(
|
||||
path: '/profile',
|
||||
builder: (context, state) => ProfileScreen(userId: '',),
|
||||
),
|
||||
);
|
||||
final myRouter = _MyRouter(
|
||||
isLoggedIn: isLoggedIn,
|
||||
);
|
||||
final router = GoRouter(
|
||||
navigatorKey: routerKey,
|
||||
initialLocation: _pathCache ?? '/$language/home',
|
||||
routes: <RouteBase>[
|
||||
GoRoute(
|
||||
redirect: _MyRouter.rootRedirect,
|
||||
path: '/:locale',
|
||||
routes: [
|
||||
myRouter.inAppRoutes,
|
||||
...myRouter.authRoutes,
|
||||
]
|
||||
.map(
|
||||
(e) => ShellRoute(
|
||||
builder: (context, state, child) {
|
||||
final goRouterState = GoRouterState.of(context);
|
||||
final locale = goRouterState.pathParameters['locale']!;
|
||||
final language = LanguageLocale.fromName(locale);
|
||||
return Localizations.override(
|
||||
context: context,
|
||||
delegates: GlobalMaterialLocalizations.delegates,
|
||||
locale: Locale(
|
||||
switch (language) {
|
||||
LanguageLocale.enUS => 'en',
|
||||
LanguageLocale.arAE => 'ar',
|
||||
},
|
||||
),
|
||||
child: Directionality(
|
||||
textDirection: switch (language) {
|
||||
LanguageLocale.enUS => TextDirection.ltr,
|
||||
LanguageLocale.arAE => TextDirection.rtl,
|
||||
},
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
},
|
||||
routes: [e],
|
||||
),
|
||||
)
|
||||
.toList(),
|
||||
),
|
||||
],
|
||||
);
|
||||
ref.onDispose(
|
||||
() {
|
||||
_pathCache =
|
||||
ref.state.valueOrNull?.routeInformationProvider.value.uri.toString();
|
||||
router.dispose();
|
||||
},
|
||||
);
|
||||
// GoRoute(
|
||||
// path: '/home',
|
||||
// builder: (context, state) => HomeRoute(),
|
||||
// ),
|
||||
|
||||
return router;
|
||||
}
|
||||
GoRoute(
|
||||
path: '/myhomepage',
|
||||
builder: (context, state) => MyHomePage(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/changepw',
|
||||
builder: (context, state) => Changepassword(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/mailverification',
|
||||
builder: (context, state) => EmailVerificationScreen(email: '', userId: '', otp: '', otpId: '', sendVerificationCode: (String ) { },),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/changepass',
|
||||
builder: (context, state) => Changepassword(),
|
||||
),
|
||||
GoRoute(
|
||||
path: '/confirmpasswd',
|
||||
builder: (context, state) => ConfirmPassword(email: '', userId: '',),
|
||||
),
|
||||
|
||||
|
||||
|
||||
|
||||
],
|
||||
);
|
||||
|
||||
@ -16,25 +16,34 @@ void main() async {
|
||||
// await (await SharedPreferences.getInstance()).clear();
|
||||
configureDependencies();
|
||||
runApp(
|
||||
const ProviderScope(
|
||||
ProviderScope(
|
||||
child: MainApp(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class MainApp extends StatelessWidget {
|
||||
const MainApp({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: RegisterScreen(),
|
||||
//home: ProfileScreen(),
|
||||
debugShowCheckedModeBanner: false,
|
||||
return MaterialApp.router(
|
||||
routerConfig: router, // Use the GoRouter configuration
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// class MainApp extends StatelessWidget {
|
||||
// const MainApp({super.key});
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return MaterialApp(
|
||||
// home: RegisterScreen(),
|
||||
// //home: ProfileScreen(),
|
||||
// debugShowCheckedModeBanner: false,
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// class MainApp extends ConsumerWidget {
|
||||
// const MainApp({super.key});
|
||||
@ -94,3 +103,5 @@ class MainApp extends StatelessWidget {
|
||||
// return authFinalizedWidget;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import 'dart:convert';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import 'otp_verification.dart';
|
||||
//import 'otp_verification.dart';
|
||||
|
||||
class Changepassword extends StatefulWidget {
|
||||
const Changepassword({Key? key}) : super(key: key);
|
||||
@ -75,39 +76,42 @@ class _ResetPasswordScreenState extends State<Changepassword> {
|
||||
final otp = otpData['otp']; // OTP value from the response
|
||||
final otpId = otpData['id'];
|
||||
_otpId = otpData['id'];
|
||||
|
||||
//print('OTP: $otp, ID: $otpId, ');
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Verification code sent to $email")),
|
||||
);
|
||||
|
||||
// Navigate to the Email Verification screen
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => EmailVerificationScreen(
|
||||
email: email,
|
||||
userId: userId, // Pass user ID to the next screen
|
||||
otp: otp,
|
||||
otpId: otpId,
|
||||
sendVerificationCode: sendVerificationCode,
|
||||
),
|
||||
),
|
||||
);
|
||||
// Navigator.push(
|
||||
// context,
|
||||
// MaterialPageRoute(
|
||||
// builder: (context) => EmailVerificationScreen(
|
||||
// email: email,
|
||||
// userId: userId, // Pass user ID to the next screen
|
||||
// otp: otp,
|
||||
// otpId: otpId,
|
||||
// sendVerificationCode: sendVerificationCode,
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
} else {
|
||||
context.go('/Profile');
|
||||
final error =
|
||||
jsonDecode(otpResponse.body)['error'] ?? "Unknown error";
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Error: $error")),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Email not found
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Please Enter Registered Mail ID")),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Error in user collection request
|
||||
final error =
|
||||
jsonDecode(userCheckResponse.body)['error'] ?? "Unknown error";
|
||||
@ -115,11 +119,13 @@ class _ResetPasswordScreenState extends State<Changepassword> {
|
||||
SnackBar(content: Text("Error: $error")),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
catch (e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Failed to process request: $e")),
|
||||
);
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
});
|
||||
@ -232,12 +238,15 @@ class _ResetPasswordScreenState extends State<Changepassword> {
|
||||
width: double.infinity,
|
||||
height: 48,
|
||||
child: ElevatedButton(
|
||||
onPressed: _isLoading
|
||||
? null
|
||||
: () {
|
||||
final email = _emailController.text.trim();
|
||||
sendVerificationCode(email);
|
||||
},
|
||||
onPressed: (){
|
||||
context.go('/mailverification');
|
||||
},
|
||||
// _isLoading
|
||||
// ? null
|
||||
// : () {
|
||||
// final email = _emailController.text.trim();
|
||||
// sendVerificationCode(email);
|
||||
// },
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF8B7355),
|
||||
foregroundColor: Colors.white,
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import 'package:uae_stat/presentation/Screens/profilepage.dart';
|
||||
|
||||
@ -201,18 +202,22 @@ class _ConfirmPasswordState extends State<ConfirmPassword> {
|
||||
SizedBox(
|
||||
width: screenwidth / 1.1,
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
if ((_formKey.currentState?.validate() ?? false)) {
|
||||
//String userId = '4hai9cbn4lg6jt4'; // Replace with the actual user ID
|
||||
String newPassword = _password ??
|
||||
''; // Replace with the new password
|
||||
|
||||
//print("Confirm Passwd- $widget.userId, $newPassword");
|
||||
|
||||
await updatePassword(widget.userId, newPassword);
|
||||
}
|
||||
// Add verification logic here
|
||||
onPressed: ()
|
||||
{
|
||||
context.go('/myhomepage');
|
||||
},
|
||||
// async {
|
||||
// if ((_formKey.currentState?.validate() ?? false)) {
|
||||
// //String userId = '4hai9cbn4lg6jt4'; // Replace with the actual user ID
|
||||
// String newPassword = _password ??
|
||||
// ''; // Replace with the new password
|
||||
//
|
||||
// //print("Confirm Passwd- $widget.userId, $newPassword");
|
||||
//
|
||||
// await updatePassword(widget.userId, newPassword);
|
||||
// }
|
||||
// // Add verification logic here
|
||||
// },
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.brown[300],
|
||||
padding: EdgeInsets.symmetric(
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
import 'package:uae_stat/config/my_router.dart';
|
||||
|
||||
import 'confirm_password.dart';
|
||||
|
||||
@ -214,17 +216,20 @@ class _EmailVerificationScreenState extends State<EmailVerificationScreen> {
|
||||
SizedBox(
|
||||
width: screenwidth / 1.2,
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
// Combine the entered OTP
|
||||
String enteredOTP = _otpControllers
|
||||
.map((controller) => controller.text)
|
||||
.join();
|
||||
|
||||
verify(
|
||||
context, widget.email, enteredOTP, widget.userId);
|
||||
|
||||
// Add verification logic here
|
||||
onPressed: () {
|
||||
context.go('/confirmpasswd');
|
||||
},
|
||||
//async {
|
||||
// Combine the entered OTP
|
||||
// String enteredOTP = _otpControllers
|
||||
// .map((controller) => controller.text)
|
||||
// .join();
|
||||
//
|
||||
// verify(
|
||||
// context, widget.email, enteredOTP, widget.userId);
|
||||
//
|
||||
// // Add verification logic here
|
||||
// },
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.brown[300],
|
||||
padding:
|
||||
|
||||
@ -1,14 +1,18 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
//import 'package:pocketbase/pocketbase.dart';
|
||||
|
||||
import '../../domain/use_cases/preferences_use_case.dart';
|
||||
import '../routes/bottom_bar_routes/tab_routes/home_route.dart';
|
||||
import 'changepassword.dart';
|
||||
|
||||
class ProfileScreen extends StatefulWidget {
|
||||
@ -20,7 +24,8 @@ class ProfileScreen extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ProfileScreenState extends State<ProfileScreen> {
|
||||
final _pb = PocketBase('https://pb.venbait.in');
|
||||
final defaultLanguage = PreferencesUseCase.defaultPrefs.language.name;
|
||||
//final _pb = PocketBase('https://pb.venbait.in');
|
||||
// final _pb = PocketBase('http://127.0.0.1:8090');
|
||||
final _formKey = GlobalKey<FormState>();
|
||||
final TextEditingController _fullNameController = TextEditingController();
|
||||
@ -46,42 +51,42 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
|
||||
// Regular expression to validate Full Name (no special characters)
|
||||
final RegExp _nameRegExp = RegExp(r"^[a-zA-Z\s]+$");
|
||||
late Future<RecordModel> userDetails;
|
||||
//late Future<RecordModel> userDetails;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
print(widget.userId);
|
||||
_fetchUserData(); // Call the function to fetch user data
|
||||
}
|
||||
// void initState() {
|
||||
// super.initState();
|
||||
// print(widget.userId);
|
||||
// _fetchUserData(); // Call the function to fetch user data
|
||||
// }
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_fullNameController.dispose();
|
||||
_dateController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
// void dispose() {
|
||||
// _fullNameController.dispose();
|
||||
// _dateController.dispose();
|
||||
// super.dispose();
|
||||
// }
|
||||
|
||||
Future<void> _fetchUserData() async {
|
||||
try {
|
||||
final adminAuth = await _pb.admins
|
||||
.authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com');
|
||||
final adminToken = adminAuth.token;
|
||||
final userDetailsResponse = await _pb.collection('users').getOne(
|
||||
widget.userId,
|
||||
headers: {
|
||||
'Authorization': 'Bearer $adminToken',
|
||||
},
|
||||
);
|
||||
print('userDetails: $userDetailsResponse');
|
||||
setState(() {
|
||||
_usernameController.text = userDetailsResponse.data['username'] ?? '';
|
||||
_emailController.text = userDetailsResponse.data['email'] ?? '';
|
||||
});
|
||||
} catch (e) {
|
||||
print('Error fetching user details: $e');
|
||||
}
|
||||
}
|
||||
// Future<void> _fetchUserData() async {
|
||||
// try {
|
||||
// final adminAuth = await _pb.admins
|
||||
// .authWithPassword('pb@venbainfotech.com', 'pb@venbainfotech.com');
|
||||
// final adminToken = adminAuth.token;
|
||||
// final userDetailsResponse = await _pb.collection('users').getOne(
|
||||
// widget.userId,
|
||||
// headers: {
|
||||
// 'Authorization': 'Bearer $adminToken',
|
||||
// },
|
||||
// );
|
||||
// print('userDetails: $userDetailsResponse');
|
||||
// setState(() {
|
||||
// _usernameController.text = userDetailsResponse.data['username'] ?? '';
|
||||
// _emailController.text = userDetailsResponse.data['email'] ?? '';
|
||||
// });
|
||||
// } catch (e) {
|
||||
// print('Error fetching user details: $e');
|
||||
// }
|
||||
// }
|
||||
|
||||
void _pickImage() async {
|
||||
final XFile? pickedFile =
|
||||
@ -173,30 +178,30 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
String formattedDob = DateFormat('yyyy-MM-dd').format(dob);
|
||||
|
||||
// Create a multipart request
|
||||
final uri =
|
||||
Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID');
|
||||
final request = http.MultipartRequest('PATCH', uri);
|
||||
// final uri =
|
||||
// Uri.parse('${_pb.baseUrl}/api/collections/users/records/$userID');
|
||||
// final request = http.MultipartRequest('PATCH', uri);
|
||||
|
||||
// Add other fields
|
||||
request.fields['full_name'] = fullName;
|
||||
request.fields['dob'] = formattedDob;
|
||||
request.fields['country_region'] = countryRegion;
|
||||
request.fields['is_profile_completed'] = 'True';
|
||||
// request.fields['full_name'] = fullName;
|
||||
// request.fields['dob'] = formattedDob;
|
||||
// request.fields['country_region'] = countryRegion;
|
||||
// request.fields['is_profile_completed'] = 'True';
|
||||
|
||||
// Add the file, if available
|
||||
if (_profileImage != null) {
|
||||
request.files.add(await http.MultipartFile.fromPath(
|
||||
'avatar',
|
||||
_profileImage!.path,
|
||||
));
|
||||
}
|
||||
// if (_profileImage != null) {
|
||||
// request.files.add(await http.MultipartFile.fromPath(
|
||||
// 'avatar',
|
||||
// _profileImage!.path,
|
||||
// ));
|
||||
// }
|
||||
|
||||
// Add headers (if required, e.g., authorization)
|
||||
request.headers['Authorization'] = 'Bearer ${_pb.authStore.token}';
|
||||
//request.headers['Authorization'] = 'Bearer ${_pb.authStore.token}';
|
||||
|
||||
// Send the request
|
||||
final response = await request.send();
|
||||
print(response);
|
||||
//final response = await request.send();
|
||||
//print(response);
|
||||
_resetFormFields();
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text("Profile updated successfully!")));
|
||||
@ -515,11 +520,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
Center(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => Changepassword()),
|
||||
);
|
||||
context.go('/changepass');
|
||||
},
|
||||
child: Text(
|
||||
"Change Password",
|
||||
@ -532,16 +533,18 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
SizedBox(height: 20),
|
||||
ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
if ((_formKey.currentState?.validate() ?? false) &&
|
||||
(isChecked)) {
|
||||
_formKey.currentState?.save();
|
||||
showConfirmationDialog(context);
|
||||
} else {
|
||||
setState(() {
|
||||
showError =
|
||||
!isChecked; // Show error if the checkbox is not checked
|
||||
});
|
||||
}
|
||||
context.go('/myhomepage');
|
||||
// if ((_formKey.currentState?.validate() ?? false) &&
|
||||
// (isChecked)) {
|
||||
// _formKey.currentState?.save();
|
||||
// showConfirmationDialog(context);
|
||||
// } else {
|
||||
// setState(() {
|
||||
// showError =
|
||||
// !isChecked; // Show error if the checkbox is not checked
|
||||
// });
|
||||
// }
|
||||
},
|
||||
// if ((_formKey.currentState?.validate() ?? false) && (isChecked)) {
|
||||
// _formKey.currentState?.save();
|
||||
// showConfirmationDialog(context);
|
||||
@ -560,7 +563,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
|
||||
// );
|
||||
//}
|
||||
//}
|
||||
},
|
||||
//},
|
||||
icon: Icon(
|
||||
Icons.save,
|
||||
color: Colors.white,
|
||||
@ -665,7 +668,8 @@ class ConfirmationDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
onPressed: () => context.go('/home'),
|
||||
//Navigator.of(context).pop(true),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: const Color(0xFF92722A), // Brown color
|
||||
foregroundColor: Colors.white,
|
||||
|
||||
@ -7,6 +7,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:uae_stat/config/my_theme.dart';
|
||||
import 'package:uae_stat/domain/use_cases/language.dart';
|
||||
import 'package:uae_stat/presentation/components/indicators/indicator_view.dart';
|
||||
import 'package:uae_stat/presentation/components/my_bottom_nav_bar.dart';
|
||||
import 'package:uae_stat/presentation/components/my_drawer.dart';
|
||||
import 'package:uae_stat/presentation/components/space.dart';
|
||||
import 'package:uae_stat/presentation/components/themed_app_bar.dart';
|
||||
|
||||
@ -157,3 +159,22 @@ class HomeRoute extends HookConsumerWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyHomePage extends StatefulWidget {
|
||||
const MyHomePage({super.key});
|
||||
|
||||
@override
|
||||
State<MyHomePage> createState() => _MyHomePageState();
|
||||
}
|
||||
|
||||
class _MyHomePageState extends State<MyHomePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
//drawer: MyDrawer(),
|
||||
//bottomNavigationBar: MyBottomNavBar(),
|
||||
body: HomeRoute(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,174 +1,3 @@
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:uae_stat/presentation/components/my_bottom_nav_bar.dart';
|
||||
// import 'package:uae_stat/presentation/components/my_drawer.dart';
|
||||
//
|
||||
//
|
||||
// class ManageUserRouter extends StatefulWidget {
|
||||
// @override
|
||||
// State<ManageUserRouter> createState() => _ManageUserRouterState();
|
||||
// }
|
||||
//
|
||||
// class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
// // Sample data for the table
|
||||
// final List<User> userData = List.generate(
|
||||
// 5,
|
||||
// (index) => User(
|
||||
// userName: 'Conan Keller ${index + 1}',
|
||||
// emailId: 'ConanKeller${index + 1}@gmail.com',
|
||||
// registrationDate: '18/07/2024',
|
||||
// status: 'Pending',
|
||||
// ),
|
||||
// );
|
||||
//
|
||||
// // Sorting state
|
||||
// int _sortColumnIndex = 0;
|
||||
// bool _isAscending = true;
|
||||
//
|
||||
// // Method to sort the data based on a column
|
||||
// void _sort<T>(Comparable<T> Function(User user) getField, int columnIndex, bool ascending) {
|
||||
// setState(() {
|
||||
// _sortColumnIndex = columnIndex;
|
||||
// _isAscending = ascending;
|
||||
// userData.sort((a, b) {
|
||||
// final aValue = getField(a);
|
||||
// final bValue = getField(b);
|
||||
// return ascending ? Comparable.compare(aValue, bValue) : Comparable.compare(bValue, aValue);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// // Define dropdown items
|
||||
// final List<String> statusOptions = ['Approved', 'Denied', 'Pending'];
|
||||
//
|
||||
// // Method to get status color
|
||||
// Color getStatusColor(String status) {
|
||||
// switch (status) {
|
||||
// case 'Approved':
|
||||
// return Colors.green;
|
||||
// case 'Denied':
|
||||
// return Colors.red;
|
||||
// case 'Pending':
|
||||
// return Colors.blue;
|
||||
// default:
|
||||
// return Colors.black;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// double myheight = MediaQuery.of(context).size.height;
|
||||
// return Scaffold(
|
||||
// drawer: MyDrawer(),
|
||||
// appBar: AppBar(
|
||||
// title: const Text('Manage User',style: TextStyle(fontWeight: FontWeight.bold),),
|
||||
// ),
|
||||
// body: SingleChildScrollView(
|
||||
// child: Padding(
|
||||
// padding: const EdgeInsets.only(left: 10.0,right: 10.0,top: 3.0),
|
||||
// child: Column(
|
||||
// children: [
|
||||
// TextField(
|
||||
// decoration: InputDecoration(
|
||||
// prefixIcon: const Icon(Icons.search),
|
||||
// hintText: 'Search',
|
||||
// border: OutlineInputBorder(
|
||||
// borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(height: myheight/40,),
|
||||
// SingleChildScrollView(
|
||||
// scrollDirection: Axis.horizontal,
|
||||
// child:
|
||||
// DataTable(
|
||||
// sortColumnIndex: _sortColumnIndex,
|
||||
// sortAscending: _isAscending,
|
||||
// columns: [
|
||||
// DataColumn(
|
||||
// label: const Text('User Name'),
|
||||
// //label: Row(children: [Text('Name'),Icon(Icons.arrow_upward),Icon(Icons.arrow_downward)],),
|
||||
// onSort: (columnIndex, ascending) => _sort((user) => user.userName, columnIndex, ascending),
|
||||
// numeric: false
|
||||
// ),
|
||||
// DataColumn(
|
||||
// label: const Text('Email ID'),
|
||||
// onSort: (columnIndex, ascending) => _sort((user) => user.emailId, columnIndex, ascending),
|
||||
// numeric: false
|
||||
// ),
|
||||
// DataColumn(
|
||||
// label: const Text('Registration Date'),
|
||||
// onSort: (columnIndex, ascending) => _sort((user) => user.registrationDate, columnIndex, ascending),
|
||||
// numeric: false
|
||||
// ),
|
||||
// DataColumn(
|
||||
// label: const Text('Status'),
|
||||
// onSort: (columnIndex, ascending) => _sort((user) => user.status, columnIndex, ascending),
|
||||
// numeric: false
|
||||
// ),
|
||||
// ],
|
||||
// rows: userData.map((user) {
|
||||
// return DataRow(
|
||||
// cells: [
|
||||
// DataCell(Text(user.userName)),
|
||||
// DataCell(Text(user.emailId)),
|
||||
// DataCell(Text(user.registrationDate)),
|
||||
// DataCell(
|
||||
// DropdownButton<String>(
|
||||
// value: user.status,
|
||||
// items: statusOptions.map((status) {
|
||||
// return DropdownMenuItem<String>(
|
||||
// value: status,
|
||||
// child: Text(
|
||||
// status,
|
||||
// style: TextStyle(color: getStatusColor(status)),
|
||||
// ),
|
||||
// );
|
||||
// }).toList(),
|
||||
// onChanged: (String? newStatus) {
|
||||
// if (newStatus != null) {
|
||||
// setState(() {
|
||||
// user.status = newStatus;
|
||||
// });
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// );
|
||||
// }).toList(),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// // User data model
|
||||
// class User {
|
||||
// final String userName;
|
||||
// final String emailId;
|
||||
// final String registrationDate;
|
||||
// String status;
|
||||
//
|
||||
// User({
|
||||
// required this.userName,
|
||||
// required this.emailId,
|
||||
// required this.registrationDate,
|
||||
// this.status = 'Pending',
|
||||
// });
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:uae_stat/presentation/components/my_bottom_nav_bar.dart';
|
||||
import 'package:uae_stat/presentation/components/my_drawer.dart';
|
||||
@ -234,64 +63,7 @@ class _ManageUserRouterState extends State<ManageUserRouter> {
|
||||
context: context,
|
||||
barrierDismissible: false, // User must tap button to dismiss dialog
|
||||
builder: (BuildContext context) {
|
||||
return
|
||||
// AlertDialog(
|
||||
// shape:
|
||||
// RoundedRectangleBorder(borderRadius: BorderRadius.circular(5.0)),
|
||||
// content: Padding(
|
||||
// padding: const EdgeInsets.all(8.0),
|
||||
// child: Text(
|
||||
// 'Are you sure you want to change \n the status to $newStatus?',
|
||||
// style: TextStyle(fontSize: 15),
|
||||
// ),
|
||||
// ),
|
||||
// actions: <Widget>[
|
||||
// Center(
|
||||
// child: Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
// children: [
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// Navigator.of(context)
|
||||
// .pop(); // Close dialog without changing status
|
||||
// },
|
||||
// style: TextButton.styleFrom(
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius: BorderRadius.circular(
|
||||
// 10.0), // Adjust the radius as needed
|
||||
// ),
|
||||
// side: BorderSide(
|
||||
// color: Colors.blue, // Set the outline color
|
||||
// width: 2.0, // Set the border width
|
||||
// ),
|
||||
// ),
|
||||
// child: Text('No'),
|
||||
// ),
|
||||
// TextButton(
|
||||
// onPressed: () {
|
||||
// setState(() {
|
||||
// user.status = newStatus; // Change status
|
||||
// });
|
||||
// Navigator.of(context).pop();
|
||||
// },
|
||||
// style: TextButton.styleFrom(
|
||||
// backgroundColor: Colors.blue, // Set background color
|
||||
// foregroundColor: Colors.white,
|
||||
// shape: RoundedRectangleBorder(
|
||||
// borderRadius:
|
||||
// BorderRadius.circular(10.0), // Set text color
|
||||
// )),
|
||||
// child: Text(
|
||||
// 'Yes',
|
||||
// style: TextStyle(color: Colors.white),
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ))
|
||||
// ],
|
||||
// );
|
||||
|
||||
AlertDialog(
|
||||
return AlertDialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5.0), // Rounded corners
|
||||
),
|
||||
|
||||
68
pubspec.lock
68
pubspec.lock
@ -282,10 +282,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: equatable
|
||||
sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
|
||||
sha256: "567c64b3cb4cf82397aac55f4f0cbd3ca20d77c6c03bedbc4ceaddc08904aef7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.5"
|
||||
version: "2.0.7"
|
||||
excel:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -345,10 +345,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file_selector_linux
|
||||
sha256: b2b91daf8a68ecfa4a01b778a6f52edef9b14ecd506e771488ea0f2e0784198b
|
||||
sha256: "54cbbd957e1156d29548c7d9b9ec0c0ebb6de0a90452198683a7d23aed617a33"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.9.3+1"
|
||||
version: "0.9.3+2"
|
||||
file_selector_macos:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -385,10 +385,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fl_chart
|
||||
sha256: "94307bef3a324a0d329d3ab77b2f0c6e5ed739185ffc029ed28c0f9b019ea7ef"
|
||||
sha256: "74959b99b92b9eebeed1a4049426fd67c4abc3c5a0f4d12e2877097d6a11ae08"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.69.0"
|
||||
version: "0.69.2"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -435,10 +435,10 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_native_splash
|
||||
sha256: ee5c9bd2b74ea8676442fd4ab876b5d41681df49276488854d6c81a5377c0ef1
|
||||
sha256: "1152ab0067ca5a2ebeb862fe0a762057202cceb22b7e62692dcbabf6483891bb"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.2"
|
||||
version: "2.4.3"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -573,10 +573,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: ce89c5a993ca5eea74535f798478502c30a625ecb10a1de4d7fef5cd1bcac2a4
|
||||
sha256: "8660b74171fafae4aa8202100fa2e55349e078281dadc73a241eb8e758534d9d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.4.1"
|
||||
version: "14.6.1"
|
||||
graphs:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -653,10 +653,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: image_picker_android
|
||||
sha256: "8faba09ba361d4b246dc0a17cb4289b3324c2b9f6db7b3d457ee69106a86bd32"
|
||||
sha256: fa8141602fde3f7e2f81dbf043613eb44dfa325fa0bcf93c0f142c9f7a2c193e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.8.12+17"
|
||||
version: "0.8.12+18"
|
||||
image_picker_for_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -757,10 +757,10 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: json_serializable
|
||||
sha256: ea1432d167339ea9b5bb153f0571d0039607a873d6e04e0117af043f14a1fd4b
|
||||
sha256: c2fcb3920cf2b6ae6845954186420fca40bc0a8abcc84903b7801f17d7050d7c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.8.0"
|
||||
version: "6.9.0"
|
||||
jwt_decoder:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -901,10 +901,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_android
|
||||
sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
|
||||
sha256: "8c4967f8b7cb46dc914e178daa29813d83ae502e0529d7b0478330616a691ef7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.12"
|
||||
version: "2.2.14"
|
||||
path_provider_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1029,10 +1029,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: riverpod_analyzer_utils
|
||||
sha256: dc53a659cb543b203cdc35cd4e942ed08ea893eb6ef12029301323bdf18c5d95
|
||||
sha256: c6b8222b2b483cb87ae77ad147d6408f400c64f060df7a225b127f4afef4f8c8
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.7"
|
||||
version: "0.5.8"
|
||||
riverpod_annotation:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -1045,18 +1045,18 @@ packages:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: riverpod_generator
|
||||
sha256: "54458dac2fea976990dc9ed379060db6ae5c8790143f1963fedd0fb99980a326"
|
||||
sha256: "63546d70952015f0981361636bf8f356d9cfd9d7f6f0815e3c07789a41233188"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.2"
|
||||
version: "2.6.3"
|
||||
riverpod_lint:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: riverpod_lint
|
||||
sha256: "326efc199b87f21053b9a2afbf2aea26c41b3bf6f8ba346ce69126ee17d16ebd"
|
||||
sha256: "83e4caa337a9840469b7b9bd8c2351ce85abad80f570d84146911b32086fbd99"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.2"
|
||||
version: "2.6.3"
|
||||
rxdart:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1156,10 +1156,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_web_socket
|
||||
sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611"
|
||||
sha256: cc36c297b52866d203dbf9332263c94becc2fe0ceaa9681d07b6ef9807023b67
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.0.1"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@ -1296,10 +1296,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: url_launcher_linux
|
||||
sha256: e2b9622b4007f97f504cd64c0128309dfb978ae66adbe944125ed9e1750f06af
|
||||
sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.0"
|
||||
version: "3.2.1"
|
||||
url_launcher_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1360,10 +1360,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: video_player_avfoundation
|
||||
sha256: cd5ab8a8bc0eab65ab0cea40304097edc46da574c8c1ecdee96f28cd8ef3792f
|
||||
sha256: "0b146e5d82e886ff43e5a46c6bcbe390761b802864a6e2503eb612d69a405dfa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.6.2"
|
||||
version: "2.6.3"
|
||||
video_player_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1432,10 +1432,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_android
|
||||
sha256: dec83a8da0a2dcd8a25418534cc59348dbc2855fa1dd0cc929c62b6029fde392
|
||||
sha256: "285cedfd9441267f6cca8843458620b5fda1af75b04f5818d0441acda5d7df19"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.1"
|
||||
version: "4.1.0"
|
||||
webview_flutter_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1448,18 +1448,18 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_wkwebview
|
||||
sha256: f14ee08021772fed913da8daebcfdeb46be457081e521e93e9918fe6cd1ce9e8
|
||||
sha256: b7e92f129482460951d96ef9a46b49db34bd2e1621685de26e9eaafd9674e7eb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.16.1"
|
||||
version: "3.16.3"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: "84ba388638ed7a8cb3445a320c8273136ab2631cd5f2c57888335504ddab1bc2"
|
||||
sha256: "8b338d4486ab3fbc0ba0db9f9b4f5239b6697fcee427939a40e720cbb9ee0a69"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.8.0"
|
||||
version: "5.9.0"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user