Commit ee178d55 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

09-07-2025 By Sai Srinivas

Network and Finance Module issue and Back
parent 2ade5aad
import 'dart:io'; import 'dart:io';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:generp/Utils/commonWidgets.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../Notifiers/splashVersionNotifier.dart'; import '../Notifiers/splashVersionNotifier.dart';
import '../Utils/commonServices.dart';
class Splash extends StatefulWidget { class Splash extends StatefulWidget {
const Splash({super.key}); const Splash({super.key});
@override @override
State<Splash> createState() => _SplashState(); State<Splash> createState() => _SplashState();
} }
// class _SplashState extends State<Splash> {
// late Image splashImage;
// Map _source = {ConnectivityResult.none: false};
// final MyConnectivity _connectivity = MyConnectivity.instance;
//
// @override
// void initState() {
// super.initState();
// _connectivity.initialise();
// _connectivity.myStream.listen((source) {
// setState(() {
// _source = source;
// String newConnection;
// switch (_source.keys.toList()[0]) {
// case ConnectivityResult.mobile:
// case ConnectivityResult.wifi:
// newConnection = 'Online';
// break;
// case ConnectivityResult.none:
// default:
// newConnection = 'Offline';
// }
//
// // Reload the page when transitioning from Offline to Online
// if (connection == 'Offline' && newConnection == 'Online') {
// _reloadPage();
// }
// connection = newConnection;
// });
// });
//
// splashImage = Image.asset("assets/images/ic_splash.jpg");
// WidgetsBinding.instance.addPostFrameCallback((_) {
// requestPermissions();
// final splashProvider = Provider.of<SplashVersionNotifier>(
// context,
// listen: false,
// );
// splashProvider.initPackageInfo();
// splashProvider.handleVersionCheck(context);
// });
// }
//
// // Method to reload the page
// void _reloadPage() {
// // Reset any necessary state or re-run initialization logic
// final splashProvider = Provider.of<SplashVersionNotifier>(
// context,
// listen: false,
// );
// splashProvider.initPackageInfo();
// splashProvider.handleVersionCheck(context);
// }
//
// @override
// void dispose() {
// super.dispose();
// _connectivity.disposeStream();
// }
//
// void requestPermissions() async {
// await getCameraPermissions();
// await getStoragePermission();
// await getLocationPermissions();
// }
//
// Future<void> getStoragePermission() async {
// if (await Permission.manageExternalStorage.request().isGranted) {
// print("Storage");
// setState(() {});
// } else if (await Permission.storage.request().isPermanentlyDenied) {
// print("Storage");
// await openAppSettings();
// } else if (await Permission.storage.request().isDenied) {
// print("Storage");
// setState(() {});
// }
// }
//
// Future<void> getCameraPermissions() async {
// if (await Permission.camera.request().isGranted) {
// print("Camera1");
// setState(() {});
// } else if (await Permission.camera.request().isPermanentlyDenied) {
// print("Camera2");
// if (Platform.isAndroid) {
// await openAppSettings();
// } else if (Platform.isIOS) {
// setState(() {});
// }
// } else if (await Permission.camera.request().isDenied) {
// print("Camera3");
// setState(() {});
// }
// }
//
// Future<void> getLocationPermissions() async {
// if (await Permission.location.request().isGranted) {
// print("Location1a");
// setState(() {});
// } else if (await Permission.location.request().isPermanentlyDenied) {
// print("Location1b");
// if (Platform.isAndroid) {
// await openAppSettings();
// } else if (Platform.isIOS) {
// // await AppSettings.openAppSettings(type: AppSettingsType.location);
// }
// } else if (await Permission.location.request().isDenied) {
// print("Location1c");
// setState(() {});
// }
//
// if (await Permission.locationAlways.request().isGranted) {
// print("Location2a");
// setState(() {});
// } else if (await Permission.locationAlways.request().isPermanentlyDenied) {
// print("Location2b");
// if (Platform.isAndroid) {
// await openAppSettings();
// } else if (Platform.isIOS) {
// // await AppSettings.openAppSettings(type: AppSettingsType.location);
// }
// } else if (await Permission.locationAlways.request().isDenied) {
// print("Location2c");
// setState(() {});
// }
//
// if (await Permission.locationWhenInUse.request().isGranted) {
// print("Location3a");
// setState(() {});
// } else if (await Permission.locationWhenInUse.request().isPermanentlyDenied) {
// print("Location3b");
// if (Platform.isAndroid) {
// await openAppSettings();
// } else if (Platform.isIOS) {
// // await AppSettings.openAppSettings(type: AppSettingsType.location);
// }
// } else if (await Permission.locationWhenInUse.request().isDenied) {
// print("Location3c");
// setState(() {});
// }
// }
//
// Future<void> getNotificationsPermissions() async {
// if (await Permission.notification.request().isGranted) {
// setState(() {});
// } else if (await Permission.notification.request().isPermanentlyDenied) {
// await openAppSettings();
// } else if (await Permission.notification.request().isDenied) {
// setState(() {});
// }
// }
//
// @override
// void didChangeDependencies() {
// super.didChangeDependencies();
// precacheImage(splashImage.image, context);
// }
//
// @override
// Widget build(BuildContext context) {
// return (connection == 'Online')
// ? SafeArea(
// top: false,
// bottom: Platform.isIOS ? false : true,
// child: Scaffold(
// resizeToAvoidBottomInset: true,
// body: Consumer<SplashVersionNotifier>(
// builder: (context, value, child) {
// return Container(
// alignment: Alignment.center,
// child: Container(
// alignment: Alignment.center,
// height: 300,
// width: 300,
// child: splashImage,
// ),
// );
// },
// ),
// ),
// )
// : NoNetwork(context);
// }
// }
class _SplashState extends State<Splash> { class _SplashState extends State<Splash> {
late Image splashImage; late Image splashImage;
Map _source = {ConnectivityResult.mobile: true};
final MyConnectivity _connectivity = MyConnectivity.instance;
@override @override
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
_connectivity.initialise();
_connectivity.myStream.listen((source) {
setState(() => _source = source);
});
splashImage = Image.asset("assets/images/ic_splash.jpg"); splashImage = Image.asset("assets/images/ic_splash.jpg");
WidgetsBinding.instance.addPostFrameCallback((_) { WidgetsBinding.instance.addPostFrameCallback((_) {
requestPermissions(); requestPermissions();
...@@ -30,9 +225,14 @@ class _SplashState extends State<Splash> { ...@@ -30,9 +225,14 @@ class _SplashState extends State<Splash> {
); );
spalshProvider.initPackageInfo(); spalshProvider.initPackageInfo();
spalshProvider.handleVersionCheck(context); spalshProvider.handleVersionCheck(context);
},); });
}
@override
void dispose() {
// TODO: implement dispose
super.dispose();
_connectivity.disposeStream();
} }
void requestPermissions() async { void requestPermissions() async {
...@@ -139,25 +339,38 @@ class _SplashState extends State<Splash> { ...@@ -139,25 +339,38 @@ class _SplashState extends State<Splash> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SafeArea( switch (_source.keys.toList()[0]) {
top: false, case ConnectivityResult.mobile:
bottom: Platform.isIOS?false:true, connection = 'Online';
child: Scaffold( break;
resizeToAvoidBottomInset: true, case ConnectivityResult.wifi:
body: Consumer<SplashVersionNotifier>( connection = 'Online';
builder: (context, value, child) { break;
return Container( case ConnectivityResult.none:
alignment: Alignment.center, default:
child: Container( connection = 'Offline';
alignment: Alignment.center, }
height: 300, return (connection == 'Online')
width: 300, ? SafeArea(
child: splashImage, top: false,
), bottom: Platform.isIOS ? false : true,
); child: Scaffold(
}, resizeToAvoidBottomInset: true,
), body: Consumer<SplashVersionNotifier>(
), builder: (context, value, child) {
); return Container(
alignment: Alignment.center,
child: Container(
alignment: Alignment.center,
height: 300,
width: 300,
child: splashImage,
),
);
},
),
),
)
: NoNetwork(context);
} }
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import FlutterMacOS import FlutterMacOS
import Foundation import Foundation
import app_settings
import connectivity_plus import connectivity_plus
import device_info_plus import device_info_plus
import file_selector_macos import file_selector_macos
...@@ -26,6 +27,7 @@ import url_launcher_macos ...@@ -26,6 +27,7 @@ import url_launcher_macos
import webview_flutter_wkwebview import webview_flutter_wkwebview
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
AppSettingsPlugin.register(with: registry.registrar(forPlugin: "AppSettingsPlugin"))
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin")) ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
......
...@@ -17,6 +17,14 @@ packages: ...@@ -17,6 +17,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.0" version: "0.4.0"
app_settings:
dependency: "direct main"
description:
name: app_settings
sha256: "3e46c561441e5820d3a25339bf8b51b9e45a5f686873851a20c257a530917795"
url: "https://pub.dev"
source: hosted
version: "6.1.1"
archive: archive:
dependency: transitive dependency: transitive
description: description:
...@@ -37,10 +45,10 @@ packages: ...@@ -37,10 +45,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
sha256: "758e6d74e971c3e5aceb4110bfd6698efc7f501675bcfe0c775459a8140750eb" sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.13.0" version: "2.12.0"
auto_size_text: auto_size_text:
dependency: "direct main" dependency: "direct main"
description: description:
...@@ -293,10 +301,10 @@ packages: ...@@ -293,10 +301,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: fake_async name: fake_async
sha256: "5368f224a74523e8d2e7399ea1638b37aecfca824a3cc4dfdf77bf1fa905ac44" sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.3.3" version: "1.3.2"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
...@@ -940,26 +948,26 @@ packages: ...@@ -940,26 +948,26 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker name: leak_tracker
sha256: "8dcda04c3fc16c14f48a7bb586d4be1f0d1572731b6d81d51772ef47c02081e0" sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "11.0.1" version: "10.0.8"
leak_tracker_flutter_testing: leak_tracker_flutter_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_flutter_testing name: leak_tracker_flutter_testing
sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.10" version: "3.0.9"
leak_tracker_testing: leak_tracker_testing:
dependency: transitive dependency: transitive
description: description:
name: leak_tracker_testing name: leak_tracker_testing
sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" version: "3.0.1"
lints: lints:
dependency: transitive dependency: transitive
description: description:
...@@ -1665,10 +1673,10 @@ packages: ...@@ -1665,10 +1673,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: vm_service name: vm_service
sha256: ddfa8d30d89985b96407efce8acbdd124701f96741f2d981ca860662f1c0dc02 sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "15.0.0" version: "14.3.1"
web: web:
dependency: transitive dependency: transitive
description: description:
......
...@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev ...@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # 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 # 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. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.92+96 version: 1.0.93+97
environment: environment:
sdk: ^3.7.2 sdk: ^3.7.2
...@@ -81,6 +81,7 @@ dependencies: ...@@ -81,6 +81,7 @@ dependencies:
tuple: ^2.0.2 tuple: ^2.0.2
collection: ^1.19.1 collection: ^1.19.1
auto_size_text: ^3.0.0 auto_size_text: ^3.0.0
app_settings: ^6.1.1
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment