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