chart changes

This commit is contained in:
venbaittech 2025-02-24 09:02:05 +05:30
parent a1993712ac
commit f054dd83d5
5 changed files with 858 additions and 570 deletions

View File

@ -15,12 +15,12 @@ if (localPropertiesFile.exists()) {
def flutterVersionCode = localProperties.getProperty("flutter.versionCode") def flutterVersionCode = localProperties.getProperty("flutter.versionCode")
if (flutterVersionCode == null) { if (flutterVersionCode == null) {
flutterVersionCode = "25" flutterVersionCode = "26"
} }
def flutterVersionName = localProperties.getProperty("flutter.versionName") def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) { if (flutterVersionName == null) {
flutterVersionName = "1.0.24" flutterVersionName = "1.0.25"
} }
def keystorePropertiesFile = rootProject.file("key.properties") def keystorePropertiesFile = rootProject.file("key.properties")

View File

@ -155,17 +155,17 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
}); });
// ToastUtil.showSuccessToast("Added to Bookmark."); // ToastUtil.showSuccessToast("Added to Bookmark.");
// ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context).showSnackBar(
// SnackBar( SnackBar(
// content: Text( content: Text(
// AppLocalizations.of(context)!.added_to_Bookmark, AppLocalizations.of(context)!.added_to_Bookmark,
// style: TextStyle( style: TextStyle(
// color: Color(0xFF2F692C), fontWeight: FontWeight.w600), color: Color(0xFF2F692C), fontWeight: FontWeight.w600),
// ), ),
// backgroundColor: Color(0xFFD6E9C6), backgroundColor: Color(0xFFD6E9C6),
// duration: Duration(seconds: 2), duration: Duration(seconds: 2),
// ), ),
// ); );
print("Bookmark added: ${response.id}"); print("Bookmark added: ${response.id}");
} catch (e) { } catch (e) {
@ -1346,9 +1346,10 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
// If chartFilteredData is empty, print the message // If chartFilteredData is empty, print the message
if (chartFilteredData.isEmpty) { if (chartFilteredData.isEmpty) {
if (kDebugMode) { if (kDebugMode) {
print("Selected year: ${selectedFilters.firstWhere((f) => f['filter_key'] == 'TIME_PERIOD', print(
orElse: () => {'filter_data': ['Unknown']})['filter_data']} - No data for chart: : $chartHeading"); "Selected year: ${selectedFilters.firstWhere((f) => f['filter_key'] == 'TIME_PERIOD', orElse: () => {
'filter_data': ['Unknown']
})['filter_data']} - No data for chart: : $chartHeading");
} }
// Add the complete chart data to the filteredData list // Add the complete chart data to the filteredData list
@ -1371,7 +1372,6 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
addedChartIds addedChartIds
.add(chart['chart_heading']); // Track by a unique identifier .add(chart['chart_heading']); // Track by a unique identifier
} }
} }
// List filteredCardData = []; // List filteredCardData = [];
@ -1800,19 +1800,18 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
print("FilteringDAtss START1 - $filterData"); print("FilteringDAtss START1 - $filterData");
print('TABId1 - $tabId'); print('TABId1 - $tabId');
for (var item in filterData) { // for (var item in filterData) {
if (item['filter_key'] == 'TIME_PERIOD') { // if (item['filter_key'] == 'TIME_PERIOD') {
// Convert the values to integers, sort them, and convert back to strings // // Convert the values to integers, sort them, and convert back to strings
List<int> timePeriodData = item['filter_data'] // List<int> timePeriodData = item['filter_data']
.map<int>((e) => int.parse(e.toString())) // Convert to int // .map<int>((e) => int.parse(e.toString())) // Convert to int
.toList(); // .toList();
timePeriodData.sort((a, b) => a.compareTo(b)); // Sort numerically // timePeriodData.sort((a, b) => a.compareTo(b)); // Sort numerically
//
// Optionally, convert sorted integers back to strings if necessary // // Optionally, convert sorted integers back to strings if necessary
item['filter_data'] = timePeriodData.map((e) => e.toString()).toList(); // item['filter_data'] = timePeriodData.map((e) => e.toString()).toList();
} // }
} // }
print('TABId - $tabId'); print('TABId - $tabId');
@ -1931,11 +1930,33 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
double myheight = MediaQuery.of(context).size.height; double myheight = MediaQuery.of(context).size.height;
double mywidth = MediaQuery.of(context).size.width; double mywidth = MediaQuery.of(context).size.width;
int crossAxisCount = cardData.isNotEmpty ? (cardData.length / 2).ceil().clamp(1, 2) : 1; int crossAxisCount =
cardData.isNotEmpty ? (cardData.length / 2).ceil().clamp(1, 2) : 1;
final color = final color =
Color(int.parse(widget.bgColor.replaceFirst('0x', ''), radix: 16)); Color(int.parse(widget.bgColor.replaceFirst('0x', ''), radix: 16));
// Color bodyColor = Color(
// int.parse(
// (chartScreenData['body_color'] ?? '#898C81')
// .replaceFirst('#', '0xFF'), // Correct format for ARGB in Flutter
// radix: 16,
// ),
// );
//
//
final bodyColor = Color(
int.parse(
(chartScreenData['body_color'] ?? '#898C81').replaceFirst('#', '0xff'),
),
);
print('ChartScrnBodyColor');
print(chartScreenData['body_color']);
print(
Color(int.parse((chartScreenData['body_color'] ?? '#898C81')
.replaceFirst('#', '0xff'))),
);
return PopScope( return PopScope(
canPop: false, // Allow back navigation only if not login screen canPop: false, // Allow back navigation only if not login screen
onPopInvokedWithResult: (didPop, result) { onPopInvokedWithResult: (didPop, result) {
@ -2003,7 +2024,6 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
fontWeight: FontWeight.w400, fontWeight: FontWeight.w400,
fontFamily: 'Roboto'), fontFamily: 'Roboto'),
), ),
], ],
), ),
)), )),
@ -2089,12 +2109,16 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
onTap: () async { onTap: () async {
try { try {
// Define share content // Define share content
final String shareLink = 'https://fcsc-da580.web.app'; // Your link final String shareLink =
final String shareText = 'Check this out!'; 'https://fcsc-da580.web.app'; // Your link
final String svgAssetPath = 'assets/logos/fcsc.png'; // Your SVG asset path final String shareText =
'Check this out!';
final String svgAssetPath =
'assets/logos/fcsc.png'; // Your SVG asset path
// Create a controller to capture the SVG as an image // Create a controller to capture the SVG as an image
final screenshotController = ScreenshotController(); final screenshotController =
ScreenshotController();
// Render the SVG off-screen and capture it as PNG // Render the SVG off-screen and capture it as PNG
final svgWidget = SvgPicture.asset( final svgWidget = SvgPicture.asset(
@ -2104,19 +2128,24 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
); );
// Capture the SVG as a PNG // Capture the SVG as a PNG
final Uint8List? capturedImage = await screenshotController.captureFromWidget( final Uint8List? capturedImage =
await screenshotController
.captureFromWidget(
Material( Material(
child: svgWidget, child: svgWidget,
), ),
); );
if (capturedImage == null) { if (capturedImage == null) {
throw Exception('Failed to capture SVG as image'); throw Exception(
'Failed to capture SVG as image');
} }
// Save the captured PNG to a temporary file // Save the captured PNG to a temporary file
final directory = await getTemporaryDirectory(); final directory =
final file = File('${directory.path}/shared_image.png'); await getTemporaryDirectory();
final file = File(
'${directory.path}/shared_image.png');
await file.writeAsBytes(capturedImage); await file.writeAsBytes(capturedImage);
// Share the PNG file with text and link // Share the PNG file with text and link
@ -2130,8 +2159,11 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
await file.delete(); await file.delete();
} catch (e) { } catch (e) {
print("Error sharing file: $e"); print("Error sharing file: $e");
ScaffoldMessenger.of(context).showSnackBar( ScaffoldMessenger.of(context)
SnackBar(content: Text('Error sharing: $e')), .showSnackBar(
SnackBar(
content:
Text('Error sharing: $e')),
); );
} }
}, },
@ -2144,43 +2176,41 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
size: 24, size: 24,
semanticLabel: 'Share', semanticLabel: 'Share',
), ),
),
), ),
),
], ],
), ),
SizedBox( SizedBox(
width: 10), // Horizontal space between items width: 10), // Horizontal space between items
Row( Row(
children: [ children: [
GestureDetector( GestureDetector(
onTap: () { onTap: () {
showRightSideModal( showRightSideModal(
context, filterData, chartsData); context, filterData, chartsData);
}, },
child: Row(
child: Row( children: [
children: [ Text(
Text( context.translate(
context.translate( 'Filter',
'Filter', 'فلتر',
'فلتر', ),
), style: const TextStyle(
style: const TextStyle( fontSize: 16,
fontSize: 16, color: Colors.white,
color: Colors.white, ),
), ),
SizedBox(width: 10),
Image.asset(
UaeNumbersAssetPath.filterUae,
color: Colors
.white, // Set color to white
width: 21,
height: 21,
),
],
), ),
SizedBox(width: 10),
Image.asset(
UaeNumbersAssetPath.filterUae,
color: Colors.white, // Set color to white
width: 21,
height: 21,
),
],),
) )
// IconButton( // IconButton(
// icon: Icon(Icons.filter_alt_outlined, // icon: Icon(Icons.filter_alt_outlined,
@ -2258,28 +2288,25 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
// nonChartData Cards // nonChartData Cards
Padding( Padding(
padding: const EdgeInsets.all(3.34), padding: const EdgeInsets.all(3.34),
child: GridView.builder(
child: GridView.builder(
key: cardKey, key: cardKey,
itemCount: cardData.length, itemCount: cardData.length,
shrinkWrap: true, shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( gridDelegate:
crossAxisCount:crossAxisCount, SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
// crossAxisCount: cardData.length % 2 == 0 ? 2 : 3, // crossAxisCount: cardData.length % 2 == 0 ? 2 : 3,
crossAxisSpacing: 2, crossAxisSpacing: 2,
mainAxisSpacing: 5, mainAxisSpacing: 5,
childAspectRatio: MediaQuery.of(context) childAspectRatio: MediaQuery.of(context)
.size .size
.width / .width /
(MediaQuery.of(context).size.height / (MediaQuery.of(context).size.height /
(cardData.length % 2 == 0 ? 2 : 2)), (cardData.length % 2 == 0 ? 2 : 2)),
// childAspectRatio:
// calculateAspectRatio(cardData.length, cardData),
), ),
// Sort and filter the cardData // Sort and filter the cardData
@ -2303,6 +2330,11 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
? 180.0 ? 180.0
: 130.0; : 130.0;
final itemdata = cardData[index];
bool isLastSingleCard =
(index == cardData.length - 1 &&
cardData.length % 2 != 0);
if (response.isEmpty) { if (response.isEmpty) {
return const SizedBox.shrink(); return const SizedBox.shrink();
// return Container( // return Container(
@ -2312,11 +2344,13 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
if (response.length == 1) { if (response.length == 1) {
return Container( return Container(
margin: const EdgeInsets.all(10), margin: const EdgeInsets.all(10),
width: isLastSingleCard
? double.infinity
: null,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
BorderRadius.circular(12), BorderRadius.circular(12),
border: Border.all( border: Border.all(
color: Color(int.parse( color: Color(int.parse(
(chartScreenData[ (chartScreenData[
'border_color'] ?? 'border_color'] ??
@ -2396,16 +2430,20 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
child: FittedBox( child: FittedBox(
child: Text( child: Text(
// '(${response[0]['display_value'] ?? 'NA'})', // '(${response[0]['display_value'] ?? 'NA'})',
RegExp(r'\d').hasMatch(response[0]['display_value'] ?? '') RegExp(r'\d').hasMatch(
response[0][
'display_value'] ??
'')
? '(${response[0]['display_value'] ?? 'NA'})' ? '(${response[0]['display_value'] ?? 'NA'})'
: '${response[0]['display_value'] ?? 'NA'}', : '${response[0]['display_value'] ?? 'NA'}',
style: style:
const TextStyle( const TextStyle(
fontSize: 10, fontSize: 10,
color: Colors.grey, color: Colors.grey,
overflow: TextOverflow.ellipsis, overflow:
), TextOverflow
.ellipsis,
),
), ),
), ),
), ),
@ -2420,35 +2458,59 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
child: Row( child: Row(
children: [ children: [
Text( Text(
response[0]['value'] ?? 'NA', response[0][
'value'] ??
'NA',
// '${data['roundedAverage'] ?? // '${data['roundedAverage'] ??
// 'NA'}', // 'NA'}',
style: style: TextStyle(
TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: fontWeight:
FontWeight.w800, FontWeight
color: response[0]['calculation'] == 'different' .w800,
? _getColorFromHex(response[0]['font_color']) color: response[0]
: const Color(0xFF90B0D5), [
'calculation'] ==
'different'
? _getColorFromHex(
response[0]
[
'font_color'])
: bodyColor,
// color: Color( // color: Color(
// 0xFF90B0D5), // 0xFF90B0D5),
), ),
), ),
const SizedBox(width: 1), // Space between text and icon const SizedBox(
if (response[0]['calculation'] == 'different') ...[ width:
if (response[0]['font_color'] == '#D83731') 1), // Space between text and icon
const Icon(Icons.arrow_downward, color: Colors.red, size: 20) if (response[0][
else if (response[0]['font_color'] == '#11AF22') 'calculation'] ==
const Icon(Icons.arrow_upward, color: Colors.green, size: 20), 'different') ...[
if (response[0][
'font_color'] ==
'#D83731')
const Icon(
Icons
.arrow_downward,
color: Colors
.red,
size: 20)
else if (response[
0][
'font_color'] ==
'#11AF22')
const Icon(
Icons
.arrow_upward,
color: Colors
.green,
size: 20),
], ],
], ],
), ),
), ),
), ),
), ),
], ],
), ),
@ -2457,6 +2519,9 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
} else { } else {
return Container( return Container(
margin: const EdgeInsets.all(10), margin: const EdgeInsets.all(10),
width: isLastSingleCard
? double.infinity
: null,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
BorderRadius.circular(12), BorderRadius.circular(12),
@ -2538,14 +2603,19 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
Text( Text(
// '(${response[0]['display_value'] ?? 'NA'})', // '(${response[0]['display_value'] ?? 'NA'})',
RegExp(r'\d').hasMatch(response[0]['display_value'] ?? '') RegExp(r'\d').hasMatch(response[
0][
'display_value'] ??
'')
? '(${response[0]['display_value'] ?? 'NA'})' ? '(${response[0]['display_value'] ?? 'NA'})'
: '${response[0]['display_value'] ?? 'NA'}', : '${response[0]['display_value'] ?? 'NA'}',
style: const TextStyle( style: const TextStyle(
fontSize: 10, fontSize: 10,
color: Colors.grey, color: Colors.grey,
overflow: TextOverflow.ellipsis,), overflow:
TextOverflow.ellipsis,
),
), ),
const SizedBox(height: 1), const SizedBox(height: 1),
Flexible( Flexible(
@ -2560,13 +2630,17 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
// data['lastYearValue']), // data['lastYearValue']),
// apiService.formatAmount( // apiService.formatAmount(
// data['lastYearValue']), // data['lastYearValue']),
style: TextStyle( style: TextStyle(
fontSize: 18, fontSize: 18,
fontWeight: fontWeight:
FontWeight.w900, FontWeight.w900,
color: response[0]['calculation'] == 'different' color: response[0][
? _getColorFromHex(response[0]['font_color']) 'calculation'] ==
: const Color(0xFF90B0D5), 'different'
? _getColorFromHex(
response[0][
'font_color'])
: bodyColor,
), ),
), ),
), ),
@ -2593,26 +2667,33 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
fontSize: 14, fontSize: 14,
fontWeight: fontWeight:
FontWeight.w600, FontWeight.w600,
color: response[1][
color: response[1]['calculation'] == 'different' 'calculation'] ==
? _getColorFromHex(response[0]['font_color']) 'different'
: const Color(0xFFD83731), ? _getColorFromHex(
response[0][
'font_color'])
: const Color(
0xFFD83731),
), ),
), ),
), ),
), ),
Text( Text(
// '(${response[1]['display_value'] ?? 'NA'})', // '(${response[1]['display_value'] ?? 'NA'})',
RegExp(r'\d').hasMatch(response[1]['display_value'] ?? '') RegExp(r'\d').hasMatch(response[
1][
'display_value'] ??
'')
? '(${response[1]['display_value'] ?? 'NA'})' ? '(${response[1]['display_value'] ?? 'NA'})'
: '${response[1]['display_value'] ?? 'NA'}', : '${response[1]['display_value'] ?? 'NA'}',
style: const TextStyle( style: const TextStyle(
fontSize: 9, fontSize: 9,
fontWeight: fontWeight: FontWeight.w500,
FontWeight.w500, color: Colors.grey,
color: Colors.grey, overflow:
overflow: TextOverflow.ellipsis,), TextOverflow.ellipsis,
),
), ),
], ],
), ),
@ -2656,18 +2737,21 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
children: [ children: [
// ConstrainedBox // ConstrainedBox
Container( Container(
// constraints: const BoxConstraints( height: (chartsData[index]
// minHeight: ['chart_type'] ==
// 200, // Minimum height 'pie_chart')
// maxHeight: ? 500
// 400, // Maximum height : (chartsData[index][
// ), 'chart_type'] ==
height: 350, 'bar_chart_horizontal')
? 370
: 350,
// child: buildChart(chartsData[index]), // child: buildChart(chartsData[index]),
child: ChartWidget( child: ChartWidget(
chartData: chartData:
chartsData[index])) chartsData[index],
bodyColor: bodyColor))
], ],
), ),
), ),
@ -2749,4 +2833,4 @@ Color _getColorFromHex(String hexColor) {
hexColor = 'FF$hexColor'; // Add alpha if not provided hexColor = 'FF$hexColor'; // Add alpha if not provided
} }
return Color(int.parse(hexColor, radix: 16)); return Color(int.parse(hexColor, radix: 16));
} }

