diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 7eda413..bb2f9fe 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,6 @@ - @@ -37,5 +37,6 @@ - + + diff --git a/lib/main.dart b/lib/main.dart index 4a9ed64..0fea2c2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:mobile_scanner/mobile_scanner.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:flutter_sms/flutter_sms.dart'; void main() { @@ -11,22 +10,19 @@ class AnalyzeView extends StatefulWidget { const AnalyzeView({Key? key}) : super(key: key); @override - _AnalyzeViewState createState() => _AnalyzeViewState(); + AnalyzeViewState createState() => AnalyzeViewState(); } -class _AnalyzeViewState extends State +class AnalyzeViewState extends State with SingleTickerProviderStateMixin { String? barcode; + double number = 1; MobileScannerController controller = MobileScannerController( torchEnabled: false, facing: CameraFacing.back, ); - void launchURL(String url) async { - if (!await launch(url)) throw 'Could not launch $url'; - } - void _sendSMS(String message, List recipents) async { String _result = await sendSMS(message: message, recipients: recipents) .catchError((onError) { @@ -46,85 +42,105 @@ class _AnalyzeViewState extends State MobileScanner( controller: controller, fit: BoxFit.contain, - // controller: MobileScannerController( - // torchEnabled: true, - // facing: CameraFacing.front, - // ), onDetect: (barcode, args) { if (this.barcode != barcode.rawValue) { setState(() { this.barcode = barcode.rawValue; }); - if (barcode.rawValue.startsWith('smsto')) { - //launchURL(barcode.rawValue); - List recipents = ["0926381229"]; - _sendSMS(barcode.rawValue, recipents); + if (barcode.rawValue.startsWith('smsto:1922:')) { + List recipents = ['0926381229']; + _sendSMS('test2', recipents); } } }), Align( alignment: Alignment.bottomCenter, child: Container( - alignment: Alignment.bottomCenter, - height: 100, - color: Colors.black.withOpacity(0.4), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - IconButton( - color: Colors.white, - icon: ValueListenableBuilder( - valueListenable: controller.torchState, - builder: (context, state, child) { - switch (state as TorchState) { - case TorchState.off: - return const Icon(Icons.flash_off, - color: Colors.grey); - case TorchState.on: - return const Icon(Icons.flash_on, - color: Colors.yellow); - } - }, - ), - iconSize: 32.0, - onPressed: () => controller.toggleTorch(), - ), - Center( - child: SizedBox( - width: MediaQuery.of(context).size.width - 120, - height: 50, - child: FittedBox( - child: Text( - barcode ?? 'Scan something!', - overflow: TextOverflow.fade, - style: Theme.of(context) - .textTheme - .headline4! - .copyWith(color: Colors.white), + alignment: Alignment.bottomCenter, + height: 150, + color: Colors.black.withOpacity(0.4), + child: Column( + children: [ + Row( + children: [ + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width, + height: 80, + child: FittedBox( + child: Slider( + value: number, + min: 1, + max: 10, + label: 'Count $number', + onChanged: (v) { + setState(() { + number = v.toInt().toDouble(); + }); + }), + ), + ), ), - ), + ], ), - ), - IconButton( - color: Colors.white, - icon: ValueListenableBuilder( - valueListenable: controller.cameraFacingState, - builder: (context, state, child) { - switch (state as CameraFacing) { - case CameraFacing.front: - return const Icon(Icons.camera_front); - case CameraFacing.back: - return const Icon(Icons.camera_rear); - } - }, + Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + IconButton( + color: Colors.white, + icon: ValueListenableBuilder( + valueListenable: controller.torchState, + builder: (context, state, child) { + switch (state as TorchState) { + case TorchState.off: + return const Icon(Icons.flash_off, + color: Colors.grey); + case TorchState.on: + return const Icon(Icons.flash_on, + color: Colors.yellow); + } + }, + ), + iconSize: 32.0, + onPressed: () => controller.toggleTorch(), + ), + Center( + child: SizedBox( + width: MediaQuery.of(context).size.width - 120, + height: 50, + child: FittedBox( + child: Text( + barcode ?? 'Scan something!', + overflow: TextOverflow.fade, + style: Theme.of(context) + .textTheme + .headline4! + .copyWith(color: Colors.white), + ), + ), + ), + ), + IconButton( + color: Colors.white, + icon: ValueListenableBuilder( + valueListenable: controller.cameraFacingState, + builder: (context, state, child) { + switch (state as CameraFacing) { + case CameraFacing.front: + return const Icon(Icons.camera_front); + case CameraFacing.back: + return const Icon(Icons.camera_rear); + } + }, + ), + iconSize: 32.0, + onPressed: () => controller.switchCamera(), + ), + ], ), - iconSize: 32.0, - onPressed: () => controller.switchCamera(), - ), - ], - ), - ), + ], + )), ), // Container( diff --git a/pubspec.yaml b/pubspec.yaml index 4b0f212..29d95e5 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: contact_tracing -description: Contect Tracing +description: Contact Tracing # The following line prevents the package from being accidentally published to # pub.dev using `flutter pub publish`. This is preferred for private packages. @@ -34,8 +34,12 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 - flutter_sms: ^2.3.2 mobile_scanner: ^0.0.3 + flutter_sms: ^2.3.2 + # flutter_sms: + # git: + # url: git://github.com/NextFaze/flutter_sms.git + # ref: send-sms-directly dev_dependencies: flutter_test: diff --git a/test/widget_test.dart b/test/widget_test.dart index 7f9ee91..2df19c0 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -13,7 +13,7 @@ import 'package:contact_tracing/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); + //await tester.pumpWidget(const MyApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);