You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
467 lines
19 KiB
Dart
467 lines
19 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:health/health.dart';
|
|
import 'package:hmg_patient_app_new/core/dependencies.dart';
|
|
import 'package:hmg_patient_app_new/core/utils/size_utils.dart';
|
|
import 'package:hmg_patient_app_new/extensions/string_extensions.dart';
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
import 'package:hmg_patient_app_new/presentation/smartwatches/health_dashboard/health_dashboard.dart';
|
|
import 'package:hmg_patient_app_new/services/dialog_service.dart';
|
|
import 'package:hmg_patient_app_new/theme/colors.dart';
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
|
|
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
class SmartwatchInstructionsPage extends StatelessWidget {
|
|
const SmartwatchInstructionsPage({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColors.bgScaffoldColor,
|
|
body: CollapsingListView(
|
|
title: LocaleKeys.smartWatches.tr(),
|
|
child: Padding(
|
|
padding: EdgeInsets.symmetric(horizontal: 24.h),
|
|
child: SingleChildScrollView(
|
|
child: Platform.isIOS ? getIOSInstructionsUI(context) : getAndroidInstructionsUI(context),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget getAndroidInstructionsUI(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
"Supported Smart Watches".needTranslation.toText20(isBold: true),
|
|
SizedBox(height: 16.h),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/galaxy_watch_ultra.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Galaxy Watch Ultra", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/galaxy_watch_8_classic.jpeg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Galaxy Watch 8 Classic", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/galaxy_watch_8.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Galaxy Watch 8", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/galaxy_watch_7_classic.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Galaxy Watch 7 Classic", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/galaxy_watch_7.webp", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Galaxy Watch 7", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/galaxy_fit_3.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: SizedBox(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Galaxy Fit3", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
"Please make sure that your Samsung Watch is connected to your Phone, is actively synced & updated.".needTranslation.toText14(isBold: true),
|
|
SizedBox(height: 12),
|
|
"Before syncing data, please make sure that you have followed the instructions properly.".needTranslation.toText14(isBold: true),
|
|
SizedBox(height: 12),
|
|
InkWell(
|
|
onTap: () {
|
|
showInstructionsDialog(context);
|
|
},
|
|
child: "View watch instructions".needTranslation.toText12(isBold: true, color: AppColors.textColor, isUnderLine: true)),
|
|
SizedBox(
|
|
height: 130.h,
|
|
),
|
|
CustomButton(
|
|
text: LocaleKeys.confirm.tr(context: context),
|
|
onPressed: () async {
|
|
await Health().getHealthConnectSdkStatus().then((val) {
|
|
print('Health Connect SDK Status: $val');
|
|
if (val == HealthConnectSdkStatus.sdkAvailable) {
|
|
Navigator.of(context).push(
|
|
CustomPageRoute(
|
|
page: HealthDashboard(),
|
|
),
|
|
);
|
|
} else {
|
|
getIt.get<DialogService>().showErrorBottomSheet(
|
|
message: "Seems like you do not have Health Connect App installed. Please install it from the Play Store to sync your health data.".needTranslation,
|
|
onOkPressed: () {
|
|
Navigator.pop(context);
|
|
Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata");
|
|
launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
});
|
|
return;
|
|
}
|
|
});
|
|
},
|
|
backgroundColor: AppColors.primaryRedColor,
|
|
borderColor: AppColors.primaryRedColor,
|
|
textColor: AppColors.whiteColor,
|
|
fontSize: 16.f,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 10.r,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 50.h,
|
|
iconColor: AppColors.whiteColor,
|
|
iconSize: 18.h,
|
|
),
|
|
// DefaultButton(
|
|
// LocaleKeys.confirm.tr(context: context),
|
|
// () async {
|
|
// await Health().getHealthConnectSdkStatus().then((val) {
|
|
// print('Health Connect SDK Status: $val');
|
|
// if (val == HealthConnectSdkStatus.sdkAvailable) {
|
|
// Navigator.of(context).push(
|
|
// FadePage(
|
|
// page: HealthDashboard(), // Replace with the actual vital signs page
|
|
// // page: HealthApp(), // Replace with the actual vital signs page
|
|
// ),
|
|
// );
|
|
// } else {
|
|
// Utils.showAppDialog(context, LocaleKeys.error.tr(context: context), LocaleKeys.healthConnectNotInstalled.tr(), () {
|
|
// Navigator.pop(context);
|
|
// Uri uri = Uri.parse("https://play.google.com/store/apps/details?id=com.google.android.apps.healthdata");
|
|
// launchUrl(uri, mode: LaunchMode.externalApplication);
|
|
// });
|
|
// return;
|
|
// }
|
|
// });
|
|
// },
|
|
// )
|
|
],
|
|
);
|
|
}
|
|
|
|
Widget getIOSInstructionsUI(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
"Supported Smart Watches".needTranslation.toText20(isBold: true),
|
|
SizedBox(height: 16.h),
|
|
Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/apple-watch-1.jpeg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Apple Watch Series 5", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/apple-watch-2.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Apple Watch Series 6", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/apple-watch-3.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Apple Watch Series 7", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/apple-watch-4.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Apple Watch Series 8", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 10.0),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/apple-watch-5.jpg", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Apple Watch Series 9", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Container(
|
|
margin: EdgeInsets.only(top: 15.0),
|
|
child: Row(
|
|
children: [
|
|
Image.asset("assets/images/png/smartwatches/Apple-Watch-6.png", width: 70.0, height: 70.0),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width * 0.21,
|
|
child: Text("Apple Watch Series 10", overflow: TextOverflow.clip, style: TextStyle(fontSize: 12.0)),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
SizedBox(height: 12),
|
|
"Please make sure that your Apple Watch is connected to your iPhone, is actively synced & updated.".toText14(isBold: true),
|
|
SizedBox(height: 12),
|
|
"Before syncing data, please make sure that you have followed the instructions properly.".toText14(isBold: true),
|
|
SizedBox(height: 12),
|
|
InkWell(
|
|
onTap: () {
|
|
showInstructionsDialog(context);
|
|
},
|
|
child: "View watch instructions".toText12(isBold: true, color: AppColors.textColor, isUnderLine: true),
|
|
),
|
|
SizedBox(
|
|
height: 130.h,
|
|
),
|
|
CustomButton(
|
|
text: LocaleKeys.confirm.tr(context: context),
|
|
onPressed: () async {
|
|
Navigator.of(context).push(
|
|
CustomPageRoute(
|
|
page: HealthDashboard(),
|
|
),
|
|
);
|
|
},
|
|
backgroundColor: AppColors.primaryRedColor,
|
|
borderColor: AppColors.primaryRedColor,
|
|
textColor: AppColors.whiteColor,
|
|
fontSize: 16.f,
|
|
fontWeight: FontWeight.w500,
|
|
borderRadius: 10.r,
|
|
padding: EdgeInsets.fromLTRB(10, 0, 10, 0),
|
|
height: 50.h,
|
|
iconColor: AppColors.whiteColor,
|
|
iconSize: 18.h,
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
showInstructionsDialog(BuildContext context) {
|
|
showGeneralDialog(
|
|
barrierColor: Colors.black.withOpacity(0.5),
|
|
transitionBuilder: (context, a1, a2, widget) {
|
|
final curvedValue = Curves.easeInOutBack.transform(a1.value) - 1.0;
|
|
return Transform(
|
|
transform: Matrix4.translationValues(0.0, curvedValue * 200, 0.0),
|
|
child: Opacity(
|
|
opacity: a1.value,
|
|
child: Dialog(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Container(
|
|
width: 350.0,
|
|
padding: EdgeInsets.all(21),
|
|
color: Colors.white,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
"SmartWatch Tracker".toText18(),
|
|
IconButton(
|
|
icon: Icon(
|
|
Icons.close,
|
|
color: Color(0xff2E303A),
|
|
),
|
|
onPressed: () {
|
|
Navigator.pop(context);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
(Platform.isIOS
|
|
? "Make sure that you have installed 'Health' App & 'Watch' App from Apple Store."
|
|
: "Please make sure that your Samsung Watch is connected to your Phone, is actively synced & updated.")
|
|
.needTranslation
|
|
.toText14(),
|
|
SizedBox(height: 12),
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
},
|
|
transitionDuration: Duration(milliseconds: 500),
|
|
barrierDismissible: true,
|
|
barrierLabel: '',
|
|
context: context,
|
|
pageBuilder: (context, animation1, animation2) {
|
|
return SizedBox();
|
|
//Chanbged By Aamir
|
|
});
|
|
}
|
|
}
|