Commit 366cec46 authored by GayaniPKarunaratne's avatar GayaniPKarunaratne

Create add location form

parent 3580ec87
...@@ -6,10 +6,221 @@ class AddLocation extends StatefulWidget { ...@@ -6,10 +6,221 @@ class AddLocation extends StatefulWidget {
} }
class AddLocationState extends State<AddLocation> { class AddLocationState extends State<AddLocation> {
String _fName;
String _lName;
String _age;
String _address;
String _nic;
String _phoneNumber;
String _riskLocation;
String _hotelName;
String _date;
String _time;
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
Widget _buildFName(){
return TextFormField(
decoration: InputDecoration(labelText: 'First Name'),
validator: (String value){
if (value.isEmpty) {
return '*First Name is Required';
}
},
onSaved: (String value){
_fName = value;
},
);
}
Widget _buildLName(){
return TextFormField(
decoration: InputDecoration(labelText: 'Last Name'),
validator: (String value){
if (value.isEmpty) {
return '*Last Name is Required';
}
},
onSaved: (String value){
_lName = value;
},
);
}
Widget _buildAge(){
return TextFormField(
decoration: InputDecoration(labelText: 'Age'),
validator: (String value){
if (value.isEmpty) {
return '*Age is Required';
}
},
onSaved: (String value){
_age = value;
},
);
}
Widget _buildAddress(){
return TextFormField(
decoration: InputDecoration(labelText: 'Address'),
validator: (String value){
if (value.isEmpty) {
return '*Address is Required';
}
},
onSaved: (String value){
_address = value;
},
);
}
Widget _buildNIC(){
return TextFormField(
decoration: InputDecoration(labelText: 'NIC'),
validator: (String value){
if (value.isEmpty) {
return '*NIC is Required';
}
},
onSaved: (String value){
_nic = value;
},
);
}
Widget _buildPhoneNumber(){
return TextFormField(
decoration: InputDecoration(labelText: 'Phone Number'),
keyboardType: TextInputType.phone,
maxLength: 10,
validator: (String value){
if (value.isEmpty) {
return '*Phone Number is Required';
}
},
onSaved: (String value){
_phoneNumber = value;
},
);
}
Widget _buildRiskLocation(){
return TextFormField(
decoration: InputDecoration(labelText: 'Risk Location'),
validator: (String value){
if (value.isEmpty) {
return '*Location is Required';
}
},
onSaved: (String value){
_riskLocation = value;
},
);
}
Widget _buildHotelName(){
return TextFormField(
decoration: InputDecoration(labelText: 'Hotel Name'),
validator: (String value){
if (value.isEmpty) {
return '*Hotel Name is Required';
}
},
onSaved: (String value){
_hotelName = value;
},
);
}
Widget _buildDate(){
return TextFormField(
decoration: InputDecoration(labelText: 'Date'),
keyboardType: TextInputType.datetime,
validator: (String value){
if (value.isEmpty) {
return '*Date is Required';
}
},
onSaved: (String value){
_date = value;
},
);
}
Widget _buildTime(){
return TextFormField(
decoration: InputDecoration(labelText: 'Time'),
validator: (String value){
if (value.isEmpty) {
return '*Time is Required';
}
},
onSaved: (String value){
_time = value;
},
);
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Scaffold(
appBar: AppBar(
backwardsCompatibility: false,
backgroundColor: Color(0xFF1B5E20),
title: Text("Add Risk Location"),
),
body: Container(
margin: EdgeInsets.all(24),
child: Form(
key: _formKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
_buildFName(),
_buildLName(),
_buildAge(),
_buildAddress(),
_buildNIC(),
_buildPhoneNumber(),
_buildRiskLocation(),
_buildHotelName(),
_buildDate(),
_buildTime(),
SizedBox(height: 100),
RaisedButton(
child: Text(
'Submit',
style: TextStyle(color: Colors.green, fontSize: 18),
),
onPressed: () {
if(!_formKey.currentState.validate()) {
return;
}
_formKey.currentState.save();
print(_fName);
print(_lName);
print(_age);
print(_address);
print(_nic);
print(_phoneNumber);
print(_riskLocation);
print(_hotelName);
print(_date);
print(_time);
} ,
)
],
),),
),
); );
} }
} }
\ No newline at end of file
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'AddLocation.dart'; import 'AddLocation.dart';
class EAnalyzerDash extends StatelessWidget { class EAnalyzerDash extends StatelessWidget {
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'home.dart'; import 'home.dart';
...@@ -14,8 +13,6 @@ class _levelsDashboardState extends State<levelsDashboard> { ...@@ -14,8 +13,6 @@ class _levelsDashboardState extends State<levelsDashboard> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backwardsCompatibility: false, backwardsCompatibility: false,
systemOverlayStyle:
SystemUiOverlayStyle(statusBarColor: Colors.blue.shade900),
title: Text("Levels DashBoard"), title: Text("Levels DashBoard"),
), ),
body: Stack( body: Stack(
......
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'levelsDashboard.dart'; import 'levelsDashboard.dart';
...@@ -14,8 +13,6 @@ class _strackerDasboardState extends State<strackerDasboard> { ...@@ -14,8 +13,6 @@ class _strackerDasboardState extends State<strackerDasboard> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
backwardsCompatibility: false, backwardsCompatibility: false,
systemOverlayStyle:
SystemUiOverlayStyle(statusBarColor: Colors.blue.shade900),
title: Text("STracker DashBoard"), title: Text("STracker DashBoard"),
), ),
body: Stack( body: Stack(
......
import 'package:covidefender/STracker/splash.dart'; import 'package:covidefender/STracker/splash.dart';
import 'package:covidefender/EAnalyzer/Loading.dart'; import 'package:covidefender/EAnalyzer/Loading.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
class HomeScreen extends StatefulWidget { class HomeScreen extends StatefulWidget {
_HomeScreenState createState() => _HomeScreenState(); _HomeScreenState createState() => _HomeScreenState();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment