This commit is contained in:
venbaittech 2025-03-19 18:31:22 +05:30
parent 59955d3bdd
commit dfd569a068
11 changed files with 146 additions and 22 deletions

View File

@ -20,12 +20,12 @@ if (project.hasProperty('google-services.json')) {
def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) {
flutterVersionCode = "39"
flutterVersionCode = "40"
}
def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
flutterVersionName = "1.0.38"
flutterVersionName = "1.0.39"
}
def keystorePropertiesFile = rootProject.file("key.properties")

View File

@ -33,8 +33,10 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="fcsc-da580.web.app"/>
<data android:scheme="https" />
<data
android:scheme="https"
android:host="fcsc-a161c.web.app"
android:pathPrefix="/chartScreen"/>
</intent-filter>
<!-- <intent-filter >-->
<!-- <action android:name="android.intent.action.VIEW" />-->

View File

@ -63,6 +63,10 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>FirebaseDynamicLinksCustomDomains</key>
<array>
<string>https://fcsc-a161c.web.app</string>
</array>
<key>UIStatusBarHidden</key>
<false/>
</dict>

View File

@ -1,34 +1,84 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:pocketbase/pocketbase.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:uae_stat/config/api_config.dart';
import 'package:uae_stat/infrastructure/data/p_auth_repo.dart';
import 'package:uae_stat/domain/entities/session_entity.dart';
import 'package:uae_stat/presentation/components/indicators/locale_provider.dart';
import 'package:url_launcher/url_launcher.dart';
class SessionCheckScreen extends StatefulWidget {
class SessionCheckScreen extends ConsumerStatefulWidget {
@override
_SessionCheckScreenState createState() => _SessionCheckScreenState();
}
class _SessionCheckScreenState extends State<SessionCheckScreen> {
class _SessionCheckScreenState extends ConsumerState<SessionCheckScreen> {
final pb = PocketBase(apiUrl);
final PAuthRepo _authRepo = PAuthRepo();
dynamic preferredLanguage;
bool _isLoading = true;
String get playStoreUrl => "https://play.google.com/store/apps/details?id=ae.gov.fcsc.frontend";
String get playStoreUrl =>
"https://play.google.com/store/apps/details?id=ae.gov.fcsc.frontend";
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) async {
await userDetails();
_checkSession();
});
}
Future<void> userDetails() async {
try {
final prefs = await SharedPreferences.getInstance();
final userId = prefs.getString('userId');
// Authenticate admin d
final adminAuth = await pb.admins.authWithPassword(
'pb@venbainfotech.com',
'pb@venbainfotech.com',
);
final String adminToken = adminAuth.token;
print('adminToken: $adminToken');
// Fetch user details
final userDetailsResponse = await pb.collection('users').getOne(
userId!,
headers: {
'Authorization': 'Bearer $adminToken',
},
);
print('userDetailsLogin: $userDetailsResponse');
preferredLanguage = userDetailsResponse.data['language'] ?? '';
print('preferredLanguage login $preferredLanguage');
// **Set Default Locale in Provider**
if (preferredLanguage == 'ar') {
ref.read(localeProvider.notifier).setLocale(const Locale('ar'));
} else {
ref.read(localeProvider.notifier).setLocale(const Locale('en'));
}
} catch (e) {
print('Error fetching user details: $e');
rethrow;
}
}
Future<void> _checkSession() async {
await Future.delayed(Duration(seconds: 2)); // Optional splash delay
final SessionEntity? session = await _authRepo.fetchLocallyStored();
final GoRouterState state = GoRouterState.of(context);
final String? intendedPath = state.uri.toString().isNotEmpty && state.uri.path != '/'
? state.uri.path
: null;
final String? intendedPath =
state.uri.toString().isNotEmpty && state.uri.path != '/'
? state.uri.path
: null;
print('fetchLocallyStored $session');
print('navigating to intended path: $intendedPath');
@ -53,7 +103,9 @@ class _SessionCheckScreenState extends State<SessionCheckScreen> {
// User is not logged in, redirect to login with intended path if present
print('session expired, redirecting to login');
if (mounted) {
context.go('/login', extra: intendedPath != null ? {'intendedPath': intendedPath} : null);
context.go('/login',
extra:
intendedPath != null ? {'intendedPath': intendedPath} : null);
}
}
} else {
@ -63,6 +115,9 @@ class _SessionCheckScreenState extends State<SessionCheckScreen> {
_redirectToPlayStore();
}
}
setState(() {
_isLoading = false; // Stop showing splash
});
}
Future<void> _redirectToPlayStore() async {
@ -75,10 +130,30 @@ class _SessionCheckScreenState extends State<SessionCheckScreen> {
@override
Widget build(BuildContext context) {
return SizedBox.shrink();
return _isLoading
? SplashScreen() // Show splash while loading
: SizedBox.shrink();
}
}
class SplashScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset('assets/images/logo.png', width: 150), // App Logo
// SizedBox(height: 20),
// CircularProgressIndicator(), // Loading indicator
],
),
),
);
}
}
// import 'dart:math';
//
@ -296,4 +371,4 @@ class _SessionCheckScreenState extends State<SessionCheckScreen> {
// // ),
// // );
// // }
// // }
// // }

View File

@ -262,7 +262,7 @@ class _UaenumberWidgetState extends ConsumerState<uaenumberWidget> {
// ),
border: InputBorder.none,
contentPadding:
EdgeInsets.symmetric(vertical: 0.5, horizontal: 18.0),
EdgeInsets.symmetric(vertical: 9, horizontal: 18.0),
),
),
),

