diff --git a/front/android/app/src/main/AndroidManifest.xml b/front/android/app/src/main/AndroidManifest.xml index 7c7130a..b9b838b 100644 --- a/front/android/app/src/main/AndroidManifest.xml +++ b/front/android/app/src/main/AndroidManifest.xml @@ -5,6 +5,10 @@ In most cases you can leave this as-is, but you if you want to provide additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> + + + + 3.11.4) + - flutter_nfc_reader (0.0.1): + - Flutter + - VYNFCKit + - Protobuf (3.11.4) + - VYNFCKit (0.3.2) + +DEPENDENCIES: + - Flutter (from `Flutter`) + - flutter_blue (from `.symlinks/plugins/flutter_blue/ios`) + - flutter_nfc_reader (from `.symlinks/plugins/flutter_nfc_reader/ios`) + +SPEC REPOS: + trunk: + - Protobuf + - VYNFCKit + +EXTERNAL SOURCES: + Flutter: + :path: Flutter + flutter_blue: + :path: ".symlinks/plugins/flutter_blue/ios" + flutter_nfc_reader: + :path: ".symlinks/plugins/flutter_nfc_reader/ios" + +SPEC CHECKSUMS: + Flutter: 0e3d915762c693b495b44d77113d4970485de6ec + flutter_blue: eeb381dc4727a0954dede73515f683865494b370 + flutter_nfc_reader: 67d71071d779d28b827ea50dcbe00d09286f253d + Protobuf: 176220c526ad8bd09ab1fb40a978eac3fef665f7 + VYNFCKit: 86a9b711fd1f34f6f7128a2a883cd58dbd781b9d + +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c + +COCOAPODS: 1.10.0 diff --git a/front/ios/Runner.xcodeproj/project.pbxproj b/front/ios/Runner.xcodeproj/project.pbxproj index 2520771..19d16c5 100644 --- a/front/ios/Runner.xcodeproj/project.pbxproj +++ b/front/ios/Runner.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; + BD0415987DA1D438C4275D1C /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3DAC4FB2A5C7DF28B46B430A /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -31,7 +32,9 @@ /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 30F1770DF4635C996EE8E56D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3DAC4FB2A5C7DF28B46B430A /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -42,6 +45,8 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + C2FDC04290EA6164F598793C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + CF7C45D1D5DDEE41373F31FD /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -49,12 +54,32 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + BD0415987DA1D438C4275D1C /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 31DFC141E9177474E6A6C9FF /* Frameworks */ = { + isa = PBXGroup; + children = ( + 3DAC4FB2A5C7DF28B46B430A /* Pods_Runner.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 485B5F077DC96AD9DB9E4B87 /* Pods */ = { + isa = PBXGroup; + children = ( + 30F1770DF4635C996EE8E56D /* Pods-Runner.debug.xcconfig */, + CF7C45D1D5DDEE41373F31FD /* Pods-Runner.release.xcconfig */, + C2FDC04290EA6164F598793C /* Pods-Runner.profile.xcconfig */, + ); + name = Pods; + path = Pods; + sourceTree = ""; + }; 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( @@ -72,6 +97,8 @@ 9740EEB11CF90186004384FC /* Flutter */, 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, + 485B5F077DC96AD9DB9E4B87 /* Pods */, + 31DFC141E9177474E6A6C9FF /* Frameworks */, ); sourceTree = ""; }; @@ -105,12 +132,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( + 6806E96B85DB019C39FD6686 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + 50164F27F11B94728878B8C8 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -183,6 +212,45 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; + 50164F27F11B94728878B8C8 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; + 6806E96B85DB019C39FD6686 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; diff --git a/front/ios/Runner.xcworkspace/contents.xcworkspacedata b/front/ios/Runner.xcworkspace/contents.xcworkspacedata index 1d526a1..21a3cc1 100644 --- a/front/ios/Runner.xcworkspace/contents.xcworkspacedata +++ b/front/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -4,4 +4,7 @@ + + diff --git a/front/lib/routes/RegTempDevice.dart b/front/lib/routes/RegTempDevice.dart index d9789d4..ca67155 100644 --- a/front/lib/routes/RegTempDevice.dart +++ b/front/lib/routes/RegTempDevice.dart @@ -1,48 +1,97 @@ import 'package:amazon_cognito_identity_dart_2/cognito.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_blue/flutter_blue.dart'; import './AccountMenu.dart'; -class RegTempDevice extends StatelessWidget { +class RegTempDevice extends StatefulWidget { final CognitoUserSession _session; RegTempDevice(this._session); + @override + _RegTempDeviceState createState() => _RegTempDeviceState(_session); +} + +class _RegTempDeviceState extends State { + final CognitoUserSession _session; + + List deviceList; + + _RegTempDeviceState(this._session); + + @override + void initState() { + super.initState(); + _scan(); + } + @override Widget build(BuildContext context) { + List _widgets = []; + + if(deviceList == null) { + deviceList = []; + } + for(var result in deviceList) { + _widgets.add(Card( + child: ListTile( + title: Text(result.device.name), + trailing: Icon(Icons.arrow_right), + onTap: () => { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => AccountMenu(_session)) + ) + }, + ), + )); + } + + var base = [ + ListTile(title: Text('検温デバイス設定')), + Padding( + padding: EdgeInsets.only(top: 10.0, right: 30.0, bottom: 10.0, left: 30.0), + child: Text( + '下に表示されるリストの中から、登録するデバイスを選択してください。' + ), + ), + Padding( + padding: EdgeInsets.only(top: 10.0, right: 30.0, bottom: 10.0, left: 30.0), + child: Text( + '表示されない場合は、以下の2点をご確認ください。\n ・機器の電源が入っているか\n ・スマートフォンと機器を近づけているか' + ), + ), + ListTile(title: Text('検出した検温デバイス一覧')), + ]; + + base.addAll(_widgets); + return Scaffold( appBar: AppBar( title: Text('検温デバイス設定'), ), body: ListView( - children: [ - ListTile(title: Text('検温デバイス設定')), - Padding( - padding: EdgeInsets.only(top: 10.0, right: 30.0, bottom: 10.0, left: 30.0), - child: Text( - '下に表示されるリストの中から、登録するデバイスを選択してください。' - ), - ), - Padding( - padding: EdgeInsets.only(top: 10.0, right: 30.0, bottom: 10.0, left: 30.0), - child: Text( - '表示されない場合は、以下の2点をご確認ください。\n ・機器の電源が入っているか\n ・スマートフォンと機器を近づけているか' - ), - ), - ListTile(title: Text('検出した検温デバイス一覧')), - Card( - child: ListTile( - title: Text('MAKURA Device'), - trailing: Icon(Icons.arrow_right), - onTap: () => { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => AccountMenu(_session)) - ) - }, - ), - ), - ], + children: base, ) ); } + + _scan() { + FlutterBlue flutterBlue = FlutterBlue.instance; + // Start scanning + flutterBlue.startScan(timeout: Duration(seconds: 4)); + + // Listen to scan results + flutterBlue.scanResults.listen((results) { + // do something with scan results + for (ScanResult r in results) { + print('${r.device.name} found! rssi: ${r.rssi}'); + } + // deviceList = results; + }); + + // Stop scanning + flutterBlue.stopScan(); + print('Scan stoped.'); + } } diff --git a/front/lib/routes/TempLog.dart b/front/lib/routes/TempLog.dart index 0824bf3..b4ba627 100644 --- a/front/lib/routes/TempLog.dart +++ b/front/lib/routes/TempLog.dart @@ -26,7 +26,7 @@ class TempLog extends StatelessWidget { onTap: () => { Navigator.push( context, - MaterialPageRoute(builder: (context) => TempLogTempDevice()) + MaterialPageRoute(builder: (context) => TempLogTempDevice(_session)) ) }, ), diff --git a/front/lib/routes/TempLogTempDevice.dart b/front/lib/routes/TempLogTempDevice.dart index 59fa3f7..139c168 100644 --- a/front/lib/routes/TempLogTempDevice.dart +++ b/front/lib/routes/TempLogTempDevice.dart @@ -1,23 +1,70 @@ +import 'dart:convert'; + +import 'package:amazon_cognito_identity_dart_2/cognito.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:http/http.dart' as http; + +class TempLogTempDevice extends StatefulWidget { + final CognitoUserSession _session; + + TempLogTempDevice(this._session); + + @override + _TempLogState createState() => _TempLogState(_session); +} + +class _TempLogState extends State { + final CognitoUserSession _session; + + List tempList; + + _TempLogState(this._session); + + @override + void initState() { + super.initState(); + _fetch(); + tempList = []; + } -class TempLogTempDevice extends StatelessWidget { @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Text('User Device 1 Data'), - ), - body: ListView( - children: [ - ListTile(title: Text('User Device 1')), - ListTile( - title: Text('2020/11/01 12:00'), - subtitle: Text('36.5℃'), - ), - ], - ) - - - ); + + List _widgets = []; + + print(tempList); + if(tempList == null) { + tempList = []; + } + + for (var temp in tempList) { + print(temp); + _widgets.add(ListTile( + title: Text(temp['measuredTime']), + subtitle: Text(temp['temperature'].toString()), + )); + } + return Scaffold( + appBar: AppBar( + title: Text('User Device 1 Data'), + ), + body: ListView( + children: _widgets, + ) + ); + } + + _fetch() async { + var response = await http.get(DotEnv().env['API_BASE'] + '/temperature/body?offset=0&count=10', + headers: {'Authorization': _session.getIdToken().getJwtToken()}); + + print(response.statusCode); + + var data = jsonDecode(response.body); + print(data); + setState(() { + tempList = data['Logs']; + }); } } diff --git a/front/lib/routes/TempReqest.dart b/front/lib/routes/TempReqest.dart index 1a003e1..6a35269 100644 --- a/front/lib/routes/TempReqest.dart +++ b/front/lib/routes/TempReqest.dart @@ -1,11 +1,15 @@ +import 'dart:convert'; + import 'package:amazon_cognito_identity_dart_2/cognito.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_dotenv/flutter_dotenv.dart'; +import 'package:http/http.dart' as http; import './UserMenu.dart'; class TempReqest extends StatelessWidget { final CognitoUserSession _session; final _tempKey = GlobalKey(); - String _nowTemp = ''; + final _tempController = TextEditingController(); TempReqest(this._session); @@ -27,26 +31,61 @@ class TempReqest extends StatelessWidget { labelText: "現在の体温を入力", // ラベル hintText: '体温', // 入力ヒント ), - autovalidate: false, // 入力変化しても自動でチェックしない。trueにすると初期状態および入力が変化する毎に自動でvalidatorがコールされる validator: (value) { // _formKey.currentState.validate()でコールされる if (value.isEmpty) { return '入力してください'; // エラー表示のメッセージを返す } return null; // 問題ない場合はnullを返す }, - onSaved: (value) => () { // this._formKey.currentState.save()でコールされる - _nowTemp = value; - }, + controller: _tempController, ), ), Align( alignment: Alignment.center, child: RaisedButton( - onPressed: () { + onPressed: () async { // 各Fieldのvalidatorを呼び出す if (_tempKey.currentState.validate()) { - // 入力データが正常な場合の処理 - this._tempKey.currentState.save(); + var response = await http.post(DotEnv().env['API_BASE'] + '/temperature/body', + headers: {'Authorization': _session.getIdToken().getJwtToken()}, + body: json.encode({ + 'body_temperature': double.parse(_tempController.text), + 'mac_address': "FROM_APP", + })); + if(response.statusCode == 201) { + await showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return AlertDialog( + title: Text('登録に成功しました!'), + actions: [ + FlatButton( + child: Text('OK'), + onPressed: () => Navigator.of(context).pop(1), + ), + ], + ); + }, + ); + } else { + await showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return AlertDialog( + title: Text('エラー'), + content: Text(response.body), + actions: [ + FlatButton( + child: Text('OK'), + onPressed: () => Navigator.of(context).pop(1), + ), + ], + ); + }, + ); + } Navigator.push( context, MaterialPageRoute( diff --git a/front/pubspec.lock b/front/pubspec.lock index 024c9e6..133c0dd 100644 --- a/front/pubspec.lock +++ b/front/pubspec.lock @@ -99,11 +99,25 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0-nullsafety.1" + fixnum: + dependency: transitive + description: + name: fixnum + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.11" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_blue: + dependency: "direct main" + description: + name: flutter_blue + url: "https://pub.dartlang.org" + source: hosted + version: "0.7.2" flutter_dotenv: dependency: "direct main" description: @@ -193,6 +207,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.0" + protobuf: + dependency: transitive + description: + name: protobuf + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" + rxdart: + dependency: transitive + description: + name: rxdart + url: "https://pub.dartlang.org" + source: hosted + version: "0.24.1" sky_engine: dependency: transitive description: flutter diff --git a/front/pubspec.yaml b/front/pubspec.yaml index 1ea2b7f..5028429 100644 --- a/front/pubspec.yaml +++ b/front/pubspec.yaml @@ -31,6 +31,7 @@ dependencies: email_validator: '^1.0.5' flutter_dotenv: ^2.0.1 http: ^0.12.2 + flutter_blue: ^0.7.2 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons.