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;
|
||||
}
|
||||
|
||||
void msgbox(String type, String title, String text, BuildContext context,
|
||||
[bool hasCancel]) {
|
||||
Future<T> msgbox<T>(
|
||||
String type, String title, String text, BuildContext context,
|
||||
[bool hasCancel]) async {
|
||||
if (hasCancel == null) {
|
||||
hasCancel = type != 'error';
|
||||
}
|
||||
showAlertDialog(
|
||||
return await showAlertDialog<T>(
|
||||
context,
|
||||
(_) => Tuple3(Text(title), Text(text), [
|
||||
hasCancel
|
||||
|
@ -168,7 +168,7 @@ class _HomePageState extends State<HomePage> {
|
||||
if (platform == 'mac os')
|
||||
platform = 'mac';
|
||||
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() {
|
||||
|
@ -33,9 +33,13 @@ class FfiModel with ChangeNotifier {
|
||||
bool _waitForImage;
|
||||
bool _initialized = false;
|
||||
final _permissions = Map<String, bool>();
|
||||
bool _secure;
|
||||
bool _direct;
|
||||
|
||||
get permissions => _permissions;
|
||||
get initialized => _initialized;
|
||||
get secure => _secure;
|
||||
get direct => _direct;
|
||||
get pi => _pi;
|
||||
|
||||
FfiModel() {
|
||||
@ -61,9 +65,32 @@ class FfiModel with ChangeNotifier {
|
||||
_pi = PeerInfo();
|
||||
_display = Display();
|
||||
_waitForImage = false;
|
||||
_secure = null;
|
||||
_direct = null;
|
||||
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() {
|
||||
_permissions.clear();
|
||||
}
|
||||
@ -71,7 +98,10 @@ class FfiModel with ChangeNotifier {
|
||||
void update(
|
||||
String id,
|
||||
BuildContext context,
|
||||
void Function(Map<String, dynamic> evt, String id, BuildContext context)
|
||||
void Function(
|
||||
Map<String, dynamic> evt,
|
||||
String id,
|
||||
)
|
||||
handleMsgbox) {
|
||||
var pos;
|
||||
for (;;) {
|
||||
@ -79,9 +109,12 @@ class FfiModel with ChangeNotifier {
|
||||
if (evt == null) break;
|
||||
var name = evt['name'];
|
||||
if (name == 'msgbox') {
|
||||
handleMsgbox(evt, id, context);
|
||||
handleMsgbox(evt, id);
|
||||
} else if (name == 'peer_info') {
|
||||
handlePeerInfo(evt, context);
|
||||
} else if (name == 'connection_ready') {
|
||||
FFI.ffiModel.setConnectionType(
|
||||
evt['secure'] == 'true', evt['direct'] == 'true');
|
||||
} else if (name == 'switch_display') {
|
||||
handleSwitchDisplay(evt);
|
||||
} else if (name == 'cursor_data') {
|
||||
|
@ -86,7 +86,7 @@ class _RemotePageState extends State<RemotePage> {
|
||||
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 title = evt['title'];
|
||||
var text = evt['text'];
|
||||
@ -95,25 +95,29 @@ class _RemotePageState extends State<RemotePage> {
|
||||
} else if (type == 'input-password') {
|
||||
enterPasswordDialog(id, context);
|
||||
} else {
|
||||
msgbox(type, title, text, context);
|
||||
final hasRetry = type == "error" &&
|
||||
title == "Connection Error" &&
|
||||
text.toLowerCase().indexOf("offline") < 0 &&
|
||||
text.toLowerCase().indexOf("exist") < 0 &&
|
||||
text.toLowerCase().indexOf("handshake") < 0 &&
|
||||
text.toLowerCase().indexOf("failed") < 0 &&
|
||||
text.toLowerCase().indexOf("resolve") < 0 &&
|
||||
text.toLowerCase().indexOf("manually") < 0;
|
||||
if (hasRetry) {
|
||||
_timer?.cancel();
|
||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||
FFI.reconnect();
|
||||
showLoading('Connecting...', context);
|
||||
});
|
||||
_reconnects *= 2;
|
||||
} else {
|
||||
_reconnects = 1;
|
||||
}
|
||||
showMsgBox(type, title, text);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Null> showMsgBox(String type, String title, String text) async {
|
||||
await msgbox(type, title, text, context);
|
||||
final hasRetry = type == "error" &&
|
||||
title == "Connection Error" &&
|
||||
text.toLowerCase().indexOf("offline") < 0 &&
|
||||
text.toLowerCase().indexOf("exist") < 0 &&
|
||||
text.toLowerCase().indexOf("handshake") < 0 &&
|
||||
text.toLowerCase().indexOf("failed") < 0 &&
|
||||
text.toLowerCase().indexOf("resolve") < 0 &&
|
||||
text.toLowerCase().indexOf("manually") < 0;
|
||||
if (hasRetry) {
|
||||
_timer?.cancel();
|
||||
_timer = Timer(Duration(seconds: _reconnects), () {
|
||||
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
|
||||
height: 0,
|
||||
child: FlatButton(
|
||||
splashColor: Colors.black,
|
||||
splashColor: MyTheme.accent,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
),
|
||||
@ -620,6 +624,9 @@ void showOptions(BuildContext context) {
|
||||
if (quality == '') quality = 'balanced';
|
||||
var displays = <Widget>[];
|
||||
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) {
|
||||
final cur = pi.currentDisplay;
|
||||
final children = <Widget>[];
|
||||
@ -647,6 +654,8 @@ void showOptions(BuildContext context) {
|
||||
spacing: 8,
|
||||
children: children,
|
||||
)));
|
||||
}
|
||||
if (displays.isNotEmpty) {
|
||||
displays.add(Divider(color: MyTheme.border));
|
||||
}
|
||||
showAlertDialog(context, (setState) {
|
||||
|