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")
if (flutterVersionCode == null) {
flutterVersionCode = "25"
flutterVersionCode = "26"
}
def flutterVersionName = localProperties.getProperty("flutter.versionName")
if (flutterVersionName == null) {
flutterVersionName = "1.0.24"
flutterVersionName = "1.0.25"
}
def keystorePropertiesFile = rootProject.file("key.properties")

View File

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

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.24+25
version: 1.0.25+26
environment:
sdk: ">=3.2.3 <4.0.0"
@ -20,7 +20,6 @@ dependencies:
injectable: ^2.3.2
riverpod_annotation: ^2.3.3
cupertino_icons: ^1.0.6
fl_chart: ^0.70.2
iconify_design: ^1.0.1
marquee: ^2.2.3
@ -66,6 +65,7 @@ dependencies:
tutorial_coach_mark: ^1.2.12
package_info_plus: ^8.2.0
flutter_svg: ^2.0.17
boxy: ^2.2.1
dependency_overrides:
fading_edge_scrollview: ^4.1.1