fix on login and config
This commit is contained in:
parent
52139dc84b
commit
0ba74ef7ec
@ -165,6 +165,7 @@ class Peer {
|
|||||||
|
|
||||||
// https://github.com/huangjianke/flutter_easyloading
|
// https://github.com/huangjianke/flutter_easyloading
|
||||||
void showLoading(String text) {
|
void showLoading(String text) {
|
||||||
|
dismissLoading();
|
||||||
EasyLoading.show(status: text);
|
EasyLoading.show(status: text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,17 +174,24 @@ void dismissLoading() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void showSuccess(String text) {
|
void showSuccess(String text) {
|
||||||
|
dismissLoading();
|
||||||
EasyLoading.showSuccess(text);
|
EasyLoading.showSuccess(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool _hasDialog = false;
|
||||||
|
|
||||||
// https://material.io/develop/flutter/components/dialogs
|
// https://material.io/develop/flutter/components/dialogs
|
||||||
void enterPasswordDialog(String id, BuildContext context) {
|
Future<Null> enterPasswordDialog(String id, BuildContext context) async {
|
||||||
dismissLoading();
|
dismissLoading();
|
||||||
|
if (_hasDialog) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
_hasDialog = true;
|
||||||
final controller = TextEditingController();
|
final controller = TextEditingController();
|
||||||
var remember = FFI.getByName('remember', arg: id) == 'true';
|
var remember = FFI.getByName('remember', arg: id) == 'true';
|
||||||
var dialog = AlertDialog(
|
var dialog = AlertDialog(
|
||||||
title: Text('Please enter your password'),
|
title: Text('Please enter your password'),
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: const EdgeInsets.all(20.0),
|
||||||
content: Column(
|
content: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
@ -230,19 +238,30 @@ void enterPasswordDialog(String id, BuildContext context) {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
showDialog<void>(context: context, builder: (context) => dialog);
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => dialog);
|
||||||
|
_hasDialog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wrongPasswordDialog(String id, BuildContext context) {
|
Future<Null> wrongPasswordDialog(String id, BuildContext context) async {
|
||||||
dismissLoading();
|
dismissLoading();
|
||||||
|
if (_hasDialog) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
_hasDialog = true;
|
||||||
var dialog = AlertDialog(
|
var dialog = AlertDialog(
|
||||||
title: Text('Wrong Password'),
|
title: Text('Wrong Password'),
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: const EdgeInsets.all(20.0),
|
||||||
content: Text('Do you want to enter again?'),
|
content: Text('Do you want to enter again?'),
|
||||||
actions: [
|
actions: [
|
||||||
FlatButton(
|
FlatButton(
|
||||||
textColor: MyTheme.accent,
|
textColor: MyTheme.accent,
|
||||||
onPressed: () => Navigator.pop(context),
|
onPressed: () {
|
||||||
|
Navigator.pop(context);
|
||||||
|
Navigator.pop(context);
|
||||||
|
},
|
||||||
child: Text('Cancel'),
|
child: Text('Cancel'),
|
||||||
),
|
),
|
||||||
FlatButton(
|
FlatButton(
|
||||||
@ -255,14 +274,23 @@ void wrongPasswordDialog(String id, BuildContext context) {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
showDialog<void>(context: context, builder: (context) => dialog);
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => dialog);
|
||||||
|
_hasDialog = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void msgbox(String type, String title, String text, BuildContext context) {
|
Future<Null> msgbox(
|
||||||
|
String type, String title, String text, BuildContext context) async {
|
||||||
dismissLoading();
|
dismissLoading();
|
||||||
|
if (_hasDialog) {
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
_hasDialog = true;
|
||||||
var dialog = AlertDialog(
|
var dialog = AlertDialog(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
contentPadding: EdgeInsets.zero,
|
contentPadding: const EdgeInsets.all(20.0),
|
||||||
content: Text(text),
|
content: Text(text),
|
||||||
actions: [
|
actions: [
|
||||||
FlatButton(
|
FlatButton(
|
||||||
@ -275,5 +303,9 @@ void msgbox(String type, String title, String text, BuildContext context) {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
showDialog<void>(context: context, builder: (context) => dialog);
|
await showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) => dialog);
|
||||||
|
_hasDialog = false;
|
||||||
}
|
}
|
||||||
|
@ -15,15 +15,10 @@ class HomePage extends StatefulWidget {
|
|||||||
class _HomePageState extends State<HomePage> {
|
class _HomePageState extends State<HomePage> {
|
||||||
final _idController = TextEditingController();
|
final _idController = TextEditingController();
|
||||||
|
|
||||||
@override
|
|
||||||
void initState() {
|
|
||||||
super.initState();
|
|
||||||
_idController.text = FFI.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Provider.of<FfiModel>(context);
|
Provider.of<FfiModel>(context);
|
||||||
|
if (_idController.text.isEmpty) _idController.text = FFI.getId();
|
||||||
// This method is rerun every time setState is called
|
// This method is rerun every time setState is called
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user