diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index bb2f9fe..98c4f31 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -1,7 +1,7 @@
+
diff --git a/lib/main.dart b/lib/main.dart
index 0fea2c2..273c75c 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,3 +1,4 @@
+import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:flutter_sms/flutter_sms.dart';
@@ -16,7 +17,8 @@ class AnalyzeView extends StatefulWidget {
class AnalyzeViewState extends State
with SingleTickerProviderStateMixin {
String? barcode;
- double number = 1;
+ double peopleCount = 1;
+ final String prefix = 'smsto:1922:';
MobileScannerController controller = MobileScannerController(
torchEnabled: false,
@@ -26,9 +28,13 @@ class AnalyzeViewState extends State
void _sendSMS(String message, List recipents) async {
String _result = await sendSMS(message: message, recipients: recipents)
.catchError((onError) {
- print('sms err: $onError');
+ if (kDebugMode) {
+ print('sms err: $onError');
+ }
});
- print('sms res: $_result');
+ if (kDebugMode) {
+ print('sms res: $_result');
+ }
}
@override
@@ -39,20 +45,33 @@ class AnalyzeViewState extends State
body: Builder(builder: (context) {
return Stack(
children: [
- MobileScanner(
- controller: controller,
- fit: BoxFit.contain,
- onDetect: (barcode, args) {
- if (this.barcode != barcode.rawValue) {
- setState(() {
- this.barcode = barcode.rawValue;
- });
- if (barcode.rawValue.startsWith('smsto:1922:')) {
- List recipents = ['0926381229'];
- _sendSMS('test2', recipents);
- }
- }
- }),
+ Align(
+ alignment: Alignment.center,
+ child: Container(
+ width: MediaQuery.of(context).size.width - 100,
+ color: Colors.black.withOpacity(0.0),
+ child: MobileScanner(
+ controller: controller,
+ fit: BoxFit.contain,
+ onDetect: (barcode, args) {
+ if (this.barcode != barcode.rawValue) {
+ setState(() {
+ this.barcode = barcode.rawValue;
+ });
+ String msg = barcode.rawValue.toLowerCase();
+ if (msg.startsWith(prefix)) {
+ List recipents = ['1922'];
+ msg = msg.substring(prefix.length);
+ if (peopleCount > 1) {
+ msg += ' +${peopleCount.toInt()}';
+ }
+ _sendSMS(msg, recipents);
+ }
+ }
+ }),
+ ),
+ ),
+
Align(
alignment: Alignment.bottomCenter,
child: Container(
@@ -62,6 +81,7 @@ class AnalyzeViewState extends State
child: Column(
children: [
Row(
+ crossAxisAlignment: CrossAxisAlignment.center,
children: [
Center(
child: SizedBox(
@@ -69,13 +89,14 @@ class AnalyzeViewState extends State
height: 80,
child: FittedBox(
child: Slider(
- value: number,
+ value: peopleCount,
min: 1,
max: 10,
- label: 'Count $number',
+ divisions: 9,
+ label: 'People: ${peopleCount.toInt()}',
onChanged: (v) {
setState(() {
- number = v.toInt().toDouble();
+ peopleCount = v;
});
}),
),
@@ -107,7 +128,7 @@ class AnalyzeViewState extends State
),
Center(
child: SizedBox(
- width: MediaQuery.of(context).size.width - 120,
+ width: MediaQuery.of(context).size.width - 220,
height: 50,
child: FittedBox(
child: Text(
@@ -115,7 +136,7 @@ class AnalyzeViewState extends State
overflow: TextOverflow.fade,
style: Theme.of(context)
.textTheme
- .headline4!
+ .headlineSmall!
.copyWith(color: Colors.white),
),
),