|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:developer';
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_swiper_view/flutter_swiper_view.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_assets.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_export.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/date_util.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/app_state.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/enums.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/utils/utils.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/int_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/insurance/insurance_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/medical_file/medical_file_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/medical_file/models/family_file_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/profile_settings/profile_settings_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/habib_wallet/habib_wallet_page.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/presentation/habib_wallet/recharge_wallet_page.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/dialog_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/app_language_change.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/chip/app_custom_chip_widget.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/transitions/fade_page.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import '../../core/dependencies.dart' show getIt;
|
|
|
|
|
|
|
|
|
|
class ProfileSettings extends StatefulWidget {
|
|
|
|
|
ProfileSettings({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
_ProfileSettingsState createState() {
|
|
|
|
|
return _ProfileSettingsState();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _ProfileSettingsState extends State<ProfileSettings> {
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
super.dispose();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int length = 3;
|
|
|
|
|
final SwiperController _controller = SwiperController();
|
|
|
|
|
|
|
|
|
|
int _index = 0;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
final MedicalFileViewModel medicalFileViewModel = getIt.get<MedicalFileViewModel>();
|
|
|
|
|
return CollapsingListView(
|
|
|
|
|
title: "Profile & Settings".needTranslation,
|
|
|
|
|
logout: () {},
|
|
|
|
|
isClose: true,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
padding: EdgeInsets.only(top: 24, bottom: 24),
|
|
|
|
|
physics: NeverScrollableScrollPhysics(),
|
|
|
|
|
child: Consumer<ProfileSettingsViewModel>(
|
|
|
|
|
builder: (context, model, child) {
|
|
|
|
|
print(jsonEncode(medicalFileViewModel.patientFamilyFiles));
|
|
|
|
|
return Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
Swiper(
|
|
|
|
|
itemCount: medicalFileViewModel.patientFamilyFiles.length,
|
|
|
|
|
layout: SwiperLayout.STACK,
|
|
|
|
|
loop: true,
|
|
|
|
|
itemWidth: MediaQuery.of(context).size.width - 42,
|
|
|
|
|
indicatorLayout: PageIndicatorLayout.COLOR,
|
|
|
|
|
axisDirection: AxisDirection.right,
|
|
|
|
|
controller: _controller,
|
|
|
|
|
itemHeight: 210 + 16,
|
|
|
|
|
pagination: const SwiperPagination(
|
|
|
|
|
alignment: Alignment.bottomCenter,
|
|
|
|
|
margin: EdgeInsets.only(top: 210 + 8 + 24),
|
|
|
|
|
builder: DotSwiperPaginationBuilder(color: Color(0xffD9D9D9), activeColor: AppColors.blackBgColor),
|
|
|
|
|
),
|
|
|
|
|
itemBuilder: (BuildContext context, int index) {
|
|
|
|
|
return FamilyCardWidget(isRootUser: true).paddingOnly(right: 16);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
GridView(
|
|
|
|
|
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 2, crossAxisSpacing: 9, mainAxisSpacing: 9),
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
padding: const EdgeInsets.all(24),
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
children: [
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.all(16),
|
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
|
|
|
|
|
color: AppColors.whiteColor,
|
|
|
|
|
borderRadius: 20.h,
|
|
|
|
|
hasShadow: true,
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
spacing: 4.h,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
spacing: 8.h,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
|
|
children: [
|
|
|
|
|
Utils.buildSvgWithAssets(icon: AppAssets.wallet, width: 40.h, height: 40.h),
|
|
|
|
|
"Habib Wallet".needTranslation.toText14(weight: FontWeight.w600, maxlines: 2).expanded,
|
|
|
|
|
Utils.buildSvgWithAssets(icon: AppAssets.arrow_forward),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Spacer(),
|
|
|
|
|
Consumer<HabibWalletViewModel>(builder: (context, habibWalletVM, child) {
|
|
|
|
|
return Utils.getPaymentAmountWithSymbol2(habibWalletVM.habibWalletAmount, isExpanded: false)
|
|
|
|
|
.toShimmer2(isShow: habibWalletVM.isWalletAmountLoading, radius: 12.h, width: 80.h, height: 24.h);
|
|
|
|
|
}),
|
|
|
|
|
CustomButton(
|
|
|
|
|
height: 40.h,
|
|
|
|
|
icon: AppAssets.recharge_icon,
|
|
|
|
|
iconSize: 24.h,
|
|
|
|
|
iconColor: AppColors.infoColor,
|
|
|
|
|
textColor: AppColors.infoColor,
|
|
|
|
|
text: "Recharge".needTranslation,
|
|
|
|
|
borderWidth: 0.h,
|
|
|
|
|
fontWeight: FontWeight.w500,
|
|
|
|
|
borderColor: Colors.transparent,
|
|
|
|
|
backgroundColor: Color(0xff45A2F8).withValues(alpha: 0.08),
|
|
|
|
|
padding: EdgeInsets.all(8.h),
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
onPressed: () {
|
|
|
|
|
Navigator.of(context).push(CustomPageRoute(page: RechargeWalletPage()));
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).onPress(() {
|
|
|
|
|
Navigator.of(context).push(CustomPageRoute(page: HabibWalletPage()));
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
"Quick Actions".needTranslation.toText18(weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1).paddingOnly(left: 24, right: 24),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 24, right: 24, top: 16, bottom: 24),
|
|
|
|
|
padding: EdgeInsets.only(top: 4, bottom: 4),
|
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
actionItem(AppAssets.language_change, "Language".needTranslation, () {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(context, title: "Application Language".needTranslation, child: AppLanguageChange(), callBackFunc: () {}, isFullScreen: false);
|
|
|
|
|
}, trailingLabel: Utils.appState.isArabic() ? "العربية".needTranslation : "English".needTranslation),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.accessibility, "Accessibility".needTranslation, () {}),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.bell, "Notifications Settings".needTranslation, () {}),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.touch_face_id, "Touch ID / Face ID Services".needTranslation, () {}, switchValue: true),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
"Personal Information".needTranslation.toText18(weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1).paddingOnly(left: 24, right: 24),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 24, right: 24, top: 16, bottom: 24),
|
|
|
|
|
padding: EdgeInsets.only(top: 4, bottom: 4),
|
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
actionItem(AppAssets.email_transparent, "Update Email Address".needTranslation, () {}),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.smart_phone_fill, "Phone Number".needTranslation, () {}),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.my_address, "My Addresses".needTranslation, () {}),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.emergency, "Emergency Contact".needTranslation, () {}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
"Help & Support".needTranslation.toText18(weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1).paddingOnly(left: 24, right: 24),
|
|
|
|
|
Container(
|
|
|
|
|
margin: EdgeInsets.only(left: 24, right: 24, top: 16),
|
|
|
|
|
padding: EdgeInsets.only(top: 4, bottom: 4),
|
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.h, hasShadow: true),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
actionItem(AppAssets.call_fill, "Contact Us".needTranslation, () {}, trailingLabel: "9200666666"),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.permission, "Permissions".needTranslation, () {}, trailingLabel: "Location, Camera"),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.rate, "Rate Our App".needTranslation, () {}, isExternalLink: true),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.privacy_terms, "Privacy Policy".needTranslation, () {}, isExternalLink: true),
|
|
|
|
|
1.divider,
|
|
|
|
|
actionItem(AppAssets.privacy_terms, "Terms & Conditions".needTranslation, () {}, isExternalLink: true),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
CustomButton(icon: AppAssets.minus, text: "Deactivate account".needTranslation, onPressed: () {}).paddingAll(24),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget actionItem(String icon, String label, VoidCallback onPress, {String trailingLabel = "", bool? switchValue, bool isExternalLink = false}) {
|
|
|
|
|
return SizedBox(
|
|
|
|
|
height: 56,
|
|
|
|
|
child: Row(
|
|
|
|
|
spacing: 8.h,
|
|
|
|
|
children: [
|
|
|
|
|
Utils.buildSvgWithAssets(icon: icon, iconColor: AppColors.greyTextColor),
|
|
|
|
|
label.toText14(weight: FontWeight.w500, textOverflow: TextOverflow.ellipsis, maxlines: 1).expanded,
|
|
|
|
|
if (trailingLabel.isNotEmpty) trailingLabel.toText14(color: AppColors.greyTextColor, weight: FontWeight.w500, textOverflow: TextOverflow.ellipsis, maxlines: 1),
|
|
|
|
|
switchValue != null
|
|
|
|
|
? Switch(
|
|
|
|
|
value: switchValue,
|
|
|
|
|
onChanged: (value) {},
|
|
|
|
|
activeColor: AppColors.successColor,
|
|
|
|
|
activeTrackColor: AppColors.successColor.withValues(alpha: .15),
|
|
|
|
|
)
|
|
|
|
|
: Transform.scale(
|
|
|
|
|
scaleX: Utils.appState.isArabic() ? -1 : 1,
|
|
|
|
|
child: Utils.buildSvgWithAssets(icon: isExternalLink ? AppAssets.externalLink : AppAssets.arrow_forward),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(left: 16, right: 16).onPress(onPress),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FamilyCardWidget extends StatelessWidget {
|
|
|
|
|
FamilyCardWidget({this.isRootUser = true, Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
bool isRootUser;
|
|
|
|
|
late AppState appState;
|
|
|
|
|
final Function() onAddFamilyMemberPress;
|
|
|
|
|
final Function(FamilyFileResponseModelLists member) onFamilySwitchPress;
|
|
|
|
|
final FamilyFileResponseModelLists profile;
|
|
|
|
|
|
|
|
|
|
const FamilyCardWidget({required this.onAddFamilyMemberPress, required this.profile, required this.onFamilySwitchPress(FamilyFileResponseModelLists member)});
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
AppState appState = getIt.get<AppState>();
|
|
|
|
|
final isActive = (profile.responseId == appState.getAuthenticatedUser()?.patientId);
|
|
|
|
|
final isParentUser = appState.getAuthenticatedUser()?.isParentUser ?? false;
|
|
|
|
|
final canSwitch = isParentUser || (!isParentUser && profile.responseId == appState.getSuperUserID);
|
|
|
|
|
return Container(
|
|
|
|
|
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 20.h, hasShadow: true),
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
Column(
|
|
|
|
|
spacing: 8.h,
|
|
|
|
|
children: [
|
|
|
|
|
Row(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
spacing: 8.h,
|
|
|
|
|
children: [
|
|
|
|
|
Image.asset(appState.getAuthenticatedUser()?.gender == 1 ? AppAssets.male_img : AppAssets.femaleImg, width: 56.h, height: 56.h),
|
|
|
|
|
Column(
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
spacing: 0.h,
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
"${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}"
|
|
|
|
|
.toText18(isBold: true, weight: FontWeight.w600, textOverflow: TextOverflow.ellipsis, maxlines: 1),
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
icon: AppAssets.file_icon,
|
|
|
|
|
labelText: "${LocaleKeys.fileNo.tr(context: context)}: ${appState.getAuthenticatedUser()!.patientId}",
|
|
|
|
|
iconSize: 12,
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
Icon(Icons.qr_code, size: 56)
|
|
|
|
|
],
|
|
|
|
|
).expanded,
|
|
|
|
|
SizedBox(
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: Wrap(
|
|
|
|
|
alignment: WrapAlignment.start,
|
|
|
|
|
spacing: 8.h,
|
|
|
|
|
children: [
|
|
|
|
|
AppCustomChipWidget(labelText: "${appState.getAuthenticatedUser()!.age} Years Old"),
|
|
|
|
|
AppCustomChipWidget(
|
|
|
|
|
icon: AppAssets.blood_icon,
|
|
|
|
|
labelText: "${LocaleKeys.bloodType.tr(context: context)}: ${appState.getUserBloodGroup}",
|
|
|
|
|
iconColor: AppColors.primaryRedColor,
|
|
|
|
|
),
|
|
|
|
|
Consumer<InsuranceViewModel>(builder: (context, insuranceVM, child) {
|
|
|
|
|
return AppCustomChipWidget(
|
|
|
|
|
icon: insuranceVM.isInsuranceLoading
|
|
|
|
|
? AppAssets.cancel_circle_icon
|
|
|
|
|
: (DateTime.now().isAfter(
|
|
|
|
|
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
|
|
|
|
|
))
|
|
|
|
|
? AppAssets.cancel_circle_icon
|
|
|
|
|
: AppAssets.insurance_active_icon,
|
|
|
|
|
labelText: insuranceVM.isInsuranceLoading
|
|
|
|
|
? "Insurance"
|
|
|
|
|
: (DateTime.now().isAfter(
|
|
|
|
|
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
|
|
|
|
|
)
|
|
|
|
|
? "Insurance Expired".needTranslation
|
|
|
|
|
: "Insurance Active".needTranslation),
|
|
|
|
|
iconColor: insuranceVM.isInsuranceLoading
|
|
|
|
|
? AppColors.primaryRedColor
|
|
|
|
|
: (DateTime.now().isAfter(
|
|
|
|
|
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
|
|
|
|
|
))
|
|
|
|
|
? AppColors.primaryRedColor
|
|
|
|
|
: AppColors.successColor,
|
|
|
|
|
iconSize: 14,
|
|
|
|
|
backgroundColor: insuranceVM.isInsuranceLoading
|
|
|
|
|
? AppColors.primaryRedColor
|
|
|
|
|
: (DateTime.now().isAfter(
|
|
|
|
|
DateUtil.convertStringToDate(insuranceVM.patientInsuranceList.first.cardValidTo),
|
|
|
|
|
))
|
|
|
|
|
? AppColors.primaryRedColor.withValues(alpha: 0.15)
|
|
|
|
|
: AppColors.successColor.withValues(alpha: 0.15),
|
|
|
|
|
).toShimmer2(isShow: insuranceVM.isInsuranceLoading);
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
).paddingOnly(top: 16, right: 16, left: 16, bottom: 12).expanded,
|
|
|
|
|
1.divider,
|
|
|
|
|
_buildActionButton(appState),
|
|
|
|
|
|
|
|
|
|
// if (appState.getAuthenticatedUser()!.isParentUser ?? false) ...[
|
|
|
|
|
// if (member!.responseId != appState.getAuthenticatedUser()!.patientId) ...[
|
|
|
|
|
// CustomButton(
|
|
|
|
|
// icon: AppAssets.switch_user,
|
|
|
|
|
// text: "Switch Family File".needTranslation,
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// onFamilySwitchPress(member!);
|
|
|
|
|
// },
|
|
|
|
|
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
|
|
|
|
|
// ] else
|
|
|
|
|
// ...[
|
|
|
|
|
// CustomButton(
|
|
|
|
|
// icon: AppAssets.add_family,
|
|
|
|
|
// text: "Add a new family member".needTranslation,
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// onAddFamilyMemberPress();
|
|
|
|
|
// },
|
|
|
|
|
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
|
|
|
|
|
// ]
|
|
|
|
|
// ] else
|
|
|
|
|
// ...[
|
|
|
|
|
// if (appState.getSuperUserID != null && appState.getSuperUserID == member!.responseId) ...[
|
|
|
|
|
// CustomButton(
|
|
|
|
|
// icon: AppAssets.switch_user,
|
|
|
|
|
// text: "Switch Back To Family File".needTranslation,
|
|
|
|
|
// onPressed: () {
|
|
|
|
|
// onFamilySwitchPress(member!);
|
|
|
|
|
// },
|
|
|
|
|
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
|
|
|
|
|
// ] else
|
|
|
|
|
// ...[
|
|
|
|
|
// CustomButton(
|
|
|
|
|
// icon: AppAssets.switch_user,
|
|
|
|
|
// text: "Disabled".needTranslation,
|
|
|
|
|
// backgroundColor: Colors.grey.shade200,
|
|
|
|
|
// borderColor: Colors.grey.shade200,
|
|
|
|
|
// textColor: AppColors.greyTextColor,
|
|
|
|
|
// onPressed: () {},
|
|
|
|
|
// iconColor: AppColors.greyTextColor,
|
|
|
|
|
// ).paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
|
|
|
|
|
// ]
|
|
|
|
|
// ]
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildActionButton(AppState appState) {
|
|
|
|
|
final isParentUser = appState.getAuthenticatedUser()?.isParentUser ?? false;
|
|
|
|
|
final int? currentUserId = appState.getAuthenticatedUser()?.patientId;
|
|
|
|
|
final int? superUserId = appState.getSuperUserID;
|
|
|
|
|
|
|
|
|
|
if (isParentUser) {
|
|
|
|
|
return _buildParentUserButton(currentUserId);
|
|
|
|
|
} else {
|
|
|
|
|
return _buildNonParentUserButton(superUserId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildParentUserButton(int? currentUserId) {
|
|
|
|
|
final canSwitch = profile.responseId != currentUserId;
|
|
|
|
|
|
|
|
|
|
return CustomButton(
|
|
|
|
|
icon: canSwitch ? AppAssets.switch_user : AppAssets.add_family,
|
|
|
|
|
text: canSwitch ? "Switch Family File".needTranslation : "Add a new family member".needTranslation,
|
|
|
|
|
onPressed: canSwitch ? () => onFamilySwitchPress(profile) : onAddFamilyMemberPress,
|
|
|
|
|
backgroundColor: canSwitch ? AppColors.secondaryLightRedColor : AppColors.primaryRedColor,
|
|
|
|
|
borderColor: canSwitch ? AppColors.secondaryLightRedColor : AppColors.primaryRedColor,
|
|
|
|
|
textColor: canSwitch ? AppColors.primaryRedColor : AppColors.whiteColor,
|
|
|
|
|
iconColor: canSwitch ? AppColors.primaryRedColor : AppColors.whiteColor,
|
|
|
|
|
).paddingOnly(top: 12, right: 16, left: 16, bottom: 16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildNonParentUserButton(int? superUserId) {
|
|
|
|
|
final canSwitchBack = superUserId != null && superUserId == profile.responseId;
|
|
|
|
|
|
|
|
|
|
return CustomButton(
|
|
|
|
|
icon: AppAssets.switch_user,
|
|
|
|
|
text: canSwitchBack ? "Switch Back To Family File".needTranslation : "Switch".needTranslation,
|
|
|
|
|
backgroundColor: canSwitchBack ? AppColors.primaryRedColor : Colors.grey.shade200,
|
|
|
|
|
borderColor: canSwitchBack ? AppColors.primaryRedColor : Colors.grey.shade200,
|
|
|
|
|
textColor: canSwitchBack ? AppColors.whiteColor : AppColors.greyTextColor,
|
|
|
|
|
iconColor: canSwitchBack ? AppColors.whiteColor : AppColors.greyTextColor,
|
|
|
|
|
onPressed: canSwitchBack ? () => onFamilySwitchPress(profile) : () {},
|
|
|
|
|
).paddingOnly(top: 12, right: 16, left: 16, bottom: 16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //TODO: Add family file switch logic here
|
|
|
|
|
// isRootUser
|
|
|
|
|
// ? CustomButton(icon: AppAssets.add_family, text: "Add a new family member".needTranslation, height: 40.h, fontSize: 14, onPressed: () {})
|
|
|
|
|
// .paddingOnly(top: 12, right: 16, left: 16, bottom: 16)
|
|
|
|
|
// : CustomButton(
|
|
|
|
|
// icon: AppAssets.add_family,
|
|
|
|
|
// backgroundColor: AppColors.secondaryLightRedColor,
|
|
|
|
|
// borderColor: AppColors.secondaryLightRedColor,
|
|
|
|
|
// textColor: AppColors.primaryRedColor,
|
|
|
|
|
// iconColor: AppColors.primaryRedColor,
|
|
|
|
|
// text: "Switch to this medical file".needTranslation,
|
|
|
|
|
// height: 40.h,
|
|
|
|
|
// fontSize: 14,
|
|
|
|
|
// onPressed: () {})
|
|
|
|
|
// .paddingOnly(top: 12, right: 16, left: 16, bottom: 16),
|
|
|
|
|
//
|
|
|
|
|
}
|