@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
66import 'package:flutter/services.dart' ;
77import 'package:openiothub_api/openiothub_api.dart' ;
88import 'package:openiothub_common_pages/openiothub_common_pages.dart' ;
9+ import 'package:openiothub_common_pages/utils/toast.dart' ;
910import 'package:openiothub_constants/openiothub_constants.dart' ;
1011import 'package:openiothub_grpc_api/google/protobuf/wrappers.pb.dart' ;
1112import 'package:openiothub_grpc_api/proto/manager/common.pb.dart' ;
@@ -145,7 +146,14 @@ class _FindGatewayGoListPageState extends State<FindGatewayGoListPage> {
145146 fixedWidth: 100 ,
146147 ),
147148 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+ }
149157 TextEditingController nameController =
150158 TextEditingController .fromValue (
151159 TextEditingValue (text: "Gateway-${DateTime .now ().minute }" ));
@@ -309,8 +317,7 @@ class _FindGatewayGoListPageState extends State<FindGatewayGoListPage> {
309317 await _addToMySessionList (
310318 openIoTHubJwt.value, gatewayInfo.name, gatewayInfo.description);
311319 } else {
312- TDToast .showText ("Response: ${operationResponse .msg }" ,
313- context: context);
320+ show_failed ("Response: ${operationResponse .msg }" ,context);
314321 }
315322 //自动 添加网关主机
316323 var device = Device ();
@@ -331,7 +338,7 @@ class _FindGatewayGoListPageState extends State<FindGatewayGoListPage> {
331338 tcpConfig.applicationProtocol = "http" ;
332339 await CommonDeviceApi .createOneTCP (tcpConfig);
333340 } catch (exception) {
334- TDToast . showText ("Failed: ${exception }" , context : context);
341+ show_failed ("Failed: ${exception }" , context);
335342 }
336343 }
337344
@@ -402,9 +409,8 @@ loginwithtokenmap:
402409 $uuid : $gatewayJwt
403410''' ;
404411 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);
408414 Navigator .of (context).pop ();
409415 },
410416 )
@@ -420,13 +426,13 @@ loginwithtokenmap:
420426 config.description = description;
421427 try {
422428 await SessionApi .createOneSession (config);
423- TDToast . showText (
429+ show_success (
424430 OpenIoTHubCommonLocalizations .of (context).add_gateway_success,
425- context: context );
431+ context);
426432 } catch (exception) {
427- TDToast . showText (
433+ show_failed (
428434 "${OpenIoTHubCommonLocalizations .of (context ).login_failed }:${exception }" ,
429- context: context );
435+ context);
430436 }
431437 // TODO 添加网关主机及网关软件的端口
432438 }
0 commit comments