chart changes
This commit is contained in:
parent
bdcdf737a8
commit
a1993712ac
@ -1346,10 +1346,9 @@ 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
|
||||
@ -1372,6 +1371,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
addedChartIds
|
||||
.add(chart['chart_heading']); // Track by a unique identifier
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// List filteredCardData = [];
|
||||
@ -1799,18 +1799,21 @@ 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');
|
||||
|
||||
print("TABFiltered Data: $filterData");
|
||||
@ -1927,6 +1930,10 @@ 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;
|
||||
|
||||
|
||||
final color =
|
||||
Color(int.parse(widget.bgColor.replaceFirst('0x', ''), radix: 16));
|
||||
return PopScope(
|
||||
@ -1938,45 +1945,6 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
|
||||
child: BaseScaffold(
|
||||
key: _scaffoldKey,
|
||||
// backgroundColor: color,
|
||||
// appBar: AppBar(
|
||||
// backgroundColor: color,
|
||||
// elevation: 0,
|
||||
// actions: [
|
||||
// // IconButton(
|
||||
// // onPressed: () {},
|
||||
// // icon: const Icon(Icons.toggle_off_outlined),
|
||||
// // ),
|
||||
// MyToggle(
|
||||
// // key: toggleKey,
|
||||
// isOn: locale?.languageCode == 'en',
|
||||
// knobTextWhenOn: 'ع',
|
||||
// knobTextWhenOff: 'EN',
|
||||
// pathColorWhenOn: Colors.grey.shade300,
|
||||
// pathColorWhenOff: Colors.grey.shade300,
|
||||
// onTap: () {
|
||||
// ref.read(localeProvider.notifier).toggleLocale();
|
||||
// },
|
||||
// ),
|
||||
// ],
|
||||
// leading: IconButton(
|
||||
// icon: Icon(Icons.arrow_back_ios_new, color: Colors.white),
|
||||
// onPressed: () {
|
||||
// if (widget.keyParam == 'home') {
|
||||
// context.go('/myhomepage');
|
||||
// } else {
|
||||
// context.go('/uaenumbers');
|
||||
// }
|
||||
// },
|
||||
// ),
|
||||
// title: Text(
|
||||
// context.translate(
|
||||
// 'UAE Numbers',
|
||||
// 'أرقام الإمارات',
|
||||
// ),
|
||||
// style: TextStyle(color: Colors.white),
|
||||
// ),
|
||||
// ),
|
||||
title: Text(
|
||||
context.translate(
|
||||
'UAE Numbers',
|
||||
@ -2035,25 +2003,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
fontWeight: FontWeight.w400,
|
||||
fontFamily: 'Roboto'),
|
||||
),
|
||||
// Row(
|
||||
// mainAxisAlignment: MainAxisAlignment.end,
|
||||
// children: [
|
||||
// IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(
|
||||
// Icons.bookmark_add_outlined,
|
||||
// color: Colors.white,
|
||||
// size: 40,
|
||||
// )),
|
||||
// IconButton(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(
|
||||
// Icons.share,
|
||||
// color: Colors.white,
|
||||
// size: 30,
|
||||
// )),
|
||||
// ],
|
||||
// ),
|
||||
|
||||
],
|
||||
),
|
||||
)),
|
||||
@ -2073,7 +2023,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (isBookmarked) {
|
||||
showRemoveBookmarkDialog();
|
||||
showRemoveBookmarkDialog();
|
||||
} else {
|
||||
showAddBookmarkDialog();
|
||||
}
|
||||
@ -2194,37 +2144,43 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
size: 24,
|
||||
semanticLabel: 'Share',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
width: 10), // Horizontal space between items
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
context.translate(
|
||||
'Filter',
|
||||
'فلتر',
|
||||
),
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(width: 10),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
showRightSideModal(
|
||||
context, filterData, chartsData);
|
||||
},
|
||||
child: Image.asset(
|
||||
|
||||
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,
|
||||
),
|
||||
],),
|
||||
|
||||
)
|
||||
// IconButton(
|
||||
// icon: Icon(Icons.filter_alt_outlined,
|
||||
@ -2302,32 +2258,26 @@ 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:2,
|
||||
crossAxisCount:
|
||||
cardData.length % 2 == 0 ? 2 : 3,
|
||||
// crossAxisCount: cardData.length == 2
|
||||
// ? 2
|
||||
// : cardData.length == 3
|
||||
// ? 3
|
||||
// : cardData.length == 4
|
||||
// ? 2
|
||||
// : 3, // Default to 3 if more than 4 items // 2 cards per row
|
||||
crossAxisSpacing: 2,
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount:crossAxisCount,
|
||||
// crossAxisCount: cardData.length % 2 == 0 ? 2 : 3,
|
||||
|
||||
crossAxisSpacing: 2,
|
||||
|
||||
mainAxisSpacing: 5,
|
||||
childAspectRatio: MediaQuery.of(context)
|
||||
.size
|
||||
.width /
|
||||
(MediaQuery.of(context).size.height /
|
||||
(cardData.length % 2 == 0
|
||||
? 2
|
||||
: 1.3)),
|
||||
(cardData.length % 2 == 0 ? 2 : 2)),
|
||||
// childAspectRatio:
|
||||
// calculateAspectRatio(cardData.length, cardData),
|
||||
),
|
||||
@ -2366,6 +2316,7 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
borderRadius:
|
||||
BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
|
||||
color: Color(int.parse(
|
||||
(chartScreenData[
|
||||
'border_color'] ??
|
||||
@ -2444,15 +2395,17 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
height: 20.0,
|
||||
child: FittedBox(
|
||||
child: Text(
|
||||
'(${response[0]['display_value'] ?? 'NA'})',
|
||||
// '(${data['firstYear'] ??
|
||||
// 'NA'} - ${data['lastYear'] ??
|
||||
// 'NA'})',
|
||||
// '(${response[0]['display_value'] ?? 'NA'})',
|
||||
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),
|
||||
color: Colors.grey,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -2467,60 +2420,35 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
child: Row(
|
||||
children: [
|
||||
Text(
|
||||
response[0][
|
||||
'value'] ??
|
||||
'NA',
|
||||
response[0]['value'] ?? 'NA',
|
||||
// '${data['roundedAverage'] ??
|
||||
// 'NA'}',
|
||||
style: TextStyle(
|
||||
fontSize: 20,
|
||||
style:
|
||||
TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight:
|
||||
FontWeight
|
||||
.w900,
|
||||
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'])
|
||||
: const Color(0xFF90B0D5),
|
||||
// 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: 22)
|
||||
else if (response[
|
||||
0][
|
||||
'font_color'] ==
|
||||
'#11AF22')
|
||||
const Icon(
|
||||
Icons
|
||||
.arrow_upward,
|
||||
color: Colors
|
||||
.green,
|
||||
size: 22),
|
||||
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),
|
||||
],
|
||||
],
|
||||
|
||||
),
|
||||
|
||||
),
|
||||
),
|
||||
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -2608,12 +2536,16 @@ class _ChartScreen1State extends ConsumerState<ChartScreen1> {
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
Text(
|
||||
'(${response[0]['display_value'] ?? 'NA'})',
|
||||
// '(${response[0]['display_value'] ?? 'NA'})',
|
||||
|
||||
RegExp(r'\d').hasMatch(response[0]['display_value'] ?? '')
|
||||
? '(${response[0]['display_value'] ?? 'NA'})'
|
||||
: '${response[0]['display_value'] ?? 'NA'}',
|
||||
|
||||
// '(${data['lastYear'] ?? 'NA'})',
|
||||
style: const TextStyle(
|
||||
fontSize: 10,
|
||||
color: Colors.grey),
|
||||
color: Colors.grey,
|
||||
overflow: TextOverflow.ellipsis,),
|
||||
),
|
||||
const SizedBox(height: 1),
|
||||
Flexible(
|
||||
@ -2628,18 +2560,13 @@ 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'])
|
||||
: const Color(0xFF90B0D5),
|
||||
),
|
||||
),
|
||||
),
|
||||
@ -2666,26 +2593,26 @@ 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'})',
|
||||
// '(${data['secondLastYear'] ?? 'NA'})',
|
||||
// '(${response[1]['display_value'] ?? 'NA'})',
|
||||
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),
|
||||
color: Colors.grey,
|
||||
overflow: TextOverflow.ellipsis,),
|
||||
),
|
||||
],
|
||||
),
|
||||
@ -2822,4 +2749,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
Loading…
Reference in New Issue
Block a user