2024-05-24 12:32:19 +05:30
|
|
|
import 'package:flutter/material.dart';
|
2024-05-24 19:32:53 +05:30
|
|
|
import 'package:flutter/services.dart';
|
2024-05-29 13:21:55 +05:30
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2024-07-09 14:56:23 +05:30
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
2024-05-24 19:32:53 +05:30
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
2024-07-03 18:46:18 +05:30
|
|
|
import 'package:local_auth/local_auth.dart';
|
2024-07-19 16:20:14 +05:30
|
|
|
import 'package:tanami_app/Globalconst.dart';
|
2024-07-17 19:12:26 +05:30
|
|
|
import 'package:tanami_app/features/login/presentation/bloc/login_bloc.dart';
|
2024-05-24 19:32:53 +05:30
|
|
|
|
|
|
|
|
import 'core/routes/routes.dart';
|
|
|
|
|
import 'core/utils/connectivity/network_connectivity.dart';
|
2024-07-09 14:56:23 +05:30
|
|
|
import 'core/utils/language/localizations_delegate.dart';
|
2024-07-10 20:35:18 +05:30
|
|
|
import 'core/utils/secure/secure_storage_service.dart';
|
2024-07-19 16:20:14 +05:30
|
|
|
import 'features/biometric/bloc/biometric_bloc.dart';
|
|
|
|
|
import 'features/biometric/bloc/biometric_event.dart';
|
2024-07-12 09:14:15 +05:30
|
|
|
import 'features/countrySelection/bloc/GetCountry/get_country_bloc.dart';
|
2024-07-11 11:05:57 +05:30
|
|
|
import 'features/countrySelection/bloc/choose_country_bloc.dart';
|
2024-07-19 16:20:14 +05:30
|
|
|
import 'features/forgotPassword/bloc/restore_password_phone_verification_bloc.dart';
|
2024-07-12 09:14:15 +05:30
|
|
|
import 'features/otpVerification/bloc/otp_bloc.dart';
|
2024-07-17 19:12:26 +05:30
|
|
|
import 'features/register/presentation/bloc/register_bloc.dart';
|
2024-06-05 15:05:11 +05:30
|
|
|
import 'shared/components/bloc/bottom_nav_bar/bottom_navigation_bloc.dart';
|
2024-07-09 14:56:23 +05:30
|
|
|
import 'shared/components/bloc/language/lng_bloc.dart';
|
2024-07-10 20:35:18 +05:30
|
|
|
import 'shared/components/bloc/language/lng_event.dart';
|
2024-07-09 14:56:23 +05:30
|
|
|
import 'shared/components/bloc/language/lng_state.dart';
|
2024-05-24 19:32:53 +05:30
|
|
|
|
|
|
|
|
/* CREATED BY - JAYESH JAIN
|
|
|
|
|
DATE - 24-05-2024
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/// The main function that runs the application.
|
|
|
|
|
Future<void> main() async {
|
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
|
2024-06-12 12:38:31 +05:30
|
|
|
// FlutterError.onError = (FlutterErrorDetails details) {
|
|
|
|
|
// FlutterError.dumpErrorToConsole(details);
|
|
|
|
|
// runApp(CustomErrorWidget(
|
|
|
|
|
// errorMessage: details.toString(),
|
|
|
|
|
// ));
|
|
|
|
|
// };
|
2024-05-24 19:32:53 +05:30
|
|
|
// Set the preferred orientations of the device.
|
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
|
DeviceOrientation.portraitUp,
|
2024-07-05 15:36:29 +05:30
|
|
|
]).then((value) => runApp(const MyApp()
|
|
|
|
|
// StatsFl(
|
2024-07-10 20:35:18 +05:30
|
|
|
// isEnabled: true, //Toggle on/off
|
|
|
|
|
// width: 200, //Set size
|
|
|
|
|
// height: 50, //
|
|
|
|
|
// maxFps: 60, // Support custom FPS target (default is 60)
|
|
|
|
|
// showText: true, // Hide text label
|
|
|
|
|
// sampleTime: .5, //Interval between fps calculations, in seconds.
|
|
|
|
|
// totalTime: 15, //Total length of timeline, in seconds.
|
|
|
|
|
// align: Alignment.center, //Alignment of statsbox
|
|
|
|
|
// child: const MyApp()
|
2024-07-05 15:36:29 +05:30
|
|
|
));
|
2024-05-24 12:32:19 +05:30
|
|
|
}
|
|
|
|
|
|
2024-05-24 19:32:53 +05:30
|
|
|
class MyApp extends StatefulWidget {
|
2024-05-24 12:32:19 +05:30
|
|
|
const MyApp({super.key});
|
|
|
|
|
|
|
|
|
|
@override
|
2024-05-24 19:32:53 +05:30
|
|
|
State<MyApp> createState() => _MyAppState();
|
2024-05-24 12:32:19 +05:30
|
|
|
}
|
|
|
|
|
|
2024-05-24 19:32:53 +05:30
|
|
|
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
|
2024-07-10 20:35:18 +05:30
|
|
|
SecureStorageService secureStorageService = SecureStorageService();
|
2024-05-27 18:00:40 +05:30
|
|
|
final NetworkConnectivity _networkConnectivity =
|
2024-05-28 16:35:33 +05:30
|
|
|
NetworkConnectivity(onStatusChange: (_) {});
|
2024-07-10 20:35:18 +05:30
|
|
|
String languageSelected = "";
|
2024-05-24 12:32:19 +05:30
|
|
|
@override
|
2024-05-24 19:32:53 +05:30
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
WidgetsBinding.instance.addObserver(this);
|
2024-07-10 20:35:18 +05:30
|
|
|
changeLanguage();
|
2024-05-24 19:32:53 +05:30
|
|
|
// Initialize the NetworkConnectivity instance.
|
|
|
|
|
_networkConnectivity.initialize();
|
|
|
|
|
}
|
2024-05-24 12:32:19 +05:30
|
|
|
|
2024-05-24 19:32:53 +05:30
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
WidgetsBinding.instance.removeObserver(this);
|
|
|
|
|
_networkConnectivity.dispose();
|
|
|
|
|
super.dispose();
|
2024-05-24 12:32:19 +05:30
|
|
|
}
|
|
|
|
|
|
2024-07-10 20:35:18 +05:30
|
|
|
Future changeLanguage() async {
|
|
|
|
|
languageSelected =
|
|
|
|
|
(await secureStorageService.read("languageSelected")) ?? "";
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-24 12:32:19 +05:30
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
2024-05-29 13:21:55 +05:30
|
|
|
return MultiBlocProvider(
|
|
|
|
|
providers: [
|
2024-07-10 20:35:18 +05:30
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) => LocalizationBloc(),
|
|
|
|
|
),
|
2024-05-29 13:21:55 +05:30
|
|
|
BlocProvider(
|
|
|
|
|
create: (context) => RadioBloc(),
|
2024-05-30 13:59:40 +05:30
|
|
|
),
|
2024-06-05 15:05:11 +05:30
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) => BottomNavigationBloc(),
|
2024-07-03 18:46:18 +05:30
|
|
|
),
|
2024-07-17 19:12:26 +05:30
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) =>
|
|
|
|
|
RegisterBloc(secureStorageService: secureStorageService),
|
|
|
|
|
),
|
|
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) => LoginBloc(secureStorageService: secureStorageService),
|
|
|
|
|
),
|
2024-07-03 18:46:18 +05:30
|
|
|
BlocProvider(
|
2024-07-18 18:51:01 +05:30
|
|
|
create: (_) => BiometricBloc(
|
|
|
|
|
LocalAuthentication(),
|
|
|
|
|
secureStorageService,
|
|
|
|
|
)..add(CheckBiometricEvent()),
|
2024-07-09 14:56:23 +05:30
|
|
|
),
|
|
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) => LocalizationBloc(),
|
|
|
|
|
),
|
2024-07-10 17:34:49 +05:30
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) => GetCountryBlock(),
|
|
|
|
|
),
|
2024-07-11 19:36:40 +05:30
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) => OTPBloc(),
|
|
|
|
|
),
|
2024-07-17 19:12:26 +05:30
|
|
|
BlocProvider(
|
|
|
|
|
create: (_) => RestorePasswordPhoneVerificationBloc(
|
|
|
|
|
secureStorageService: secureStorageService),
|
|
|
|
|
),
|
2024-05-29 13:21:55 +05:30
|
|
|
],
|
|
|
|
|
child: ScreenUtilInit(
|
2024-07-09 14:56:23 +05:30
|
|
|
builder: (BuildContext context, Widget? child) =>
|
|
|
|
|
BlocBuilder<LocalizationBloc, LocalizationState>(
|
|
|
|
|
builder: (context, state) {
|
2024-07-10 20:35:18 +05:30
|
|
|
changeLanguage().then(
|
|
|
|
|
(value) {
|
|
|
|
|
if (languageSelected.isEmpty) {
|
|
|
|
|
context
|
|
|
|
|
.read<LocalizationBloc>()
|
|
|
|
|
.add(const ChangeLanguage(Locale('en')));
|
2024-07-19 16:20:14 +05:30
|
|
|
Globalconst.languageSelected = "en";
|
2024-07-10 20:35:18 +05:30
|
|
|
} else if (languageSelected == "en") {
|
|
|
|
|
context
|
|
|
|
|
.read<LocalizationBloc>()
|
|
|
|
|
.add(const ChangeLanguage(Locale('en')));
|
2024-07-19 16:20:14 +05:30
|
|
|
Globalconst.languageSelected = "en";
|
2024-07-10 20:35:18 +05:30
|
|
|
} else {
|
|
|
|
|
context
|
|
|
|
|
.read<LocalizationBloc>()
|
|
|
|
|
.add(const ChangeLanguage(Locale('ar')));
|
2024-07-19 16:20:14 +05:30
|
|
|
Globalconst.languageSelected = "ar";
|
2024-07-10 20:35:18 +05:30
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
2024-07-09 14:56:23 +05:30
|
|
|
return MaterialApp.router(
|
|
|
|
|
title: 'Tanami Capital',
|
|
|
|
|
locale: state.locale,
|
|
|
|
|
supportedLocales: const [
|
|
|
|
|
Locale('en', ''),
|
|
|
|
|
Locale('ar', ''),
|
|
|
|
|
],
|
|
|
|
|
localizationsDelegates: const [
|
|
|
|
|
AppLocalizations.delegate,
|
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
|
],
|
|
|
|
|
localeResolutionCallback: (locale, supportedLocales) {
|
|
|
|
|
for (var supportedLocale in supportedLocales) {
|
|
|
|
|
if (supportedLocale.languageCode == locale?.languageCode) {
|
|
|
|
|
return supportedLocale;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return supportedLocales.first;
|
|
|
|
|
},
|
|
|
|
|
theme: ThemeData(
|
|
|
|
|
useMaterial3: true,
|
|
|
|
|
),
|
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
|
routerConfig: goRouter,
|
|
|
|
|
);
|
|
|
|
|
}),
|
2024-05-29 13:21:55 +05:30
|
|
|
designSize: const Size(390, 844),
|
2024-05-24 12:32:19 +05:30
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|