Skip to content

Commit 05b3da4

Browse files
committed
Please login before Add Gateway
git tag v1.0.5+78
1 parent 9b9ec5a commit 05b3da4

File tree

4 files changed

+53
-12
lines changed

4 files changed

+53
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.0.5+78]
2+
3+
* Please login before Add Gateway
4+
15
## [1.0.5+77]
26

37
* Fix TCP

lib/commPages/findGatewayGoList.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
66
import 'package:flutter/services.dart';
77
import 'package:openiothub_api/openiothub_api.dart';
88
import 'package:openiothub_common_pages/openiothub_common_pages.dart';
9+
import 'package:openiothub_common_pages/utils/toast.dart';
910
import 'package:openiothub_constants/openiothub_constants.dart';
1011
import 'package:openiothub_grpc_api/google/protobuf/wrappers.pb.dart';
1112
import '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
}

lib/utils/toast.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
import 'package:flutter/cupertino.dart';
3+
import 'package:tdesign_flutter/tdesign_flutter.dart';
4+
5+
show_success(String msg, BuildContext context) {
6+
TDMessage.showMessage(
7+
context: context,
8+
content: msg,
9+
visible: true,
10+
icon: false,
11+
theme: MessageTheme.success,
12+
duration: 3000,
13+
onDurationEnd: () {
14+
print('message end');
15+
},
16+
);
17+
}
18+
19+
show_failed(String msg, BuildContext context) {
20+
TDMessage.showMessage(
21+
context: context,
22+
content: msg,
23+
visible: true,
24+
icon: false,
25+
theme: MessageTheme.error,
26+
duration: 3000,
27+
onDurationEnd: () {
28+
print('message end');
29+
},
30+
);
31+
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: openiothub_common_pages
22
description: openiothub_common_pages
3-
version: 1.0.5+77
3+
version: 1.0.5+78
44
homepage: https://github.com/OpenIoTHub
55

66
environment:

0 commit comments

Comments
 (0)