2020-10-07 02:33:06 +06:30
|
|
|
import 'package:fcs/pages/main/model/main_model.dart';
|
|
|
|
|
import 'package:fcs/pages/main/util.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/local_text.dart';
|
|
|
|
|
import 'package:fcs/pages/widgets/progress.dart';
|
2020-09-12 03:34:52 +06:30
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
|
|
|
|
|
|
import '../../helpers/theme.dart';
|
|
|
|
|
|
|
|
|
|
class RequestInvitationPage extends StatefulWidget {
|
|
|
|
|
@override
|
|
|
|
|
_RequestInvitationPageState createState() => _RequestInvitationPageState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _RequestInvitationPageState extends State<RequestInvitationPage> {
|
|
|
|
|
bool _isLoading = false;
|
|
|
|
|
TextEditingController nameCtl;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
nameCtl = new TextEditingController();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return LocalProgress(
|
|
|
|
|
inAsyncCall: _isLoading,
|
|
|
|
|
child: new Scaffold(
|
|
|
|
|
appBar: AppBar(
|
|
|
|
|
centerTitle: true,
|
|
|
|
|
leading: new IconButton(
|
|
|
|
|
icon: new Icon(Icons.close),
|
|
|
|
|
onPressed: () => Navigator.of(context).pop(),
|
|
|
|
|
),
|
|
|
|
|
backgroundColor: primaryColor,
|
|
|
|
|
),
|
|
|
|
|
body: _buildBody(context),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget _buildBody(BuildContext context) {
|
|
|
|
|
return ListView(
|
|
|
|
|
padding: EdgeInsets.only(top: 5, left: 10, right: 10),
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 40),
|
|
|
|
|
child: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
'invite.title',
|
|
|
|
|
fontSize: 21,
|
|
|
|
|
color: primaryColor,
|
|
|
|
|
fontWeight: FontWeight.bold,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 25),
|
|
|
|
|
child: LocalText(
|
|
|
|
|
context,
|
|
|
|
|
'invite.name.enter',
|
|
|
|
|
color: labelColor,
|
|
|
|
|
fontSize: 16,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
padding: EdgeInsets.only(top: 0, bottom: 10),
|
|
|
|
|
child: TextFormField(
|
|
|
|
|
controller: nameCtl,
|
|
|
|
|
cursorColor: primaryColor,
|
|
|
|
|
textAlign: TextAlign.left,
|
|
|
|
|
keyboardType: TextInputType.text,
|
|
|
|
|
autofocus: true,
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
fontSize: 18,
|
|
|
|
|
),
|
|
|
|
|
decoration: new InputDecoration(
|
|
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
|
borderSide: BorderSide(color: primaryColor, width: 1.0)),
|
|
|
|
|
),
|
|
|
|
|
)),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 20,
|
|
|
|
|
),
|
|
|
|
|
Container(
|
|
|
|
|
child: Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
RaisedButton(
|
|
|
|
|
onPressed: _request,
|
|
|
|
|
child: Text(getLocalString(context, "invite.request")),
|
|
|
|
|
)
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_request() async {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = true;
|
|
|
|
|
});
|
|
|
|
|
try {
|
2020-09-13 21:49:39 +06:30
|
|
|
// just signup to request for invitation
|
|
|
|
|
await context.read<MainModel>().signup(nameCtl.text);
|
2020-09-12 03:34:52 +06:30
|
|
|
await showMsgDialog(context, "Successful",
|
|
|
|
|
getLocalString(context, "invite.request.successful"));
|
2020-09-13 21:49:39 +06:30
|
|
|
Navigator.pushNamedAndRemoveUntil(context, "/home", (r) => false);
|
2020-09-12 03:34:52 +06:30
|
|
|
} catch (e) {
|
|
|
|
|
await showMsgDialog(context, "Error", e.toString());
|
|
|
|
|
} finally {
|
|
|
|
|
setState(() {
|
|
|
|
|
_isLoading = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|