File diff suppressed because it is too large Load Diff

View File

@ -70,6 +70,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
boxy:
dependency: "direct main"
description:
name: boxy
sha256: "71af0cd1bf7889c09787f26219a345aa4f38ccb98384c8ec24189e4d8e746005"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
build: build:
dependency: transitive dependency: transitive
description: description:

View File

@ -1,7 +1,7 @@
name: uae_stat name: uae_stat
description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness." description: "View statistics about the UAE from the Federal Center for Statistics and Competitiveness."
publish_to: "none" publish_to: "none"
version: 1.0.24+25 version: 1.0.25+26
environment: environment:
sdk: ">=3.2.3 <4.0.0" sdk: ">=3.2.3 <4.0.0"
@ -20,7 +20,6 @@ dependencies:
injectable: ^2.3.2 injectable: ^2.3.2
riverpod_annotation: ^2.3.3 riverpod_annotation: ^2.3.3
cupertino_icons: ^1.0.6 cupertino_icons: ^1.0.6
fl_chart: ^0.70.2 fl_chart: ^0.70.2
iconify_design: ^1.0.1 iconify_design: ^1.0.1
marquee: ^2.2.3 marquee: ^2.2.3
@ -66,6 +65,7 @@ dependencies:
tutorial_coach_mark: ^1.2.12 tutorial_coach_mark: ^1.2.12
package_info_plus: ^8.2.0 package_info_plus: ^8.2.0
flutter_svg: ^2.0.17 flutter_svg: ^2.0.17
boxy: ^2.2.1
dependency_overrides: dependency_overrides:
fading_edge_scrollview: ^4.1.1 fading_edge_scrollview: ^4.1.1