View File

@ -47,6 +47,29 @@ class ChartWidget extends StatelessWidget {
],
};
final Map<String, List<Color>> colorMapForFour = {
"ECONOMY": [
Color(0xFF648CBA),
Color(0xFF90B0D5),
Color(0xFF98BCE5),
Color(0xFFA7B5C5),
Color(0xFFBED3EC),
],
"SOCIAL": [
Color(0xFFD9BB99),
Color(0xFF87766E),
Color(0xFFC6A885),
Color(0xFFA28565),
Color(0xFFBFB29B),
],
"ENVIRONMENT": [
Color(0xFF376C79),
Color(0xFF578D9C),
Color(0xFF7DAFBC),
Color(0xFF86C7D9),
],
};
final Map<String, List<Color>> colorMapForThree = {
"ECONOMY": [
Color(0xFF648CBA),
@ -116,6 +139,17 @@ class ChartWidget extends StatelessWidget {
return colorMapForThree[key] ?? [Colors.grey];
}
List<Color> get uniqueColorsForFour {
final Map<String, String> translations = {
'اقتصاد': 'ECONOMY',
'اجتماعي': 'SOCIAL',
'بيئة': 'ENVIRONMENT',
};
String key = translations[chartHeader] ?? chartHeader;
return colorMapForFour[key] ?? [Colors.grey];
}
String capitalizeAndSplit(String input) {
return input
.split('_')
@ -1009,6 +1043,7 @@ class ChartWidget extends StatelessWidget {
titlesData: titlesData1(uniqueXValuesProcessed),
borderData: borderData(),
lineBarsData: lineBars,
// minY: 10000,
// minX: uniqueXValues.reduce((a, b) => a < b ? a : b),
// maxX: uniqueXValues.reduce((a, b) => a > b ? a : b),
// minX: uniqueXValuesProcessed.reduce((a, b) => a < b ? a : b),
@ -2391,7 +2426,7 @@ class ChartWidget extends StatelessWidget {
width: 120,
child: Text(
title,
textAlign: TextAlign.end,
textAlign: TextAlign.right,
style: const TextStyle(fontSize: 12),
softWrap: true,
maxLines: 2,
@ -2979,7 +3014,7 @@ class ChartWidget extends StatelessWidget {
// print("Bottomtiles");
// print(value);
return Padding(
padding: const EdgeInsets.only(top: 4, left: 20.0),
padding: const EdgeInsets.only(top: 10, left: 20.0),
child: SizedBox(
width: 40,
child: Transform.rotate(
@ -3320,6 +3355,10 @@ class ChartWidget extends StatelessWidget {
barColor =
uniqueColorsForThree[colorIndex % uniqueColorsForThree.length];
colorIndex++;
} else if (chartData['dataset'] == 'oil_and_gas') {
barColor =
uniqueColorsForFour[colorIndex % uniqueColorsForFour.length];
colorIndex++;
} else {
barColor = uniqueColors[colorIndex % uniqueColors.length];
colorIndex++;

View File

@ -491,6 +491,11 @@ class _EditProfileState extends ConsumerState<EditProfile> {
ref.listen<Locale?>(localeProvider, (previous, next) async {
final localeCode = next?.languageCode ?? 'en'; // Default to 'en' if null
await _userService.updateLanguage(localeCode);
setState(() {
isLoader = true;
});
await _fetchUserData();
});
return PopScope(

View File

@ -416,7 +416,7 @@ class _ManageUserRouterState extends ConsumerState<ManageUserRouter> {
// ),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
vertical: 0.5, horizontal: 18.0),
vertical: 9, horizontal: 18.0),
),
onChanged: filterUsers,
),

View File

@ -109,11 +109,10 @@ class _NotificationPageState extends ConsumerState<NotificationPage> {
jsonDecode(response.body); // Decode JSON
if (jsonResponse['message'] == 'Success') {
setState(() async {
setState(() {
notifications = List<Map<String, dynamic>>.from(
jsonResponse['data']); // Assign decoded data
print('notifications $notifications');
await Future.delayed(Duration(seconds: 5));
isLoading = false;
});
} else {

View File

@ -5,7 +5,7 @@
"namespace": "android_app",
"package_name": "ae.gov.fcsc.frontend",
"sha256_cert_fingerprints": [
"3D:BB:9E:B6:3E:80:50:6F:52:EB:73:B8:AD:F9:5F:5A:0A:05:BE:E4:CA:D1:AF:F7:26:2C:56:3F:35:1D:4E:81"
"E0:B4:6F:B9:8B:96:66:5B:EC:14:98:53:07:01:D4:DF:39:24:E8:1F:CD:A2:9E:E4:77:66:E0:B4:5B:C2:E0:94"
]
}
}

View File

@ -1,7 +1,7 @@
name: uae_stat
description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness."
publish_to: "none"
version: 1.0.38+39
version: 1.0.39+40
environment:
sdk: ">=3.2.3 <4.0.0"