@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
6
6
import 'package:flutter/services.dart' ;
7
7
import 'package:openiothub_api/openiothub_api.dart' ;
8
8
import 'package:openiothub_common_pages/openiothub_common_pages.dart' ;
9
+ import 'package:openiothub_common_pages/utils/toast.dart' ;
9
10
import 'package:openiothub_constants/openiothub_constants.dart' ;
10
11
import 'package:openiothub_grpc_api/google/protobuf/wrappers.pb.dart' ;
11
12
import 'package:openiothub_grpc_api/proto/manager/common.pb.dart' ;
@@ -145,7 +146,14 @@ class _FindGatewayGoListPageState extends State<FindGatewayGoListPage> {
145
146
fixedWidth: 100 ,
146
147
),
147
148
trailing: Constants .rightArrowIcon,
148
- onTap: () {
149
+ onTap: () async {
150
+ if (! (await userSignedIn ())) {
151
+ show_failed ("Please login before Add Gateway" , context);
152
+ if (! (await userSignedIn ())) {
153
+ Navigator .of (context).push (MaterialPageRoute (
154
+ builder: (context) => LoginPage ()));
155
+ }
156
+ }
149
157
TextEditingController nameController =
150
158
TextEditingController .fromValue (
151
159
TextEditingValue (text: "Gateway-${DateTime .now ().minute }" ));
@@ -309,8 +317,7 @@ class _FindGatewayGoListPageState extends State<FindGatewayGoListPage> {
309
317
await _addToMySessionList (
310
318
openIoTHubJwt.value, gatewayInfo.name, gatewayInfo.description);
311
319
} else {
312
- TDToast .showText ("Response: ${operationResponse .msg }" ,
313
- context: context);
320
+ show_failed ("Response: ${operationResponse .msg }" ,context);
314
321
}
315
322
//自动 添加网关主机
316
323
var device = Device ();
@@ -331,7 +338,7 @@ class _FindGatewayGoListPageState extends State<FindGatewayGoListPage> {
331
338
tcpConfig.applicationProtocol = "http" ;
332
339
await CommonDeviceApi .createOneTCP (tcpConfig);
333
340
} catch (exception) {
334
- TDToast . showText ("Failed: ${exception }" , context : context);
341
+ show_failed ("Failed: ${exception }" , context);
335
342
}
336
343
}
337
344
@@ -402,9 +409,8 @@ loginwithtokenmap:
402
409
$uuid : $gatewayJwt
403
410
''' ;
404
411
Clipboard .setData (ClipboardData (text: data));
405
- TDToast .showText (
406
- OpenIoTHubCommonLocalizations .of (context).paste_info,
407
- context: context);
412
+ show_success (
413
+ OpenIoTHubCommonLocalizations .of (context).paste_info, context);
408
414
Navigator .of (context).pop ();
409
415
},
410
416
)
@@ -420,13 +426,13 @@ loginwithtokenmap:
420
426
config.description = description;
421
427
try {
422
428
await SessionApi .createOneSession (config);
423
- TDToast . showText (
429
+ show_success (
424
430
OpenIoTHubCommonLocalizations .of (context).add_gateway_success,
425
- context: context );
431
+ context);
426
432
} catch (exception) {
427
- TDToast . showText (
433
+ show_failed (
428
434
"${OpenIoTHubCommonLocalizations .of (context ).login_failed }:${exception }" ,
429
- context: context );
435
+ context);
430
436
}
431
437
// TODO 添加网关主机及网关软件的端口
432
438
}
0 commit comments