* 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 {
if (getIt.get<AppState>().isAuthenticated) {
getIt.get<NavigationService>().pushPageRoute(AppRoutes.smartWatches); getIt.get<NavigationService>().pushPageRoute(AppRoutes.smartWatches);
} else {
// if (getIt.get<AppState>().isAuthenticated) { Navigator.of(getIt<NavigationService>().navigatorKey.currentContext!).push(
// } else { CustomPageRoute(
// Navigator.of(getIt<NavigationService>().navigatorKey.currentContext!).push( page: ServiceInfoPage(
// CustomPageRoute( serviceName: LocaleKeys.smartWatches.tr(),
// page: ServiceInfoPage( serviceHeader: LocaleKeys.smartWatchServiceHeader.tr(),
// serviceName: LocaleKeys.smartWatches.tr(), serviceDescription: LocaleKeys.smartWatchServiceDescription.tr(),
// serviceHeader: LocaleKeys.smartWatchServiceHeader.tr(), serviceImage: AppAssets.smartWatchService),
// serviceDescription: LocaleKeys.smartWatchServiceDescription.tr(), ),
// 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,6 +21,14 @@ class SmartwatchInstructionsPage extends StatelessWidget {
@override @override
Widget build(BuildContext context) { 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( return Scaffold(
backgroundColor: AppColors.bgScaffoldColor, backgroundColor: AppColors.bgScaffoldColor,
body: CollapsingListView( body: CollapsingListView(
@ -82,6 +90,8 @@ class SmartwatchInstructionsPage extends StatelessWidget {
), ),
); );
} }
);
}
Widget watchContentDetails({required String title, required String description, required String icon, required Color descriptionTextColor}) { Widget watchContentDetails({required String title, required String description, required String icon, required Color descriptionTextColor}) {
return Column( return Column(

Loading…
Cancel
Save