Pull to refresh implemented

pull/213/head
haroon amjad 5 days ago
parent 71030c0fe9
commit 991f9c7a9b

@ -270,7 +270,7 @@ class _RechargeWalletPageState extends State<RechargeWalletPage> {
isCloseButtonVisible: true, isCloseButtonVisible: true,
); );
} else { } else {
habibWalletVM.setWalletRechargeAmount(num.parse(amountTextController.text)); habibWalletVM.setWalletRechargeAmount(num.parse(amountTextController.text.replaceAll(',', '')));
habibWalletVM.setNotesText(notesTextController.text); habibWalletVM.setNotesText(notesTextController.text);
// habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}", // habibWalletVM.setDepositorDetails(appState.getAuthenticatedUser()!.patientId.toString(), "${appState.getAuthenticatedUser()!.firstName} ${appState.getAuthenticatedUser()!.lastName}",
// appState.getAuthenticatedUser()!.mobileNumber!); // appState.getAuthenticatedUser()!.mobileNumber!);

@ -180,7 +180,29 @@ class _LandingPageState extends State<LandingPage> {
body: Consumer<InsuranceViewModel>(builder: (context, insuranceVM, child) { body: Consumer<InsuranceViewModel>(builder: (context, insuranceVM, child) {
return Stack( return Stack(
children: [ children: [
SingleChildScrollView( RefreshIndicator(
color: AppColors.primaryRedColor,
onRefresh: () async {
if (appState.isAuthenticated) {
// Refresh Appointments Data
myAppointmentsViewModel.setIsAppointmentDataToBeLoaded(true);
myAppointmentsViewModel.initAppointmentsViewModel();
myAppointmentsViewModel.getPatientAppointments(true, false);
// Refresh Appointments Data
habibWalletVM.initHabibWalletProvider();
habibWalletVM.getPatientBalanceAmount();
// Refresh Ancillary Orders
todoSectionViewModel.initializeTodoSectionViewModel();
// Refresh Immediate LiveCare Data
immediateLiveCareViewModel.initImmediateLiveCare();
immediateLiveCareViewModel.getPatientLiveCareHistory();
}
},
child: SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: (appState.isAuthenticated && !insuranceVM.isInsuranceLoading && insuranceVM.isInsuranceExpired && insuranceVM.isInsuranceExpiryBannerShown) top: (appState.isAuthenticated && !insuranceVM.isInsuranceLoading && insuranceVM.isInsuranceExpired && insuranceVM.isInsuranceExpiryBannerShown)
? (MediaQuery.paddingOf(context).top + 70.h) ? (MediaQuery.paddingOf(context).top + 70.h)
@ -215,9 +237,15 @@ class _LandingPageState extends State<LandingPage> {
}, },
name: ('${appState.getAuthenticatedUser()!.firstName!} ${appState.getAuthenticatedUser()!.lastName!}'), name: ('${appState.getAuthenticatedUser()!.firstName!} ${appState.getAuthenticatedUser()!.lastName!}'),
// imageUrl: appState.getAuthenticatedUser()?.gender == 1 ? AppAssets.maleImg : AppAssets.femaleImg, // imageUrl: appState.getAuthenticatedUser()?.gender == 1 ? AppAssets.maleImg : AppAssets.femaleImg,
imageUrl: appState.getAuthenticatedUser()?.gender == 1 imageUrl: appState
? ((appState.getAuthenticatedUser()?.age ?? 0) < 7 ? AppAssets.babyBoyImg : AppAssets.maleImg) .getAuthenticatedUser()
: ((appState.getAuthenticatedUser()?.age ?? 0) < 7 ? AppAssets.babyGirlImg : AppAssets.femaleImg), ?.gender == 1
? ((appState
.getAuthenticatedUser()
?.age ?? 0) < 7 ? AppAssets.babyBoyImg : AppAssets.maleImg)
: ((appState
.getAuthenticatedUser()
?.age ?? 0) < 7 ? AppAssets.babyGirlImg : AppAssets.femaleImg),
).expanded ).expanded
: CustomButton( : CustomButton(
text: LocaleKeys.loginOrRegister.tr(context: context), text: LocaleKeys.loginOrRegister.tr(context: context),
@ -279,7 +307,11 @@ class _LandingPageState extends State<LandingPage> {
child: Text( child: Text(
todoSectionVM.notificationsCount.toString(), todoSectionVM.notificationsCount.toString(),
style: TextStyle( style: TextStyle(
color: Colors.white, fontFamily: "Poppins", fontSize: 10.f, fontWeight: FontWeight.w600,), color: Colors.white,
fontFamily: "Poppins",
fontSize: 10.f,
fontWeight: FontWeight.w600,
),
textAlign: TextAlign.center, textAlign: TextAlign.center,
), ),
), ),
@ -443,7 +475,8 @@ class _LandingPageState extends State<LandingPage> {
// ), // ),
// ); // );
}, },
separatorBuilder: (BuildContext cxt, int index) => SizedBox( separatorBuilder: (BuildContext cxt, int index) =>
SizedBox(
width: 10.w, width: 10.w,
), ),
), ),
@ -589,12 +622,13 @@ class _LandingPageState extends State<LandingPage> {
Navigator.of(context).push(CustomPageRoute(page: MedicalFilePage())); Navigator.of(context).push(CustomPageRoute(page: MedicalFilePage()));
}), }),
SizedBox(height: 16.h), SizedBox(height: 16.h),
Container( Consumer(builder: (BuildContext context, TodoSectionViewModel todoSectionVM, Widget? child) {
return Container(
// height: 121.h, // height: 121.h,
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.r), decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 24.r),
child: Column( child: Column(
children: [ children: [
todoSectionViewModel.patientAncillaryOrdersList.isNotEmpty todoSectionVM.patientAncillaryOrdersList.isNotEmpty
? Container( ? Container(
height: 50.h, height: 50.h,
decoration: ShapeDecoration( decoration: ShapeDecoration(
@ -607,14 +641,11 @@ class _LandingPageState extends State<LandingPage> {
child: Row( child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
LocaleKeys.pendingAncillaryOrders LocaleKeys.pendingAncillaryOrders.tr(context: context).toText14(color: AppColors.eReferralCardColor, isBold: true).paddingSymmetrical(24.h, 0.h),
.tr(context: context)
.toText14(color: AppColors.eReferralCardColor, isBold: true)
.paddingSymmetrical(24.h, 0.h),
CustomButton( CustomButton(
text: LocaleKeys.view.tr(context: context), text: LocaleKeys.view.tr(context: context),
onPressed: () { onPressed: () {
getIt.get<TodoSectionViewModel>().setIsAncillaryOrdersNeedReloading(true); todoSectionVM.setIsAncillaryOrdersNeedReloading(true);
Navigator.of(context).push( Navigator.of(context).push(
CustomPageRoute( CustomPageRoute(
page: ToDoPage(), page: ToDoPage(),
@ -645,7 +676,11 @@ class _LandingPageState extends State<LandingPage> {
trackColor: Color(0xffD9D9D9), trackColor: Color(0xffD9D9D9),
trackBorderColor: Colors.transparent, trackBorderColor: Colors.transparent,
trackRadius: Radius.circular(10.0), trackRadius: Radius.circular(10.0),
padding: EdgeInsets.only(top: 92.h + 32.h, left: MediaQuery.sizeOf(context).width / 2.5 - 10, right: MediaQuery.sizeOf(context).width / 2.5 - 10), padding: EdgeInsets.only(top: 92.h + 32.h, left: MediaQuery
.sizeOf(context)
.width / 2.5 - 10, right: MediaQuery
.sizeOf(context)
.width / 2.5 - 10),
child: ListView.separated( child: ListView.separated(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: LandingPageData.getLoggedInServiceCardsList.length, itemCount: LandingPageData.getLoggedInServiceCardsList.length,
@ -680,7 +715,8 @@ class _LandingPageState extends State<LandingPage> {
SizedBox(height: 16.h), SizedBox(height: 16.h),
], ],
), ),
).paddingSymmetrical(24.h, 0.h), ).paddingSymmetrical(24.h, 0.h);
}),
], ],
) )
: Container( : Container(
@ -698,7 +734,11 @@ class _LandingPageState extends State<LandingPage> {
trackColor: Color(0xffD9D9D9), trackColor: Color(0xffD9D9D9),
trackBorderColor: Colors.transparent, trackBorderColor: Colors.transparent,
trackRadius: Radius.circular(10.0), trackRadius: Radius.circular(10.0),
padding: EdgeInsets.only(top: 92.h + 32.h, left: MediaQuery.sizeOf(context).width / 2.5 - 10, right: MediaQuery.sizeOf(context).width / 2.5 - 10), padding: EdgeInsets.only(top: 92.h + 32.h, left: MediaQuery
.sizeOf(context)
.width / 2.5 - 10, right: MediaQuery
.sizeOf(context)
.width / 2.5 - 10),
child: ListView.separated( child: ListView.separated(
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
itemCount: LandingPageData.getNotLoggedInServiceCardsList.length, itemCount: LandingPageData.getNotLoggedInServiceCardsList.length,
@ -781,6 +821,7 @@ class _LandingPageState extends State<LandingPage> {
], ],
), ),
), ),
),
(appState.isAuthenticated && !insuranceVM.isInsuranceLoading && insuranceVM.isInsuranceExpired && insuranceVM.isInsuranceExpiryBannerShown) (appState.isAuthenticated && !insuranceVM.isInsuranceLoading && insuranceVM.isInsuranceExpired && insuranceVM.isInsuranceExpiryBannerShown)
? Container( ? Container(
height: MediaQuery.paddingOf(context).top + 50.h, height: MediaQuery.paddingOf(context).top + 50.h,

@ -304,7 +304,7 @@ class TextInputWidget extends StatelessWidget {
hintLocales: const [Locale('en', 'US')], hintLocales: const [Locale('en', 'US')],
enabled: isEnable, enabled: isEnable,
scrollPadding: EdgeInsets.zero, scrollPadding: EdgeInsets.zero,
keyboardType: isMultiline ? TextInputType.multiline : keyboardType, keyboardType: isMultiline ? TextInputType.multiline : (isWalletAmountInput! ? const TextInputType.numberWithOptions(decimal: true) : keyboardType),
controller: controller, controller: controller,
readOnly: isReadOnly, readOnly: isReadOnly,
textAlignVertical: TextAlignVertical.top, textAlignVertical: TextAlignVertical.top,
@ -315,7 +315,12 @@ class TextInputWidget extends StatelessWidget {
autofocus: autoFocus, autofocus: autoFocus,
textInputAction: TextInputAction.done, textInputAction: TextInputAction.done,
cursorHeight: isWalletAmountInput! ? 40.h : 20.h, cursorHeight: isWalletAmountInput! ? 40.h : 20.h,
maxLength: isWalletAmountInput! ? 6 : 100, maxLength: isWalletAmountInput! ? 7 : 100,
inputFormatters: isWalletAmountInput!
? [
_ThousandSeparatorInputFormatter(),
]
: null,
onTapOutside: (event) { onTapOutside: (event) {
FocusManager.instance.primaryFocus?.unfocus(); FocusManager.instance.primaryFocus?.unfocus();
}, },
@ -407,3 +412,63 @@ class TextInputWidget extends StatelessWidget {
); );
} }
} }
class _ThousandSeparatorInputFormatter extends TextInputFormatter {
@override
TextEditingValue formatEditUpdate(
TextEditingValue oldValue,
TextEditingValue newValue,
) {
// Remove all commas to get the raw number
String newText = newValue.text.replaceAll(',', '');
// Allow only digits and one decimal point
if (newText.isNotEmpty && !RegExp(r'^\d*\.?\d{0,2}$').hasMatch(newText)) {
return oldValue;
}
// Split into integer and decimal parts
String integerPart;
String decimalPart = '';
if (newText.contains('.')) {
final parts = newText.split('.');
integerPart = parts[0];
decimalPart = '.${parts[1]}';
} else {
integerPart = newText;
}
// Add thousand separators to the integer part
if (integerPart.isNotEmpty) {
final buffer = StringBuffer();
int count = 0;
for (int i = integerPart.length - 1; i >= 0; i--) {
buffer.write(integerPart[i]);
count++;
if (count == 3 && i > 0) {
buffer.write(',');
count = 0;
}
}
integerPart = buffer.toString().split('').reversed.join();
}
final formatted = '$integerPart$decimalPart';
// Calculate new cursor position
int cursorOffset = newValue.selection.baseOffset;
// Count commas before cursor in the new formatted string
int commasInNew = ','.allMatches(formatted.substring(0, cursorOffset.clamp(0, formatted.length))).length;
// Count commas before cursor in the old value
int commasInOld = ','.allMatches(oldValue.text.substring(0, oldValue.selection.baseOffset.clamp(0, oldValue.text.length))).length;
int newCursorPos = cursorOffset + (commasInNew - commasInOld);
newCursorPos = newCursorPos.clamp(0, formatted.length);
return TextEditingValue(
text: formatted,
selection: TextSelection.collapsed(offset: newCursorPos),
);
}
}

Loading…
Cancel
Save