has crash when popup msgbox when there is keyboard or some other
condition
BIN
flutter_hbb/assets/insecure.png
Normal file
After Width: | Height: | Size: 4.0 KiB |
BIN
flutter_hbb/assets/insecure_relay.png
Normal file
After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 2.8 KiB |
BIN
flutter_hbb/assets/secure.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
BIN
flutter_hbb/assets/secure_relay.png
Normal file
After Width: | Height: | Size: 5.0 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.3 KiB |
@ -64,12 +64,13 @@ Future<T> showAlertDialog<T>(BuildContext context, BuildAlertDailog build,
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void msgbox(String type, String title, String text, BuildContext context,
|
Future<T> msgbox<T>(
|
||||||
[bool hasCancel]) {
|
String type, String title, String text, BuildContext context,
|
||||||
|
[bool hasCancel]) async {
|
||||||
if (hasCancel == null) {
|
if (hasCancel == null) {
|
||||||
hasCancel = type != 'error';
|
hasCancel = type != 'error';
|
||||||
}
|
}
|
||||||
showAlertDialog(
|
return await showAlertDialog<T>(
|
||||||
context,
|
context,
|
||||||
(_) => Tuple3(Text(title), Text(text), [
|
(_) => Tuple3(Text(title), Text(text), [
|
||||||
hasCancel
|
hasCancel
|
||||||
|
@ -168,7 +168,7 @@ class _HomePageState extends State<HomePage> {
|
|||||||
if (platform == 'mac os')
|
if (platform == 'mac os')
|
||||||
platform = 'mac';
|
platform = 'mac';
|
||||||
else if (platform != 'linux') platform = 'win';
|
else if (platform != 'linux') platform = 'win';
|
||||||
return Image.asset('assets/$platform.png', width: 36, height: 36);
|
return Image.asset('assets/$platform.png', width: 24, height: 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getPeers() {
|
Widget getPeers() {
|
||||||
|
@ -33,9 +33,13 @@ class FfiModel with ChangeNotifier {
|
|||||||
bool _waitForImage;
|
bool _waitForImage;
|
||||||
bool _initialized = false;
|
bool _initialized = false;
|
||||||
final _permissions = Map<String, bool>();
|
final _permissions = Map<String, bool>();
|
||||||
|
bool _secure;
|
||||||
|
bool _direct;
|
||||||
|
|
||||||
get permissions => _permissions;
|
get permissions => _permissions;
|
||||||
get initialized => _initialized;
|
get initialized => _initialized;
|
||||||
|
get secure => _secure;
|
||||||
|
get direct => _direct;
|
||||||
get pi => _pi;
|
get pi => _pi;
|
||||||
|
|
||||||
FfiModel() {
|
FfiModel() {
|
||||||
@ -61,9 +65,32 @@ class FfiModel with ChangeNotifier {
|
|||||||
_pi = PeerInfo();
|
_pi = PeerInfo();
|
||||||
_display = Display();
|
_display = Display();
|
||||||
_waitForImage = false;
|
_waitForImage = false;
|
||||||
|
_secure = null;
|
||||||
|
_direct = null;
|
||||||
clearPermissions();
|
clearPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setConnectionType(bool secure, bool direct) {
|
||||||
|
_secure = secure;
|
||||||
|
_direct = direct;
|
||||||
|
}
|
||||||
|
|
||||||
|
Image getConnectionImage() {
|
||||||
|
String icon;
|
||||||
|
if (secure == true && direct == true) {
|
||||||
|
icon = 'secure';
|
||||||
|
} else if (secure == false && direct == true) {
|
||||||
|
icon = 'insecure';
|
||||||
|
} else if (secure == false && direct == false) {
|
||||||
|
icon = 'insecure_relay';
|
||||||
|
} else if (secure == true && direct == false) {
|
||||||
|
icon = 'secure_relay';
|
||||||
|
}
|
||||||
|
return icon == null
|
||||||
|
? null
|
||||||
|
: Image.asset('assets/$icon.png', width: 48, height: 48);
|
||||||
|
}
|
||||||
|
|
||||||
void clearPermissions() {
|
void clearPermissions() {
|
||||||
_permissions.clear();
|
_permissions.clear();
|
||||||
}
|
}
|
||||||
@ -71,7 +98,10 @@ class FfiModel with ChangeNotifier {
|
|||||||
void update(
|
void update(
|
||||||
String id,
|
String id,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
void Function(Map<String, dynamic> evt, String id, BuildContext context)
|
void Function(
|
||||||
|
Map<String, dynamic> evt,
|
||||||
|
String id,
|
||||||
|
)
|
||||||
handleMsgbox) {
|
handleMsgbox) {
|
||||||
var pos;
|
var pos;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -79,9 +109,12 @@ class FfiModel with ChangeNotifier {
|
|||||||
if (evt == null) break;
|
if (evt == null) break;
|
||||||
var name = evt['name'];
|
var name = evt['name'];
|
||||||
if (name == 'msgbox') {
|
if (name == 'msgbox') {
|
||||||
handleMsgbox(evt, id, context);
|
handleMsgbox(evt, id);
|
||||||
} else if (name == 'peer_info') {
|
} else if (name == 'peer_info') {
|
||||||
handlePeerInfo(evt, context);
|
handlePeerInfo(evt, context);
|
||||||
|
} else if (name == 'connection_ready') {
|
||||||
|
FFI.ffiModel.setConnectionType(
|
||||||
|
evt['secure'] == 'true', evt['direct'] == 'true');
|
||||||
} else if (name == 'switch_display') {
|
} else if (name == 'switch_display') {
|
||||||
handleSwitchDisplay(evt);
|
handleSwitchDisplay(evt);
|
||||||
} else if (name == 'cursor_data') {
|
} else if (name == 'cursor_data') {
|
||||||
|
@ -86,7 +86,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
FFI.ffiModel.update(widget.id, context, handleMsgbox);
|
FFI.ffiModel.update(widget.id, context, handleMsgbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMsgbox(Map<String, dynamic> evt, String id, BuildContext context) {
|
void handleMsgbox(Map<String, dynamic> evt, String id) {
|
||||||
var type = evt['type'];
|
var type = evt['type'];
|
||||||
var title = evt['title'];
|
var title = evt['title'];
|
||||||
var text = evt['text'];
|
var text = evt['text'];
|
||||||
@ -95,25 +95,29 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
} else if (type == 'input-password') {
|
} else if (type == 'input-password') {
|
||||||
enterPasswordDialog(id, context);
|
enterPasswordDialog(id, context);
|
||||||
} else {
|
} else {
|
||||||
msgbox(type, title, text, context);
|
showMsgBox(type, title, text);
|
||||||
final hasRetry = type == "error" &&
|
}
|
||||||
title == "Connection Error" &&
|
}
|
||||||
text.toLowerCase().indexOf("offline") < 0 &&
|
|
||||||
text.toLowerCase().indexOf("exist") < 0 &&
|
Future<Null> showMsgBox(String type, String title, String text) async {
|
||||||
text.toLowerCase().indexOf("handshake") < 0 &&
|
await msgbox(type, title, text, context);
|
||||||
text.toLowerCase().indexOf("failed") < 0 &&
|
final hasRetry = type == "error" &&
|
||||||
text.toLowerCase().indexOf("resolve") < 0 &&
|
title == "Connection Error" &&
|
||||||
text.toLowerCase().indexOf("manually") < 0;
|
text.toLowerCase().indexOf("offline") < 0 &&
|
||||||
if (hasRetry) {
|
text.toLowerCase().indexOf("exist") < 0 &&
|
||||||
_timer?.cancel();
|
text.toLowerCase().indexOf("handshake") < 0 &&
|
||||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
text.toLowerCase().indexOf("failed") < 0 &&
|
||||||
FFI.reconnect();
|
text.toLowerCase().indexOf("resolve") < 0 &&
|
||||||
showLoading('Connecting...', context);
|
text.toLowerCase().indexOf("manually") < 0;
|
||||||
});
|
if (hasRetry) {
|
||||||
_reconnects *= 2;
|
_timer?.cancel();
|
||||||
} else {
|
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||||
_reconnects = 1;
|
FFI.reconnect();
|
||||||
}
|
showLoading('Connecting...', context);
|
||||||
|
});
|
||||||
|
_reconnects *= 2;
|
||||||
|
} else {
|
||||||
|
_reconnects = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +334,7 @@ class _RemotePageState extends State<RemotePage> {
|
|||||||
minWidth: 0, //wraps child's width
|
minWidth: 0, //wraps child's width
|
||||||
height: 0,
|
height: 0,
|
||||||
child: FlatButton(
|
child: FlatButton(
|
||||||
splashColor: Colors.black,
|
splashColor: MyTheme.accent,
|
||||||
shape: RoundedRectangleBorder(
|
shape: RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.circular(5.0),
|
borderRadius: BorderRadius.circular(5.0),
|
||||||
),
|
),
|
||||||
@ -620,6 +624,9 @@ void showOptions(BuildContext context) {
|
|||||||
if (quality == '') quality = 'balanced';
|
if (quality == '') quality = 'balanced';
|
||||||
var displays = <Widget>[];
|
var displays = <Widget>[];
|
||||||
final pi = FFI.ffiModel.pi;
|
final pi = FFI.ffiModel.pi;
|
||||||
|
final image = FFI.ffiModel.getConnectionImage();
|
||||||
|
if (image != null)
|
||||||
|
displays.add(Padding(padding: const EdgeInsets.only(top: 8), child: image));
|
||||||
if (pi.displays.length > 1) {
|
if (pi.displays.length > 1) {
|
||||||
final cur = pi.currentDisplay;
|
final cur = pi.currentDisplay;
|
||||||
final children = <Widget>[];
|
final children = <Widget>[];
|
||||||
@ -647,6 +654,8 @@ void showOptions(BuildContext context) {
|
|||||||
spacing: 8,
|
spacing: 8,
|
||||||
children: children,
|
children: children,
|
||||||
)));
|
)));
|
||||||
|
}
|
||||||
|
if (displays.isNotEmpty) {
|
||||||
displays.add(Divider(color: MyTheme.border));
|
displays.add(Divider(color: MyTheme.border));
|
||||||
}
|
}
|
||||||
showAlertDialog(context, (setState) {
|
showAlertDialog(context, (setState) {
|
||||||
|