* 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 {
if (getIt.get<AppState>().isAuthenticated) {
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),
// ),
// );
// }
} 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,6 +21,14 @@ class SmartwatchInstructionsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
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(
@ -82,6 +90,8 @@ class SmartwatchInstructionsPage extends StatelessWidget {
),
);
}
);
}
Widget watchContentDetails({required String title, required String description, required String icon, required Color descriptionTextColor}) {
return Column(

Loading…
Cancel
Save