code base setup phase 1

This commit is contained in:
jayesh
2024-05-24 19:32:53 +05:30
parent 715d0c8ed5
commit 8c18c0b5f7
17 changed files with 1386 additions and 180 deletions

View File

@@ -49,6 +49,7 @@ android {
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}
buildTypes {
@@ -64,4 +65,6 @@ flutter {
source '../..'
}
dependencies {}
dependencies {
implementation 'androidx.multidex:multidex:2.0.1'
}

View File

@@ -1,6 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tanami_app">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission
android:name="android.permission.USE_BIOMETRIC"/>
<application
android:label="tanami_app"
android:label="Tanami"
android:requestLegacyExternalStorage="true"
android:usesCleartextTraffic="true"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
<activity

View File

@@ -0,0 +1,14 @@
/* CREATED BY - JAYESH JAIN
DATE - 24-05-2024
*/
class RouteName {
//Splash
static const String splashScreen = '/';
//Login
static const String loginScreen = 'loginScreen';
//No Internet
static const String noInternetScreen = 'noInternet';
}

View File

@@ -0,0 +1,49 @@
// router.dart
import 'package:go_router/go_router.dart';
import 'package:tanami_app/core/routes/route_name.dart';
import '../../features/login/presentation/pages/login_screen.dart';
import '../../features/splash/presentation/pages/splash_screen.dart';
/* CREATED BY - JAYESH JAIN
DATE - 24-05-2024
*/
// The GoRouter instance used to navigate between screens.
final goRouter = GoRouter(
initialLocation: '/',
//errorBuilder: (context, state) => ErrorScreen(state.error),
routes: [
GoRoute(
name: "splash",
path: RouteName.splashScreen,
builder: (context, state) {
return const SplashScreen();
},
// redirect: (context, state) {
// if (true) {
// return "/login";
// }
// return "/";
// },
routes: [
GoRoute(
name: RouteName.loginScreen,
path: RouteName.loginScreen,
builder: (context, state) {
return const LoginScreen();
},
),
]),
// GoRoute(
// path: '/profile/:userId',
// builder: (context, state) {
// final userId = state.params['userId'];
// return MaterialPage(child: ProfilePage(userId: userId));
// },
// ),
// Add more routes as needed
],
);

View File

@@ -0,0 +1,54 @@
// network_connectivity.dart
import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:tanami_app/core/routes/route_name.dart';
import 'package:tanami_app/core/routes/routes.dart';
/* CREATED BY - JAYESH JAIN
DATE - 24-05-2024
*/
/// Class that handles network connectivity checks and updates.
class NetworkConnectivity {
final Connectivity _connectivity = Connectivity();
late StreamSubscription<List<ConnectivityResult>> _subscription;
final Function(String) onStatusChange;
NetworkConnectivity({required this.onStatusChange});
/// Initializes the network connectivity checks and updates.
void initialize() {
_subscription = _connectivity.onConnectivityChanged
.listen((List<ConnectivityResult> result) {
String status = result.toString();
onStatusChange(status);
if (result[0] == ConnectivityResult.wifi ||
result[0] == ConnectivityResult.mobile) {
goRouter.pop(true);
} else {
goRouter.go(RouteName.noInternetScreen);
}
});
checkInternet();
}
/// Checks the current network connectivity status.
Future<void> checkInternet() async {
final connectivityResult = await _connectivity.checkConnectivity();
if (connectivityResult[0] != ConnectivityResult.none) {
onStatusChange(connectivityResult.toString());
} else {
onStatusChange(connectivityResult.toString());
goRouter.go(RouteName.noInternetScreen);
}
}
/// Cancels the StreamSubscription that listens for connectivity changes.
void dispose() {
_subscription.cancel();
}
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class LoginScreen extends StatelessWidget {
const LoginScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold();
}
}

View File

@@ -0,0 +1,10 @@
import 'package:flutter/material.dart';
class SplashScreen extends StatelessWidget {
const SplashScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold();
}
}

View File

