You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
212 lines
6.6 KiB
212 lines
6.6 KiB
import 'package:flutter/material.dart';
|
|
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:teso/Classes/API%20Clasess/TesoUserDetail.dart';
|
|
import 'package:teso/Classes/customTesoButton.dart';
|
|
import 'package:teso/util/consts.dart';
|
|
|
|
class CompleteNewProfile extends StatefulWidget {
|
|
@override
|
|
_CompleteNewProfileState createState() => _CompleteNewProfileState();
|
|
}
|
|
|
|
class _CompleteNewProfileState extends State<CompleteNewProfile> {
|
|
DateFormat dateFormat = DateFormat("EEEE dd-MM-yyyy");
|
|
DateTime selectedDate = DateTime.now();
|
|
String selectedGender;
|
|
List<String> gender = ["Male", "Female", "Other"];
|
|
bool error = false;
|
|
String message = "";
|
|
TesoUserDetail olduser;
|
|
|
|
void changeDate(v) {
|
|
setState(() {
|
|
selectedDate = v;
|
|
});
|
|
}
|
|
|
|
completeNewProfile() async {
|
|
if (selectedDate.year != DateTime.now().year && selectedGender != null) {
|
|
olduser = new TesoUserDetail();
|
|
olduser.dateOfBirth = selectedDate;
|
|
olduser.gender = selectedGender;
|
|
Navigator.pop(context, olduser);
|
|
} else {
|
|
setState(() {
|
|
error = true;
|
|
message =
|
|
"Sorry, an error occurred please make sure to select the right date and select a gender !!!";
|
|
});
|
|
|
|
Future.delayed(const Duration(seconds: 5), () {
|
|
if (error) {
|
|
if (mounted) {
|
|
setState(() {
|
|
error = false;
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: SingleChildScrollView(
|
|
scrollDirection: Axis.vertical,
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
padding: EdgeInsets.all(20),
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
height: 120,
|
|
padding: EdgeInsets.symmetric(vertical: 20),
|
|
child: Image(
|
|
image: AssetImage("assets/images/tesoCouponInsignia.png"),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 5,
|
|
),
|
|
Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
child: Center(
|
|
child: Text(
|
|
"Complete your profile",
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 40,
|
|
),
|
|
Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
// height: 10,
|
|
child: Text(
|
|
"When is your birthday ?",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 5,
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: TextButton(
|
|
onPressed: () {
|
|
DatePicker.showDatePicker(
|
|
context,
|
|
showTitleActions: true,
|
|
maxTime: DateTime.now(),
|
|
onConfirm: (date) {
|
|
changeDate(date);
|
|
},
|
|
currentTime: selectedDate,
|
|
locale: LocaleType.en,
|
|
);
|
|
},
|
|
child: Text(
|
|
dateFormat.format(selectedDate).toString(),
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.normal,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Divider(),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
child: Text(
|
|
"What is your gender ?",
|
|
style: TextStyle(
|
|
fontWeight: FontWeight.bold,
|
|
),
|
|
),
|
|
),
|
|
Container(
|
|
alignment: Alignment.centerLeft,
|
|
child: DropdownButton<String>(
|
|
hint: Text("Select Gender"),
|
|
value: selectedGender,
|
|
items: gender
|
|
.map(
|
|
(gender) => DropdownMenuItem<String>(
|
|
value: gender,
|
|
child: Text(
|
|
gender,
|
|
style: TextStyle(
|
|
// color: Colors.grey,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
.toList(),
|
|
onChanged: (v) {
|
|
setState(() {
|
|
selectedGender = v;
|
|
});
|
|
},
|
|
),
|
|
),
|
|
Divider(),
|
|
SizedBox(
|
|
height: 10,
|
|
),
|
|
Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
child: Text(
|
|
"Teso uses this data to personalize your experiences, to help business understand their customers, and more. " +
|
|
"We will always keep your personal data private.",
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
Visibility(
|
|
visible: error,
|
|
child: Container(
|
|
width: MediaQuery.of(context).size.width,
|
|
child: Text(
|
|
message,
|
|
style: TextStyle(
|
|
color: Colors.red,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
RaisedGradientButton(
|
|
onPressed: completeNewProfile,
|
|
child: Text(
|
|
"Submit",
|
|
style: TextStyle(
|
|
fontSize: 18,
|
|
color: Colors.white,
|
|
),
|
|
),
|
|
gradient: LinearGradient(
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [
|
|
accentMain,
|
|
darkAccent,
|
|
],
|
|
// stops: [0.1, 0.4, 0.7, 0.8],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|