104 lines
2.9 KiB
Dart
104 lines
2.9 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:fcs/fcs/common/pages/util.dart';
|
|
import 'package:fcs/fcs/common/helpers/theme.dart';
|
|
import 'package:fcs/widget/local_text.dart';
|
|
import 'package:fcs/widget/localization/app_translations.dart';
|
|
|
|
class PhoneEditor extends StatefulWidget {
|
|
@override
|
|
_PhoneEditorState createState() => _PhoneEditorState();
|
|
}
|
|
|
|
class _PhoneEditorState extends State<PhoneEditor> {
|
|
final _formKey = GlobalKey<FormState>();
|
|
TextEditingController _phone = new TextEditingController();
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_phone.text = '09';
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AlertDialog(
|
|
title: Center(
|
|
child: Text(
|
|
AppTranslations.of(context).text("contact.phone.title"),
|
|
style: TextStyle(
|
|
color: primaryColor, fontWeight: FontWeight.bold, fontSize: 20),
|
|
)),
|
|
content: Form(
|
|
key: _formKey,
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: <Widget>[
|
|
new Expanded(
|
|
child: new TextFormField(
|
|
keyboardType: TextInputType.number,
|
|
autofocus: true,
|
|
controller: _phone,
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20),
|
|
cursorColor: primaryColor,
|
|
decoration: new InputDecoration(
|
|
fillColor: primaryColor,
|
|
icon: Icon(
|
|
Icons.phone,
|
|
color: primaryColor,
|
|
),
|
|
focusedBorder: UnderlineInputBorder(
|
|
borderSide: BorderSide(color: Colors.grey, width: 1.0)),
|
|
),
|
|
validator: (value) {
|
|
if (value.isEmpty) {
|
|
return AppTranslations.of(context)
|
|
.text("contact.phone.empty");
|
|
}
|
|
return null;
|
|
},
|
|
))
|
|
],
|
|
),
|
|
),
|
|
actions: <Widget>[
|
|
FlatButton(
|
|
child: LocalText(
|
|
context,
|
|
'do.cancel',
|
|
color: secondaryColor,
|
|
),
|
|
onPressed: () {
|
|
_phone.clear();
|
|
Navigator.of(context).pop();
|
|
}),
|
|
FlatButton(
|
|
color: primaryColor,
|
|
child: LocalText(
|
|
context,
|
|
'do.enter',
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
onPressed: () async {
|
|
if (!_formKey.currentState.validate()) return;
|
|
_save();
|
|
})
|
|
],
|
|
);
|
|
}
|
|
|
|
_save() {
|
|
try {
|
|
Navigator.pop<String>(context, _phone.text);
|
|
} catch (e) {
|
|
showMsgDialog(context, "Error", e.toString());
|
|
}
|
|
}
|
|
}
|