|
|
@@ -29,6 +29,8 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
Station stationObj;
|
|
|
String name = '物流';
|
|
|
BluetoothUtils bluetooth = BluetoothUtils();
|
|
|
+ List<String> btList = [];
|
|
|
+ Set<String> btSet = Set();
|
|
|
List printTypeList = ["全部", "配件商", "修理厂", "司机", "货物", "货物外", "不打印"];
|
|
|
static
|
|
|
var printTypeMap = {
|
|
|
@@ -85,7 +87,14 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
}
|
|
|
|
|
|
onEvent(Object obj) {
|
|
|
- print(obj.toString());
|
|
|
+ setState(() {
|
|
|
+ if(obj.toString().indexOf('||')!=-1){
|
|
|
+ int index = obj.toString().indexOf('||');
|
|
|
+ String temp = obj.toString().substring(0,index);
|
|
|
+ btSet.add(temp);
|
|
|
+ btList =btSet.toList();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
onError(Object obj) {
|
|
|
@@ -180,7 +189,7 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
_passWordWidget(),
|
|
|
_linkPrint(check),
|
|
|
_printType(),
|
|
|
- //_quitWidget(context)
|
|
|
+ _btList()
|
|
|
],
|
|
|
),
|
|
|
);
|
|
|
@@ -369,7 +378,8 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
value: this.check,
|
|
|
activeColor: Colors.blue,
|
|
|
onChanged: (bool val) {
|
|
|
- bluetooth.isBTDevice().then((resp) {
|
|
|
+ if(val){
|
|
|
+ bluetooth.isBTDevice().then((resp) {
|
|
|
if (resp) {
|
|
|
bluetooth.isEnableBluetooth().then((bool resp) {
|
|
|
this.setState(() {
|
|
|
@@ -380,6 +390,15 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
+ }else{
|
|
|
+ bluetooth.disConnnectBT();
|
|
|
+ setState(() {
|
|
|
+ this.check = val;
|
|
|
+ btList.clear();
|
|
|
+ btSet.clear();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
)
|
|
|
],
|
|
|
@@ -439,49 +458,54 @@ class _MyPageState extends State < MyPage > with AutomaticKeepAliveClientMixin {
|
|
|
},
|
|
|
);
|
|
|
}
|
|
|
- Widget _quitWidget(BuildContext context) {
|
|
|
+
|
|
|
+ Widget _btList() {
|
|
|
+ return Container(
|
|
|
+ height: ScreenUtil.getInstance().setHeight(350),
|
|
|
+ padding: EdgeInsets.all(ScreenUtil.getInstance().setHeight(30)),
|
|
|
+ child: ListView.builder(
|
|
|
+ itemCount:btList.length,
|
|
|
+ itemBuilder: (BuildContext context, int index) {
|
|
|
+
|
|
|
+ return _btItem(btList[index]);
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+ )
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _btItem(String name) {
|
|
|
return InkWell(
|
|
|
- child: Container(
|
|
|
- height: ScreenUtil.getInstance().setHeight(90),
|
|
|
- color: Colors.white,
|
|
|
- padding: EdgeInsets.fromLTRB(ScreenUtil.getInstance().setHeight(30), 0, 0, 0),
|
|
|
- margin: EdgeInsets.only(top: ScreenUtil.getInstance().setHeight(20)),
|
|
|
- child: Column(
|
|
|
+ child: Padding(
|
|
|
+ padding: EdgeInsets.only(bottom: ScreenUtil.getInstance().setHeight(30)),
|
|
|
+ child: Row(
|
|
|
+ mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
children: < Widget > [
|
|
|
- Expanded(
|
|
|
- child: Center(
|
|
|
- child: Row(
|
|
|
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
|
- children: < Widget > [
|
|
|
- Text('退出', style: TextStyle(fontSize: ScreenUtil.getInstance().setSp(30), color: Color.fromRGBO(74, 74, 74, 1)), ),
|
|
|
- Icon(Icons.keyboard_arrow_right, color: Color.fromRGBO(199, 199, 204, 1))
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
+ Text(name),
|
|
|
+ CircleAvatar(
|
|
|
+ backgroundColor: Colors.grey,
|
|
|
+ radius: 6,
|
|
|
)
|
|
|
],
|
|
|
)
|
|
|
),
|
|
|
- onTap: () {
|
|
|
- showDialog < Null > (
|
|
|
- context: context, //BuildContext对象
|
|
|
- barrierDismissible: false,
|
|
|
- builder: (BuildContext context) {
|
|
|
- return new LoadingDialog( //调用对话框
|
|
|
- text: '确认退出?', childCallback: (val) {
|
|
|
- if (val) {
|
|
|
- clearKey();
|
|
|
- Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) {
|
|
|
- return LoginPage();
|
|
|
- }));
|
|
|
- } else {
|
|
|
- return;
|
|
|
- }
|
|
|
- },
|
|
|
- );
|
|
|
- });
|
|
|
+ onTap: (){
|
|
|
+ print('链接');
|
|
|
},
|
|
|
);
|
|
|
+ }
|
|
|
|
|
|
+ Widget _searchBt(){
|
|
|
+ return InkWell(
|
|
|
+ child: Center(
|
|
|
+ child: Container(
|
|
|
+ width: 160,
|
|
|
+ height: 30,
|
|
|
+ color: Colors.blue,
|
|
|
+ child: Text('扫描中'),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
}
|
|
|
}
|