From 031be1ac565f26276067876d1fadc335ca264a8c Mon Sep 17 00:00:00 2001 From: "HMG\\Lama.Herbish" Date: Mon, 15 Feb 2021 14:43:16 +0300 Subject: [PATCH] fixes --- .../health_data_list.dart | 129 ++++++++++++++---- .../smart_watch_instructions.dart | 59 +++++--- .../smart_watch_health_data/stepsTracker.dart | 3 +- 3 files changed, 142 insertions(+), 49 deletions(-) diff --git a/lib/pages/medical/smart_watch_health_data/health_data_list.dart b/lib/pages/medical/smart_watch_health_data/health_data_list.dart index 2f9a3e60..281cfcee 100644 --- a/lib/pages/medical/smart_watch_health_data/health_data_list.dart +++ b/lib/pages/medical/smart_watch_health_data/health_data_list.dart @@ -1,5 +1,8 @@ +import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/stepsTracker.dart'; import 'package:diplomaticquarterapp/widgets/buttons/button.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:diplomaticquarterapp/widgets/transitions/fade_page.dart'; +import 'package:fit_kit/fit_kit.dart'; import 'package:flutter/material.dart'; class HealthDataList extends StatefulWidget { @@ -8,13 +11,30 @@ class HealthDataList extends StatefulWidget { } class _HealthDataListState extends State { + + List dataTypes = List(); + + @override + void initState() { + dataTypes.add(DataType.DISTANCE); + dataTypes.add(DataType.STEP_COUNT); + dataTypes.add(DataType.HEART_RATE); + dataTypes.add(DataType.SLEEP); + dataTypes.add(DataType.ENERGY); + + super.initState(); + } + @override Widget build(BuildContext context) { return AppScaffold( appBarTitle: "Smartwatches", isShowAppBar: true, body: Container( - height: MediaQuery.of(context).size.height, + height: MediaQuery + .of(context) + .size + .height, margin: EdgeInsets.all(20.0), child: SingleChildScrollView( child: Column( @@ -58,21 +78,31 @@ class _HealthDataListState extends State { Divider( color: Colors.grey[500], ), - Row( - children: [ - Container( - child: Image.asset( - "assets/images/SmartWatches/heartrate_icon.png", - width: 60.0, - height: 60.0), - ), - Container( - margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0), - child: Text("Steps", - style: TextStyle( - fontSize: 20.0, fontWeight: FontWeight.bold)), - ), - ], + InkWell( + onTap: () { + Navigator.push( + context, + FadePage( + page: StepsTracker(), + ), + ); + }, + child: Row( + children: [ + Container( + child: Image.asset( + "assets/images/SmartWatches/heartrate_icon.png", + width: 60.0, + height: 60.0), + ), + Container( + margin: EdgeInsets.fromLTRB(20.0, 0.0, 20.0, 0.0), + child: Text("Steps", + style: TextStyle( + fontSize: 20.0, fontWeight: FontWeight.bold)), + ), + ], + ), ), Divider( color: Colors.grey[500], @@ -121,25 +151,68 @@ class _HealthDataListState extends State { ), bottomSheet: Container( width: double.infinity, - height: MediaQuery.of(context).size.height * 0.1, + height: MediaQuery + .of(context) + .size + .height * 0.1, color: Colors.grey[100], child: Column( children: [ Divider( color: Colors.transparent, ), - Container( - width: MediaQuery.of(context).size.width * 0.8, - child: Button( - onTap: () { -// launch(model.radImageURL); - }, - label: 'Sync Health Data', - backgroundColor: Colors.grey[800], - ), - ), + InkWell( + onTap: () { + print("ReadLast"); + readLast(); + }, + child:Container( + height: (MediaQuery + .of(context) + .size + .height/2)*0.12, + width: MediaQuery + .of(context) + .size + .width * 0.8, + decoration: BoxDecoration( + color: Colors.grey[800], + borderRadius: BorderRadius.circular(6.0), + ), + child: Container( + padding: EdgeInsets.only(top: 10.0), + child: Text( + 'Sync Health Data' , textAlign: TextAlign.center,style: TextStyle( + color: Colors.white , fontSize: 18.0 + ), + ), + ),),), ], ), )); } -} + + + void readLast() async { + print("ReadLast"); + final result = await FitKit.readLast(DataType.DISTANCE); + print(result); + print(result); + } + + void readAll() async { + if (await FitKit.requestPermissions(dataTypes)) { + for (DataType type in dataTypes) { + final results = await FitKit.read( + type, + dateFrom: DateTime.now().subtract(Duration(days: 7)), + dateTo: DateTime.now(), + limit: 100, + ); + print(results); + print(results.length); + } + readLast(); + } + } +} \ No newline at end of file diff --git a/lib/pages/medical/smart_watch_health_data/smart_watch_instructions.dart b/lib/pages/medical/smart_watch_health_data/smart_watch_instructions.dart index eb0c1675..72dbb3c7 100644 --- a/lib/pages/medical/smart_watch_health_data/smart_watch_instructions.dart +++ b/lib/pages/medical/smart_watch_health_data/smart_watch_instructions.dart @@ -4,6 +4,7 @@ import 'package:carousel_slider/carousel_slider.dart'; import 'package:diplomaticquarterapp/pages/medical/smart_watch_health_data/health_data_list.dart'; import 'package:diplomaticquarterapp/services/smartwatch_integration/SmartWatchIntegrationService.dart'; import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:smart_progress_bar/smart_progress_bar.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -88,8 +89,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "Apple Watch Series 1", + "Apple Watch Series 1", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -108,8 +110,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "Apple Watch Series 2", + "Apple Watch Series 2", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -135,8 +138,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "Apple Watch Series 3", + "Apple Watch Series 3", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -155,8 +159,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "Apple Watch Series 4", + "Apple Watch Series 4", overflow: TextOverflow.clip , style: TextStyle( fontSize: 12.0)), ) @@ -182,8 +187,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "Apple Watch Series 5", + "Apple Watch Series 5", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -202,8 +208,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "Apple Watch Series 6", + "Apple Watch Series 6", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -229,7 +236,8 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( - child: Text("Mi Band 3", + width: MediaQuery.of(context).size.width*0.22, + child: Text("Mi Band 3", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -248,7 +256,8 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( - child: Text("Mi Band 4", + width: MediaQuery.of(context).size.width*0.22, + child: Text("Mi Band 4", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -417,9 +426,9 @@ class _SmartWatchInstructionsState extends State { child: CarouselSlider( carouselController: buttonCarouselController, options: CarouselOptions( - enableInfiniteScroll: false, - viewportFraction: 0.95, - height: MediaQuery.of(context).size.height * 0.9), + // enableInfiniteScroll: true, + viewportFraction: 0.99, + height: MediaQuery.of(context).size.height*1.02 ), items: [1, 2].map((i) { return Builder( builder: (BuildContext context) { @@ -427,7 +436,8 @@ class _SmartWatchInstructionsState extends State { width: MediaQuery.of(context).size.width, margin: EdgeInsets.symmetric(horizontal: 5.0), child: Card( - margin: EdgeInsets.fromLTRB(8.0, 16.0, 8.0, 8.0), + margin: EdgeInsets.only(top:16.0 , bottom: 8.0), + // fromLTRB(8.0, 16.0, 8.0, 8.0), color: Colors.white.withOpacity(1.0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), @@ -457,8 +467,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "Huawei Watch 2", + "Huawei Watch 2", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -477,8 +488,10 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( "Mobovi TicWatch E2", + overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -504,7 +517,8 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( - child: Text("Huawei Watch", + width: MediaQuery.of(context).size.width*0.22, + child: Text("Huawei Watch", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -523,7 +537,8 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( - child: Text("Fossil Sport", + width: MediaQuery.of(context).size.width*0.22, + child: Text("Fossil Sport", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -549,8 +564,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "MisFit Vapor 2", + "MisFit Vapor 2", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -569,8 +585,9 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( + width: MediaQuery.of(context).size.width*0.22, child: Text( - "LG Watch Sport", + "LG Watch Sport", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -596,7 +613,8 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( - child: Text("Mi Band 3", + width: MediaQuery.of(context).size.width*0.22, + child: Text("Mi Band 3", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -615,7 +633,8 @@ class _SmartWatchInstructionsState extends State { width: 70.0, height: 70.0), Container( - child: Text("Mi Band 4", + width: MediaQuery.of(context).size.width*0.22, + child: Text("Mi Band 4", overflow: TextOverflow.clip, style: TextStyle( fontSize: 12.0)), ) @@ -735,7 +754,7 @@ class _SmartWatchInstructionsState extends State { ), Container( margin: EdgeInsets.fromLTRB( - 15.0, 95.0, 15.0, 15.0), + 15.0, 75.0, 15.0, 15.0), child: ButtonTheme( shape: RoundedRectangleBorder( borderRadius: diff --git a/lib/pages/medical/smart_watch_health_data/stepsTracker.dart b/lib/pages/medical/smart_watch_health_data/stepsTracker.dart index 467242e8..3fe1a4ba 100644 --- a/lib/pages/medical/smart_watch_health_data/stepsTracker.dart +++ b/lib/pages/medical/smart_watch_health_data/stepsTracker.dart @@ -84,6 +84,7 @@ class _StepsTrackerState extends State print(res['Med_GetYearStepsTransactionsStsList']); yearlyStepsList.clear(); res['Med_GetYearStepsTransactionsStsList'].forEach((element) { + print('in forEach'); yearlyStepsList.add(new YearlyStepsResModel.fromJson(element)); if (element['ValueSum'] != null) { double value = element['ValueSum']; @@ -91,7 +92,7 @@ class _StepsTrackerState extends State dataLength++; } }); - + print("innnnnnnnnnnnnnnnn"); print(avgStepsValue); print(dataLength); setState(() {