* error toast added to the instruction page of watch

Main_App_Replacement
taha 1 week ago
parent ae0fffdc0a
commit 402edaf674

@ -120,13 +120,17 @@ class HealthProvider with ChangeNotifier {
void initDevice() async { void initDevice() async {
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader();
notifyListeners(); notifyListeners();
error = null;
final result = await _healthService.initDevice(); final result = await _healthService.initDevice();
isLoading = false; isLoading = false;
// LoaderBottomSheet.hideLoader(); // LoaderBottomSheet.hideLoader();
if (result.isError) { if (result.isError) {
LoaderBottomSheet.hideLoader(); LoaderBottomSheet.hideLoader();
if(result.asError?.error is PlatformException) { final rawError = result.asError?.error;
error = 'Error initializing device: ${(result.asError?.error as PlatformException)?.message}'; if (rawError is PlatformException) {
error = 'Error initializing device: ${rawError.message ?? rawError.toString()}';
} else {
error = 'Error initializing device: ${rawError?.toString() ?? 'Unknown error'}';
} }
} else { } else {
// LoaderBottomSheet.showLoader(); // LoaderBottomSheet.showLoader();
@ -293,5 +297,6 @@ class HealthProvider with ChangeNotifier {
void clearError(){ void clearError(){
error = null; error = null;
notifyListeners();
} }
} }

@ -368,20 +368,19 @@ class _ServicesPageState extends State<ServicesPage> {
true, true,
route: null, route: null,
onTap: () async { onTap: () async {
getIt.get<NavigationService>().pushPageRoute(AppRoutes.smartWatches); if (getIt.get<AppState>().isAuthenticated) {
getIt.get<NavigationService>().pushPageRoute(AppRoutes.smartWatches);
// if (getIt.get<AppState>().isAuthenticated) { } else {
// } else { Navigator.of(getIt<NavigationService>().navigatorKey.currentContext!).push(
// Navigator.of(getIt<NavigationService>().navigatorKey.currentContext!).push( CustomPageRoute(
// CustomPageRoute( page: ServiceInfoPage(
// page: ServiceInfoPage( serviceName: LocaleKeys.smartWatches.tr(),
// serviceName: LocaleKeys.smartWatches.tr(), serviceHeader: LocaleKeys.smartWatchServiceHeader.tr(),
// serviceHeader: LocaleKeys.smartWatchServiceHeader.tr(), serviceDescription: LocaleKeys.smartWatchServiceDescription.tr(),
// serviceDescription: LocaleKeys.smartWatchServiceDescription.tr(), serviceImage: AppAssets.smartWatchService),
// serviceImage: AppAssets.smartWatchService), ),
// ), );
// ); }
// }
// if (getIt.get<AppState>().isAuthenticated) { // if (getIt.get<AppState>().isAuthenticated) {
// getIt.get<NavigationService>().pushPageRoute(AppRoutes.smartWatches); // getIt.get<NavigationService>().pushPageRoute(AppRoutes.smartWatches);
// } else { // } else {

@ -26,11 +26,7 @@ class SmartwatchHomePage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Consumer<HealthProvider>(builder: (context, healthProvider, child) { return Consumer<HealthProvider>(builder: (context, healthProvider, child) {
if (healthProvider.error != null &&
healthProvider.error?.isNotEmpty == true) {
Utils.showToast(healthProvider.error!);
healthProvider.clearError();
}
return Scaffold( return Scaffold(
backgroundColor: AppColors.bgScaffoldColor, backgroundColor: AppColors.bgScaffoldColor,
body: CollapsingListView( body: CollapsingListView(

@ -21,65 +21,75 @@ class SmartwatchInstructionsPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Consumer<HealthProvider>(builder: (context, healthProvider, child) {
backgroundColor: AppColors.bgScaffoldColor, final errorMessage = healthProvider.error;
body: CollapsingListView( if (errorMessage != null && errorMessage.isNotEmpty) {
title: "smartwatchHowItWorks".tr(context: context), WidgetsBinding.instance.addPostFrameCallback((_) {
bottomChild: Container( Utils.showToast(errorMessage, longDuration: false);
decoration: RoundedRectangleBorder().toSmoothCornerDecoration( healthProvider.clearError();
color: AppColors.whiteColor, });
borderRadius: 24.r, }
), return Scaffold(
child: CustomButton( backgroundColor: AppColors.bgScaffoldColor,
text: LocaleKeys.getStarted.tr(context: context), body: CollapsingListView(
onPressed: () { title: "smartwatchHowItWorks".tr(context: context),
context.read<HealthProvider>().initDevice(); bottomChild: Container(
}, decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
backgroundColor: AppColors.primaryRedColor, color: AppColors.whiteColor,
borderColor: AppColors.primaryRedColor, borderRadius: 24.r,
textColor: AppColors.whiteColor, ),
fontSize: 16.f, child: CustomButton(
isBold: true, text: LocaleKeys.getStarted.tr(context: context),
borderRadius: 12.r, onPressed: () {
height: 50.h, context.read<HealthProvider>().initDevice();
).paddingSymmetrical(24.w, 30.h), },
), backgroundColor: AppColors.primaryRedColor,
child: Column( borderColor: AppColors.primaryRedColor,
mainAxisSize: MainAxisSize.max, textColor: AppColors.whiteColor,
spacing: 18.h, fontSize: 16.f,
children: [ isBold: true,
Utils.buildImgWithAssets( borderRadius: 12.r,
icon: smartwatchDetails.watchIcon, height: 50.h,
fit: BoxFit.contain, ).paddingSymmetrical(24.w, 30.h),
height: 280.h,
width: 280.w,
), ),
DecoratedBox( child: Column(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 12.h), mainAxisSize: MainAxisSize.max,
child: Column( spacing: 18.h,
children: [ children: [
watchContentDetails( Utils.buildImgWithAssets(
title: smartwatchDetails.detailsTitle, icon: smartwatchDetails.watchIcon,
description: smartwatchDetails.details, fit: BoxFit.contain,
icon: smartwatchDetails.smallIcon, height: 280.h,
descriptionTextColor: AppColors.primaryRedColor, width: 280.w,
), ),
Divider( DecoratedBox(
color: AppColors.dividerColor, decoration: RoundedRectangleBorder().toSmoothCornerDecoration(color: AppColors.whiteColor, borderRadius: 12.h),
thickness: 1.h, child: Column(
).paddingOnly(top: 16.h, bottom: 16.h), children: [
watchContentDetails( watchContentDetails(
title: smartwatchDetails.secondTitle, title: smartwatchDetails.detailsTitle,
description: LocaleKeys.updatetheinformation.tr(), description: smartwatchDetails.details,
icon: AppAssets.bluetooth, icon: smartwatchDetails.smallIcon,
descriptionTextColor: AppColors.greyTextColor, descriptionTextColor: AppColors.primaryRedColor,
), ),
], Divider(
).paddingSymmetrical(16.w, 16.h), color: AppColors.dividerColor,
) thickness: 1.h,
], ).paddingOnly(top: 16.h, bottom: 16.h),
).paddingSymmetrical(24.w, 16.h), watchContentDetails(
), title: smartwatchDetails.secondTitle,
description: LocaleKeys.updatetheinformation.tr(),
icon: AppAssets.bluetooth,
descriptionTextColor: AppColors.greyTextColor,
),
],
).paddingSymmetrical(16.w, 16.h),
)
],
).paddingSymmetrical(24.w, 16.h),
),
);
}
); );
} }

Loading…
Cancel
Save