Minor fixes
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
<application
|
<application
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
android:label="ThingsBoard App"
|
android:label="ThingsBoard App"
|
||||||
|
android:networkSecurityConfig="@xml/network_security_config"
|
||||||
android:icon="@mipmap/launcher_icon">
|
android:icon="@mipmap/launcher_icon">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
@@ -49,5 +50,7 @@
|
|||||||
android:name="flutterEmbedding"
|
android:name="flutterEmbedding"
|
||||||
android:value="2"
|
android:value="2"
|
||||||
/>
|
/>
|
||||||
|
<meta-data android:name="io.flutter.network-policy"
|
||||||
|
android:resource="@xml/network_security_config"/>
|
||||||
</application>
|
</application>
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
4
android/app/src/main/res/xml/network_security_config.xml
Normal file
4
android/app/src/main/res/xml/network_security_config.xml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<network-security-config>
|
||||||
|
<base-config cleartextTrafficPermitted="true" />
|
||||||
|
</network-security-config>
|
||||||
@@ -275,6 +275,7 @@ class TbContext {
|
|||||||
await navigateToDashboard(defaultDashboardId, animate: false);
|
await navigateToDashboard(defaultDashboardId, animate: false);
|
||||||
navigateTo('/home',
|
navigateTo('/home',
|
||||||
replace: true,
|
replace: true,
|
||||||
|
closeDashboard: false,
|
||||||
transition: TransitionType.none);
|
transition: TransitionType.none);
|
||||||
} else {
|
} else {
|
||||||
navigateTo('/fullscreenDashboard/$defaultDashboardId',
|
navigateTo('/fullscreenDashboard/$defaultDashboardId',
|
||||||
@@ -323,11 +324,11 @@ class TbContext {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> navigateTo(String path, {bool replace = false, bool clearStack = false,
|
Future<dynamic> navigateTo(String path, {bool replace = false, bool clearStack = false, closeDashboard = true,
|
||||||
TransitionType? transition, Duration? transitionDuration, bool restoreDashboard = true}) async {
|
TransitionType? transition, Duration? transitionDuration, bool restoreDashboard = true}) async {
|
||||||
if (currentState != null) {
|
if (currentState != null) {
|
||||||
hideNotification();
|
hideNotification();
|
||||||
bool isOpenedDashboard = _mainDashboardHolder?.isDashboardOpen() == true;
|
bool isOpenedDashboard = _mainDashboardHolder?.isDashboardOpen() == true && closeDashboard;
|
||||||
if (isOpenedDashboard) {
|
if (isOpenedDashboard) {
|
||||||
_mainDashboardHolder?.openMain();
|
_mainDashboardHolder?.openMain();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,136 +183,131 @@ class _DashboardState extends TbContextState<Dashboard, _DashboardState> {
|
|||||||
if (!ready) {
|
if (!ready) {
|
||||||
return SizedBox.shrink();
|
return SizedBox.shrink();
|
||||||
} else {
|
} else {
|
||||||
return Container(
|
return Stack(
|
||||||
decoration: BoxDecoration(color: Colors.white),
|
children: [
|
||||||
child: SafeArea(
|
InAppWebView(
|
||||||
child: Stack(
|
key: webViewKey,
|
||||||
children: [
|
initialUrlRequest: URLRequest(url: _initialUrl),
|
||||||
InAppWebView(
|
initialOptions: options,
|
||||||
key: webViewKey,
|
onWebViewCreated: (webViewController) {
|
||||||
initialUrlRequest: URLRequest(url: _initialUrl),
|
log.debug("onWebViewCreated");
|
||||||
initialOptions: options,
|
webViewController.addJavaScriptHandler(handlerName: "tbMobileDashboardLoadedHandler", callback: (args) async {
|
||||||
onWebViewCreated: (webViewController) {
|
log.debug("Invoked tbMobileDashboardLoadedHandler");
|
||||||
log.debug("onWebViewCreated");
|
dashboardLoading.value = false;
|
||||||
webViewController.addJavaScriptHandler(handlerName: "tbMobileDashboardLoadedHandler", callback: (args) async {
|
});
|
||||||
log.debug("Invoked tbMobileDashboardLoadedHandler");
|
webViewController.addJavaScriptHandler(handlerName: "tbMobileDashboardStateNameHandler", callback: (args) async {
|
||||||
dashboardLoading.value = false;
|
log.debug("Invoked tbMobileDashboardStateNameHandler: $args");
|
||||||
});
|
if (args.isNotEmpty && args[0] is String) {
|
||||||
webViewController.addJavaScriptHandler(handlerName: "tbMobileDashboardStateNameHandler", callback: (args) async {
|
if (widget._titleCallback != null) {
|
||||||
log.debug("Invoked tbMobileDashboardStateNameHandler: $args");
|
widget._titleCallback!(args[0]);
|
||||||
if (args.isNotEmpty && args[0] is String) {
|
}
|
||||||
if (widget._titleCallback != null) {
|
}
|
||||||
widget._titleCallback!(args[0]);
|
});
|
||||||
}
|
webViewController.addJavaScriptHandler(handlerName: "tbMobileNavigationHandler", callback: (args) async {
|
||||||
}
|
log.debug("Invoked tbMobileNavigationHandler: $args");
|
||||||
});
|
if (args.length > 0) {
|
||||||
webViewController.addJavaScriptHandler(handlerName: "tbMobileNavigationHandler", callback: (args) async {
|
String? path = args[0];
|
||||||
log.debug("Invoked tbMobileNavigationHandler: $args");
|
Map<String, dynamic>? params;
|
||||||
if (args.length > 0) {
|
if (args.length > 1) {
|
||||||
String? path = args[0];
|
params = args[1];
|
||||||
Map<String, dynamic>? params;
|
}
|
||||||
if (args.length > 1) {
|
log.debug("path: $path");
|
||||||
params = args[1];
|
log.debug("params: $params");
|
||||||
}
|
if (path != null) {
|
||||||
log.debug("path: $path");
|
if ([
|
||||||
log.debug("params: $params");
|
'profile',
|
||||||
if (path != null) {
|
'devices',
|
||||||
if ([
|
'assets',
|
||||||
'profile',
|
'dashboards',
|
||||||
'devices',
|
'customers',
|
||||||
'assets',
|
'auditLogs'
|
||||||
'dashboards',
|
].contains(path)) {
|
||||||
'customers',
|
var targetPath = '/$path';
|
||||||
'auditLogs'
|
if (path == 'devices' && widget._home != true) {
|
||||||
].contains(path)) {
|
targetPath = '/devicesPage';
|
||||||
var targetPath = '/$path';
|
|
||||||
if (path == 'devices' && widget._home != true) {
|
|
||||||
targetPath = '/devicesPage';
|
|
||||||
}
|
|
||||||
navigateTo(targetPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
webViewController.addJavaScriptHandler(handlerName: "tbMobileHandler", callback: (args) async {
|
|
||||||
log.debug("Invoked tbMobileHandler: $args");
|
|
||||||
return await widgetActionHandler.handleWidgetMobileAction(args, webViewController);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
|
||||||
var uri = navigationAction.request.url!;
|
|
||||||
var uriString = uri.toString();
|
|
||||||
log.debug('shouldOverrideUrlLoading $uriString');
|
|
||||||
if (![
|
|
||||||
"http",
|
|
||||||
"https",
|
|
||||||
"file",
|
|
||||||
"chrome",
|
|
||||||
"data",
|
|
||||||
"javascript",
|
|
||||||
"about"
|
|
||||||
].contains(uri.scheme)) {
|
|
||||||
if (await canLaunch(uriString)) {
|
|
||||||
// Launch the App
|
|
||||||
await launch(
|
|
||||||
uriString,
|
|
||||||
);
|
|
||||||
// and cancel the request
|
|
||||||
return NavigationActionPolicy.CANCEL;
|
|
||||||
}
|
}
|
||||||
|
navigateTo(targetPath);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
webViewController.addJavaScriptHandler(handlerName: "tbMobileHandler", callback: (args) async {
|
||||||
|
log.debug("Invoked tbMobileHandler: $args");
|
||||||
|
return await widgetActionHandler.handleWidgetMobileAction(args, webViewController);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
shouldOverrideUrlLoading: (controller, navigationAction) async {
|
||||||
|
var uri = navigationAction.request.url!;
|
||||||
|
var uriString = uri.toString();
|
||||||
|
log.debug('shouldOverrideUrlLoading $uriString');
|
||||||
|
if (![
|
||||||
|
"http",
|
||||||
|
"https",
|
||||||
|
"file",
|
||||||
|
"chrome",
|
||||||
|
"data",
|
||||||
|
"javascript",
|
||||||
|
"about"
|
||||||
|
].contains(uri.scheme)) {
|
||||||
|
if (await canLaunch(uriString)) {
|
||||||
|
// Launch the App
|
||||||
|
await launch(
|
||||||
|
uriString,
|
||||||
|
);
|
||||||
|
// and cancel the request
|
||||||
|
return NavigationActionPolicy.CANCEL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Platform.isIOS ? NavigationActionPolicy.ALLOW : NavigationActionPolicy.CANCEL;
|
return Platform.isIOS ? NavigationActionPolicy.ALLOW : NavigationActionPolicy.CANCEL;
|
||||||
},
|
},
|
||||||
onUpdateVisitedHistory: (controller, url, androidIsReload) async {
|
onUpdateVisitedHistory: (controller, url, androidIsReload) async {
|
||||||
log.debug('onUpdateVisitedHistory: url');
|
log.debug('onUpdateVisitedHistory: url');
|
||||||
_dashboardController.onHistoryUpdated(controller.canGoBack());
|
_dashboardController.onHistoryUpdated(controller.canGoBack());
|
||||||
},
|
},
|
||||||
onConsoleMessage: (controller, consoleMessage) {
|
onConsoleMessage: (controller, consoleMessage) {
|
||||||
log.debug('[JavaScript console] ${consoleMessage.messageLevel}: ${consoleMessage.message}');
|
log.debug('[JavaScript console] ${consoleMessage.messageLevel}: ${consoleMessage.message}');
|
||||||
},
|
},
|
||||||
onLoadStart: (controller, url) async {
|
onLoadStart: (controller, url) async {
|
||||||
log.debug('onLoadStart: $url');
|
log.debug('onLoadStart: $url');
|
||||||
},
|
},
|
||||||
onLoadStop: (controller, url) async {
|
onLoadStop: (controller, url) async {
|
||||||
log.debug('onLoadStop: $url');
|
log.debug('onLoadStop: $url');
|
||||||
if (webViewLoading) {
|
if (webViewLoading) {
|
||||||
webViewLoading = false;
|
webViewLoading = false;
|
||||||
_controller.complete(controller);
|
_controller.complete(controller);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
androidOnPermissionRequest: (controller, origin, resources) async {
|
androidOnPermissionRequest: (controller, origin, resources) async {
|
||||||
log.debug('androidOnPermissionRequest origin: $origin, resources: $resources');
|
log.debug('androidOnPermissionRequest origin: $origin, resources: $resources');
|
||||||
return PermissionRequestResponse(
|
return PermissionRequestResponse(
|
||||||
resources: resources,
|
resources: resources,
|
||||||
action: PermissionRequestResponseAction.GRANT);
|
action: PermissionRequestResponseAction.GRANT);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ValueListenableBuilder(
|
ValueListenableBuilder(
|
||||||
valueListenable: dashboardLoading,
|
valueListenable: dashboardLoading,
|
||||||
builder: (BuildContext context, bool loading, child) {
|
builder: (BuildContext context, bool loading, child) {
|
||||||
if (!loading) {
|
if (!loading) {
|
||||||
return SizedBox.shrink();
|
return SizedBox.shrink();
|
||||||
} else {
|
} else {
|
||||||
var data = MediaQueryData.fromWindow(WidgetsBinding.instance!.window);
|
var data = MediaQueryData.fromWindow(WidgetsBinding.instance!.window);
|
||||||
var bottomPadding = data.padding.top;
|
var bottomPadding = data.padding.top;
|
||||||
if (widget._home != true) {
|
if (widget._home != true) {
|
||||||
bottomPadding += kToolbarHeight;
|
bottomPadding += kToolbarHeight;
|
||||||
}
|
}
|
||||||
return Container(
|
return Container(
|
||||||
padding: EdgeInsets.only(bottom: bottomPadding),
|
padding: EdgeInsets.only(bottom: bottomPadding),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
child: TbProgressIndicator(
|
child: TbProgressIndicator(
|
||||||
size: 50.0
|
size: 50.0
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
)
|
||||||
),
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
import 'package:thingsboard_app/core/context/tb_context.dart';
|
import 'package:thingsboard_app/core/context/tb_context.dart';
|
||||||
@@ -147,6 +148,7 @@ class _MainPageState extends TbPageState<MainPage, _MainPageState> with TbMainSt
|
|||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: TabBarView(
|
body: TabBarView(
|
||||||
|
physics: tbContext.homeDashboard != null ? NeverScrollableScrollPhysics() : null,
|
||||||
controller: _tabController,
|
controller: _tabController,
|
||||||
children: _tabItems.map((item) => item.page).toList(),
|
children: _tabItems.map((item) => item.page).toList(),
|
||||||
),
|
),
|
||||||
@@ -162,7 +164,7 @@ class _MainPageState extends TbPageState<MainPage, _MainPageState> with TbMainSt
|
|||||||
)).toList()
|
)).toList()
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
),
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,10 +113,8 @@ class _TransitionIndexedStackState extends State<TransitionIndexedStack> with Ti
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return Stack(
|
||||||
child: Stack(
|
children: _pages,
|
||||||
children: _pages,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user