msgbox start to work
This commit is contained in:
		
							parent
							
								
									1a3a2cf6c7
								
							
						
					
					
						commit
						a110db32e9
					
				| @ -93,11 +93,11 @@ class FFI { | ||||
|     return Uint8List.sublistView(ref.data.asTypedList(ref.len)); | ||||
|   } | ||||
| 
 | ||||
|   static Map<String, String> popEvent() { | ||||
|   static Map<String, dynamic> popEvent() { | ||||
|     var s = getByName('event'); | ||||
|     if (s == '') return null; | ||||
|     try { | ||||
|       Map<String, String> event = json.decode(s); | ||||
|       Map<String, dynamic> event = json.decode(s); | ||||
|       return event; | ||||
|     } catch (e) { | ||||
|       print(e); | ||||
| @ -178,6 +178,7 @@ void showSuccess(String text) { | ||||
| 
 | ||||
| // https://material.io/develop/flutter/components/dialogs | ||||
| void enterPasswordDialog(String id, BuildContext context) { | ||||
|   dismissLoading(); | ||||
|   var remember = FFI.getByName('remember', arg: id) == 'true'; | ||||
|   var dialog = AlertDialog( | ||||
|     title: Text('Please enter your password'), | ||||
| @ -219,6 +220,7 @@ void enterPasswordDialog(String id, BuildContext context) { | ||||
| } | ||||
| 
 | ||||
| void wrongPasswordDialog(String id, BuildContext context) { | ||||
|   dismissLoading(); | ||||
|   var dialog = AlertDialog( | ||||
|     title: Text('Please enter your password'), | ||||
|     contentPadding: EdgeInsets.zero, | ||||
| @ -241,3 +243,23 @@ void wrongPasswordDialog(String id, BuildContext context) { | ||||
|   ); | ||||
|   showDialog<void>(context: context, builder: (context) => dialog); | ||||
| } | ||||
| 
 | ||||
| void msgbox(String type, String title, String text, BuildContext context) { | ||||
|   dismissLoading(); | ||||
|   var dialog = AlertDialog( | ||||
|     title: Text(title), | ||||
|     contentPadding: EdgeInsets.zero, | ||||
|     content: Text(text), | ||||
|     actions: [ | ||||
|       FlatButton( | ||||
|         textColor: MyTheme.accent, | ||||
|         onPressed: () { | ||||
|           Navigator.pop(context); | ||||
|           Navigator.pop(context); | ||||
|         }, | ||||
|         child: Text('OK'), | ||||
|       ), | ||||
|     ], | ||||
|   ); | ||||
|   showDialog<void>(context: context, builder: (context) => dialog); | ||||
| } | ||||
|  | ||||
| @ -60,15 +60,16 @@ class _RemotePageState extends State<RemotePage> { | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   void handleMsgbox(evt) { | ||||
|   void handleMsgbox(Map<String, dynamic> evt) { | ||||
|     var type = evt['type']; | ||||
|     var title = evt['title']; | ||||
|     var text = evt['text']; | ||||
|     if (type == 'error') { | ||||
|     } else if (type == 're-input-password') { | ||||
|     if (type == 're-input-password') { | ||||
|       wrongPasswordDialog(widget.id, context); | ||||
|     } else if (type == 'input-password') { | ||||
|       enterPasswordDialog(widget.id, context); | ||||
|     } else { | ||||
|       msgbox(type, title, text, context); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user