You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
146 lines
4.7 KiB
Dart
146 lines
4.7 KiB
Dart
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
// OWNER : Ibrahim albitar
|
|
// DATE : 12-04-2020
|
|
// DESCRIPTION : Customization for Texts in app
|
|
|
|
class MobileNo extends StatefulWidget {
|
|
final bool disabled;
|
|
|
|
// final String data;
|
|
final List<Countries> countries = [
|
|
new Countries( name: "Saudi Arabia",
|
|
name_ar:"المملكة العربية السعودية", code: '966' ),
|
|
new Countries(name: "United Arab Emirates",
|
|
name_ar:"الإمارات العربية المتحدة", code: '971'),
|
|
];
|
|
final double margin;
|
|
final double marginTop;
|
|
final double marginRight;
|
|
final double marginBottom;
|
|
final double marginLeft;
|
|
final TextEditingController controller;
|
|
final Function onNumberChange;
|
|
final Function onCountryChange;
|
|
|
|
MobileNo(
|
|
{this.disabled = false,
|
|
this.marginTop = 0,
|
|
this.marginRight = 0,
|
|
this.marginBottom = 0,
|
|
this.controller,
|
|
this.marginLeft = 0,
|
|
this.onNumberChange,
|
|
this.onCountryChange,
|
|
this.margin = 0});
|
|
|
|
@override
|
|
_MobileNo createState() => _MobileNo();
|
|
}
|
|
|
|
class _MobileNo extends State<MobileNo> {
|
|
var _selectedType = '966';
|
|
String countryCode = '966';
|
|
ProjectViewModel projectProvider;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
projectProvider = Provider.of(context);
|
|
return Visibility(
|
|
child: Column(children: <Widget>[
|
|
Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: <Widget>[
|
|
Container(
|
|
margin: EdgeInsets.only(bottom: 10.0),
|
|
height: 60.0,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border.all(
|
|
color: Colors.grey[400],
|
|
width: 1.0,
|
|
),
|
|
borderRadius: BorderRadius.circular(10),
|
|
),
|
|
width: MediaQuery.of(context).size.width * 0.89,
|
|
child: Padding(
|
|
padding: EdgeInsets.all(10),
|
|
child: DropdownButtonHideUnderline(
|
|
child: DropdownButton(
|
|
isExpanded: true,
|
|
value: _selectedType,
|
|
iconSize: 40,
|
|
elevation: 16,
|
|
onChanged: (value) => {
|
|
widget.onCountryChange(value),
|
|
setState(() {
|
|
countryCode = value;
|
|
_selectedType = value;
|
|
})
|
|
},
|
|
items: widget.countries
|
|
.map<DropdownMenuItem<String>>((Countries value) {
|
|
return DropdownMenuItem<String>(
|
|
value: value.code,
|
|
child: Text(projectProvider.isArabic == true ? value.name_ar : value.name),
|
|
);
|
|
}).toList())))),
|
|
],
|
|
),
|
|
Container(
|
|
padding: EdgeInsets.all(5),
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
border: Border.all(color: Colors.grey),
|
|
borderRadius: BorderRadius.circular(10)),
|
|
child: Row(children: <Widget>[
|
|
Expanded(
|
|
flex: 1,
|
|
child: Icon(
|
|
Icons.phone,
|
|
color: Color(0xFF40ACC9),
|
|
)),
|
|
Expanded(
|
|
flex: 1,
|
|
child: Text(
|
|
countryCode,
|
|
overflow: TextOverflow.clip,
|
|
)),
|
|
Expanded(
|
|
flex: 4,
|
|
child: Container(
|
|
margin: widget.margin != null
|
|
? EdgeInsets.all(widget.margin)
|
|
: EdgeInsets.only(
|
|
top: widget.marginTop,
|
|
right: widget.marginRight,
|
|
bottom: widget.marginBottom,
|
|
left: widget.marginLeft),
|
|
child: TextField(
|
|
controller: widget.controller,
|
|
keyboardType: TextInputType.phone,
|
|
// onChanged: (value) {
|
|
// widget.controller.text = countryCode;
|
|
// },
|
|
onChanged: (value) => widget.onNumberChange(value),
|
|
decoration: InputDecoration(
|
|
border: InputBorder.none, hintText: '5xxxxxxxx'),
|
|
),
|
|
),
|
|
)
|
|
]),
|
|
)
|
|
]));
|
|
}
|
|
}
|
|
|
|
class Countries {
|
|
final String name;
|
|
final String name_ar;
|
|
final String code;
|
|
|
|
Countries({this.name, this.name_ar, this.code});
|
|
}
|