Skip to content

Commit

Permalink
hcmpre-1421: ui changes for search and overview page
Browse files Browse the repository at this point in the history
  • Loading branch information
yashita-egov committed Dec 3, 2024
1 parent 0b4ea20 commit 8592a36
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 49 deletions.
19 changes: 13 additions & 6 deletions apps/health_campaign_field_worker_app/lib/pages/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import 'package:referral_reconciliation/router/referral_reconciliation_router.gm
import 'package:registration_delivery/registration_delivery.dart';
import 'package:registration_delivery/router/registration_delivery_router.gm.dart';
import 'package:survey_form/router/survey_form_router.gm.dart';
import 'package:digit_data_model/models/entities/household_type.dart';

import '../blocs/app_initialization/app_initialization.dart';
import '../blocs/auth/auth.dart';
Expand Down Expand Up @@ -356,16 +357,22 @@ class _HomePageState extends LocalizedState<HomePage> {
icon: Icons.all_inbox,
label: i18.home.beneficiaryLabel,
onPressed: () async {
RegistrationDeliverySingleton()
.setHouseholdType(HouseholdType.family);
await context.router.push(const RegistrationDeliveryWrapperRoute());
},
),
),

i18.home.institutionLabel: homeShowcaseData.instituteCampaign.buildWith(
i18.home.clfLabel: homeShowcaseData.clf.buildWith(
child: HomeItemCard(
icon: Icons.account_balance,
label: i18.home.institutionLabel,
onPressed: () {},
label: i18.home.clfLabel,
onPressed: () async {
RegistrationDeliverySingleton()
.setHouseholdType(HouseholdType.community);
await context.router.push(const RegistrationDeliveryWrapperRoute());
},
),
),

Expand Down Expand Up @@ -534,13 +541,13 @@ class _HomePageState extends LocalizedState<HomePage> {
i18.home.closedHouseHoldLabel:
homeShowcaseData.closedHouseHold.showcaseKey,
i18.home.dashboard: homeShowcaseData.dashBoard.showcaseKey,
i18.home.institutionLabel: homeShowcaseData.instituteCampaign.showcaseKey,
i18.home.clfLabel: homeShowcaseData.clf.showcaseKey,
};

final homeItemsLabel = <String>[
// INFO: Need to add items label of package Here
i18.home.beneficiaryLabel,
i18.home.institutionLabel,
i18.home.clfLabel,
i18.home.closedHouseHoldLabel,
i18.home.manageStockLabel,
i18.home.stockReconciliationLabel,
Expand All @@ -561,7 +568,7 @@ class _HomePageState extends LocalizedState<HomePage> {
.toList()
.contains(element) ||
element == i18.home.db ||
element == i18.home.institutionLabel)
element == i18.home.clfLabel)
.toList();

final showcaseKeys = filteredLabels
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ class HomeShowcase {
return 'WAREHOUSE_MANAGER_HOME_SHOWCASE_DELETE_ALL';
}

String get instituteCampaign {
return "INSTITUTE_CAMPAIGN_SHOWCASE";
String get clf {
return "COMMUNAL_LIVING_FACILITY_SHOWCASE";
}
}

Expand Down Expand Up @@ -565,7 +565,7 @@ class Home {

String get closedHouseHoldLabel => 'HOME_CLOSE_HOUSEHOLD_LABEL';

String get institutionLabel => "HOME_INSTITUTION_CAMPAIGN_LABEL";
String get clfLabel => "HOME_COMMUNAL_LIVING_FACILITIES_LABEL";
}

class AcknowledgementSuccess {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,5 @@ class _HomePageShowcaseData {
messageLocalizationKey: i18.home.closedHouseHoldLabel,
);

final instituteCampaign = ShowcaseItemBuilder(
messageLocalizationKey: i18.homeShowcase.instituteCampaign);
final clf = ShowcaseItemBuilder(messageLocalizationKey: i18.homeShowcase.clf);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:auto_route/auto_route.dart';
import 'package:collection/collection.dart';
import 'package:digit_data_model/data_model.dart';
import 'package:digit_data_model/models/entities/household_type.dart';
import 'package:digit_ui_components/enum/app_enums.dart';
import 'package:digit_ui_components/theme/digit_extended_theme.dart';
import 'package:digit_ui_components/theme/digit_theme.dart';
Expand Down Expand Up @@ -407,9 +408,18 @@ class _HouseholdOverviewPageState
child: Padding(
padding: const EdgeInsets.all(spacer2),
child: Text(
localizations.translate(i18
.householdOverView
.householdOverViewLabel),
RegistrationDeliverySingleton()
.householdType !=
null &&
RegistrationDeliverySingleton()
.householdType ==
HouseholdType.community
? localizations.translate(i18
.householdOverView
.clfOverviewLabel)
: localizations.translate(i18
.householdOverView
.householdOverViewLabel),
style: textTheme.headingXl,
),
),
Expand Down Expand Up @@ -458,6 +468,49 @@ class _HouseholdOverviewPageState
bool shouldShowStatus = beneficiaryType ==
BeneficiaryType.household;

if (RegistrationDeliverySingleton()
.householdType !=
null &&
RegistrationDeliverySingleton()
.householdType ==
HouseholdType.community) {
return Column(
children: [
DigitTableCard(element: {
localizations.translate(i18
.householdOverView
.instituteNameLabel): state
.householdMemberWrapper
.headOfHousehold
?.name
?.givenName ??
localizations.translate(
i18.common.coreCommonNA),
localizations.translate(i18
.householdOverView
.instituteTypeLabel):
RegistrationDeliverySingleton()
.householdType,
localizations.translate(
i18.deliverIntervention
.memberCountText,
): state.householdMemberWrapper
.household?.memberCount,
localizations.translate(
i18.householdLocation
.administrationAreaFormLabel,
): state
.householdMemberWrapper
.headOfHousehold
?.address
?.first
.locality
?.code,
}),
],
);
}

return Column(
children: [
DigitTableCard(
Expand Down Expand Up @@ -543,11 +596,9 @@ class _HouseholdOverviewPageState
'${localizations.translate(getStatus(selectedFilters[index]))}'
' (${state.householdMemberWrapper.members!.length})',
onItemDelete: () {
setState(() {
selectedFilters.remove(
selectedFilters[
index]);
});
selectedFilters.remove(
selectedFilters[
index]);
callReloadEvent(
offset: 0, limit: 10);
},
Expand Down Expand Up @@ -1020,18 +1071,13 @@ class _HouseholdOverviewPageState
]));

if (filters != null && filters.isNotEmpty) {
setState(() {
selectedFilters = [];
});
setState(() {
selectedFilters.addAll(filters);
});
selectedFilters.addAll(filters);
callReloadEvent(offset: 0, limit: 10);
} else {
setState(() {
selectedFilters = [];
});
// blocWrapper.clearEvent();

callReloadEvent(offset: 0, limit: 10);
}
}
Expand Down
57 changes: 34 additions & 23 deletions packages/registration_delivery/lib/pages/search_beneficiary.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:auto_route/auto_route.dart';
import 'package:digit_data_model/data_model.dart';
import 'package:digit_data_model/models/entities/household_type.dart';
import 'package:digit_scanner/blocs/scanner.dart';
import 'package:digit_scanner/pages/qr_scanner.dart';
import 'package:digit_ui_components/blocs/fetch_location_bloc.dart';
Expand Down Expand Up @@ -109,11 +110,19 @@ class _SearchBeneficiaryPageState
alignment: Alignment.topLeft,
child: Text(
localizations.translate(
RegistrationDeliverySingleton().beneficiaryType !=
BeneficiaryType.individual
? i18.searchBeneficiary.statisticsLabelText
: i18.searchBeneficiary
.searchIndividualLabelText,
RegistrationDeliverySingleton().householdType !=
null &&
RegistrationDeliverySingleton()
.householdType ==
HouseholdType.community
? i18.searchBeneficiary.searchCLFLabel
: RegistrationDeliverySingleton()
.beneficiaryType !=
BeneficiaryType.individual
? i18
.searchBeneficiary.statisticsLabelText
: i18.searchBeneficiary
.searchIndividualLabelText,
),
style: textTheme.headingXl,
textAlign: TextAlign.left,
Expand Down Expand Up @@ -489,31 +498,33 @@ class _SearchBeneficiaryPageState
limit: isPagination
? blocWrapper.individualGlobalSearchBloc.state.limit
: limit,
householdType: RegistrationDeliverySingleton().householdType,
)));
}
} else {
if (isProximityEnabled ||
selectedFilters.isNotEmpty ||
searchController.text.isNotEmpty) {
blocWrapper.houseHoldGlobalSearchBloc
.add(SearchHouseholdsEvent.houseHoldGlobalSearch(
blocWrapper.houseHoldGlobalSearchBloc.add(
SearchHouseholdsEvent.houseHoldGlobalSearch(
globalSearchParams: GlobalSearchParameters(
isProximityEnabled: isProximityEnabled,
latitude: lat,
longitude: long,
projectId: RegistrationDeliverySingleton().projectId!,
maxRadius: RegistrationDeliverySingleton().maxRadius,
nameSearch: searchController.text.trim().length > 2
? searchController.text.trim()
: blocWrapper.searchHouseholdsBloc.state.searchQuery,
filter: selectedFilters,
offset: isPagination
? blocWrapper.houseHoldGlobalSearchBloc.state.offset
: offset,
limit: isPagination
? blocWrapper.houseHoldGlobalSearchBloc.state.limit
: limit,
)));
isProximityEnabled: isProximityEnabled,
latitude: lat,
longitude: long,
projectId: RegistrationDeliverySingleton().projectId!,
maxRadius: RegistrationDeliverySingleton().maxRadius,
nameSearch: searchController.text.trim().length > 2
? searchController.text.trim()
: blocWrapper.searchHouseholdsBloc.state.searchQuery,
filter: selectedFilters,
offset: isPagination
? blocWrapper.houseHoldGlobalSearchBloc.state.offset
: offset,
limit: isPagination
? blocWrapper.houseHoldGlobalSearchBloc.state.limit
: limit,
householdType:
RegistrationDeliverySingleton().householdType)));
}
}
}
Expand Down

0 comments on commit 8592a36

Please sign in to comment.