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

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

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

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