@@ -1,125 +1,63 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
void main() {
runApp(const MyApp());
import 'core/routes/routes.dart';
import 'core/utils/connectivity/network_connectivity.dart';
/* CREATED BY - JAYESH JAIN
DATE - 24-05-2024
*/
/// The main function that runs the application.
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
// Set the preferred orientations of the device.
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
]).then((value) =>
runApp(MultiBlocProvider(providers: [], child: const MyApp())));
}
class MyApp extends StatelessWidget {
class MyApp extends StatefulWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// TRY THIS: Try running your application with "flutter run". You'll see
// the application has a purple toolbar. Then, without quitting the app,
// try changing the seedColor in the colorScheme below to Colors.green
// and then invoke "hot reload" (save your changes or press the "hot
// reload" button in a Flutter-supported IDE, or press "r" if you used
// the command line to start the app).
//
// Notice that the counter didn't reset back to zero; the application
// state is not lost during the reload. To reset the state, use hot
// restart instead.
//
// This works for code too, not just values: Most code changes can be
// tested with just a hot reload.
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> with WidgetsBindingObserver {
late NetworkConnectivity _networkConnectivity;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
// Initialize the NetworkConnectivity instance.
_networkConnectivity.initialize();
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
// This call to setState tells the Flutter framework that something has
// changed in this State, which causes it to rerun the build method below
// so that the display can reflect the updated values. If we changed
// _counter without calling setState(), then the build method would not be
// called again, and so nothing would appear to happen.
_counter++;
});
void dispose() {
WidgetsBinding.instance.removeObserver(this);
_networkConnectivity.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// This method is rerun every time setState is called, for instance as done
// by the _incrementCounter method above.
//
// The Flutter framework has been optimized to make rerunning build methods
// fast, so that you can just rebuild anything that needs updating rather
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Center(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child: Column(
// Column is also a layout widget. It takes a list of children and
// arranges them vertically. By default, it sizes itself to fit its
// children horizontally, and tries to be as tall as its parent.
//
// Column has various properties to control how it sizes itself and
// how it positions its children. Here we use mainAxisAlignment to
// center the children vertically; the main axis here is the vertical
// axis because Columns are vertical (the cross axis would be
// horizontal).
//
// TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
// action in the IDE, or press "p" in the console), to see the
// wireframe for each widget.
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
return ScreenUtilInit(
builder: (BuildContext context, Widget? child) => MaterialApp.router(
title: 'Tanami Capital',
theme: ThemeData(
useMaterial3: true,
),
debugShowCheckedModeBanner: false,
routerConfig: goRouter,
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
), // This trailing comma makes auto-formatting nicer for build methods.
designSize: const Size(390, 844),
);
}
}

View File

@@ -0,0 +1,3 @@
class ApiEndpoints {
static const base = ""; //App Base url
}

View File

@@ -0,0 +1,54 @@
// common_api.dart
import 'package:dio/dio.dart';
class NetworkApiService {
final Dio _dio = Dio();
// Common function for GET requests
Future<Response> get(String endpoint,
{Map<String, dynamic>? queryParameters}) async {
try {
return await _dio.get(endpoint, queryParameters: queryParameters);
} catch (e) {
throw _handleError(e);
}
}
// Common function for POST requests
Future<Response> post(String endpoint, dynamic data) async {
try {
return await _dio.post(endpoint, data: data);
} catch (e) {
throw _handleError(e);
}
}
// Common function for PUT requests
Future<Response> put(String endpoint, dynamic data) async {
try {
return await _dio.put(endpoint, data: data);
} catch (e) {
throw _handleError(e);
}
}
// Common function for DELETE requests
Future<Response> delete(String endpoint) async {
try {
return await _dio.delete(endpoint);
} catch (e) {
throw _handleError(e);
}
}
// Handle Dio errors
dynamic _handleError(dynamic e) {
if (e is DioException) {
// Handle Dio specific errors (e.g., DioErrorType.connectTimeout, DioErrorType.response)
return e.message; // Or return a custom error message
} else {
return 'An error occurred'; // Generic error message for other types of errors
}
}
}

View File

@@ -6,6 +6,14 @@
#include "generated_plugin_registrant.h"
#include <flutter_secure_storage_linux/flutter_secure_storage_linux_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) flutter_secure_storage_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterSecureStorageLinuxPlugin");
flutter_secure_storage_linux_plugin_register_with_registrar(flutter_secure_storage_linux_registrar);
g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin");
url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar);
}

View File

@@ -3,6 +3,8 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
flutter_secure_storage_linux
url_launcher_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST

View File

@@ -5,6 +5,24 @@
import FlutterMacOS
import Foundation
import connectivity_plus
import device_info_plus
import firebase_core
import flutter_secure_storage_macos
import package_info_plus
import path_provider_foundation
import shared_preferences_foundation
import sqflite
import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin"))
FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
SqflitePlugin.register(with: registry.registrar(forPlugin: "SqflitePlugin"))
UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin"))
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,90 +1,79 @@
name: tanami_app
description: "A new Flutter project."
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix.
publish_to: "none"
version: 1.0.0+1
environment:
sdk: '>=3.3.4 <4.0.0'
sdk: ">=3.3.4 <4.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
# Icons
cupertino_icons: ^1.0.6
# Image and SVG Handling
cached_network_image: ^3.3.1
flutter_svg: ^2.0.10+1
# Network
dio: ^5.4.3+1
connectivity_plus: ^6.0.3
# State Management
bloc: ^8.1.4
flutter_bloc: ^8.1.5
# Permissions
permission_handler: ^11.3.1
# Device Related
device_info_plus: ^10.1.0
intl: ^0.19.0
path: ^1.9.0
upgrader: ^10.3.0
google_fonts: ^6.2.1
# Async
async: ^2.11.0
# Firebase
firebase_core: ^2.31.1
# Animation
lottie: ^3.1.2
shimmer: ^3.0.0
# Device Responsiveness
gap: ^3.0.1
auto_size_text: ^3.0.0
flutter_screenutil: ^5.9.1
# Security
shared_preferences: ^2.2.3
flutter_secure_storage: ^9.2.2
local_auth: ^2.2.0
crypto: ^3.0.3
flutter_jailbreak_detection: ^1.10.0
secure_application: ^4.0.1
# Toast Messages
toastification: ^2.0.0
#Routes
go_router: ^14.1.3
# Json Annotation
json_serializable: ^6.8.0
dev_dependencies:
flutter_test:
sdk: flutter
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^3.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

View File

@@ -6,6 +6,27 @@
#include "generated_plugin_registrant.h"
#include <connectivity_plus/connectivity_plus_windows_plugin.h>
#include <firebase_core/firebase_core_plugin_c_api.h>
#include <flutter_secure_storage_windows/flutter_secure_storage_windows_plugin.h>
#include <local_auth_windows/local_auth_plugin.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <secure_application/secure_application_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
ConnectivityPlusWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin"));
FirebaseCorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
FlutterSecureStorageWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FlutterSecureStorageWindowsPlugin"));
LocalAuthPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("LocalAuthPlugin"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
SecureApplicationPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SecureApplicationPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherWindows"));
}

View File

@@ -3,6 +3,13 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
connectivity_plus
firebase_core
flutter_secure_storage_windows
local_auth_windows
permission_handler_windows
secure_application
url_launcher_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST