diff --git a/mobile/lib/features/home/view/contribution_screen.dart b/mobile/lib/features/home/view/contribution_screen.dart index d37e766..d15ed72 100644 --- a/mobile/lib/features/home/view/contribution_screen.dart +++ b/mobile/lib/features/home/view/contribution_screen.dart @@ -629,7 +629,14 @@ class _UserContributionWidgetState extends State { } num countTotal() { - return widget.oneDayData["kg_co2e_reduced"] ?? 0; + final int roleId = widget.oneDayData["role_id"] ?? 0; + final Map data = widget.oneDayData; + switch (roleId) { + case 2: + return (data["kg_co2e_recycle_reduced"] ?? 0) + (data["kg_co2e_plastic_reduced"] ?? 0); + case 3: return data["kg_co2e_reduced"] ?? 0; + default: return 0; + } } String? getAvatarUrl() { diff --git a/mobile/lib/features/home/view/statistic_screen.dart b/mobile/lib/features/home/view/statistic_screen.dart index 545659e..2cd2785 100644 --- a/mobile/lib/features/home/view/statistic_screen.dart +++ b/mobile/lib/features/home/view/statistic_screen.dart @@ -26,6 +26,12 @@ class _StatisticScreenState extends State { }); } + _getRoleIdShowData() { + return widget.roleId == 1 ? + isHouseholdTab ? 2 : 3 + : widget.roleId; + } + @override Widget build(BuildContext context) { final Map allData = widget.roleId == 1 ? @@ -63,7 +69,7 @@ class _StatisticScreenState extends State { BarWidget(isHousehold: isHouseholdTab, changeBar: changeBar), if (allData["overall_data_one_month"] != null && allData["overall_data_one_month"].isNotEmpty) ...allData["overall_data_one_month"].map((e) { - return UserContributionWidget(oneDayData: {...e, "role_id": widget.roleId}); + return UserContributionWidget(oneDayData: {...e, "role_id": _getRoleIdShowData()}); }).toList() else const Center( diff --git a/mobile/pubspec.yaml b/mobile/pubspec.yaml index 994b1d5..c975d46 100644 --- a/mobile/pubspec.yaml +++ b/mobile/pubspec.yaml @@ -3,7 +3,7 @@ description: "WazNet (Waste zero, Net zero) is a mobile app that helps users tra # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.1+13 +version: 0.0.1+14 environment: sdk: ^3.5.3