Polishings

This commit is contained in:
warlock
2022-03-07 18:52:36 +05:30
parent f749c4ce8d
commit 455483299f
11 changed files with 461 additions and 230 deletions

View File

@@ -44,231 +44,240 @@ class _NewActivity extends State<NewActivity> {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SingleChildScrollView(
child: Padding(
padding: EdgeInsets.fromLTRB(20, 50, 20, 50),
child: Column(
children: [
Column(children: [
Container(
padding: EdgeInsets.all(10),
child: Text('Task')),
Container(
padding: EdgeInsets.symmetric(
horizontal: 12, vertical: 1),
decoration: BoxDecoration(
color: Colors.blueGrey,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey, width: 2)),
child: DropdownButton<String>(
dropdownColor: Colors.blueGrey,
iconSize: 30,
elevation: 10,
borderRadius: BorderRadius.circular(10),
value: selectedCat,
isExpanded: true,
items: getActivities().map<DropdownMenuItem<String>>(
(String value) {
print(value);
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? _value) {
setState(() {
selectedCat = _value ?? 'n/a';
});
})),
Expanded(
flex: 9,
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
child: Expanded(
child: Padding(
padding: EdgeInsets.fromLTRB(20, 50, 20, 50),
child: Column(
children: [
Column(children: [
Container(
padding: EdgeInsets.all(10),
child: Text('Task')),
Container(
padding: EdgeInsets.all(10),
child:Column(
children: [
Container(
padding: EdgeInsets.symmetric(
horizontal: 12, vertical: 1),
decoration: BoxDecoration(
color: Colors.blueGrey,
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey, width: 2)),
child: DropdownButton<String>(
dropdownColor: Colors.blueGrey,
iconSize: 30,
elevation: 10,
borderRadius: BorderRadius.circular(10),
value: selectedCat,
isExpanded: true,
items: getActivities().map<DropdownMenuItem<String>>(
(String value) {
print(value);
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? _value) {
setState(() {
selectedCat = _value ?? 'n/a';
});
})),
TextField(
controller: metadataController,
decoration: InputDecoration(
hintText: 'Description (optional)',
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20)
)
),
Container(
padding: EdgeInsets.all(10),
child:Column(
children: [
TextField(
controller: metadataController,
decoration: InputDecoration(
hintText: 'Description (optional)',
filled: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(20)
)
),
),
],
)
),
Container(
child: Divider(
height: 30,
)),
Container(
padding: EdgeInsets.all(10),
child: Text('Start Time')),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
QuickTimeButton('Last', Function: (){
if(User.activities.length > 0) {
startTime= User.activities[0].endTime;
}
})
,
Container(
padding: EdgeInsets.symmetric(
horizontal: 12, vertical: 1),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey, width: 2)),
child: MaterialButton(
onPressed: () {
setState(() {
DatePicker.showDateTimePicker(
context,
showTitleActions: true,
onChanged: (date) {
// print('change $date');
}, onConfirm: (date) {
setState(() {
if(endTime.compareTo(date) < 0){
const snackBar = SnackBar(
content: Text('You cannot start something after you ended it!'),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}else {
startTime = date;
}
});
},
currentTime: startTime,
locale: LocaleType.en);
});
},
child: Text(
dateFormat.format(startTime),
style: TextStyle(
color: Colors.blue)))),
QuickTimeButton('Now', Function: (){
startTime = DateTime.now();
})
],
),
SizedBox(
height: 10,
),
Container(
padding: EdgeInsets.all(10),
child: Text('Ended Time')),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(width: 60,),
Container(
padding: EdgeInsets.symmetric(
horizontal: 12, vertical: 1),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey, width: 2)),
child: MaterialButton(
onPressed: () {
setState(() {
DatePicker.showDateTimePicker(
context,
showTitleActions: true,
onChanged: (date) {
// print('change $date');
}, onConfirm: (date) {
setState(() {
if(startTime.compareTo(date) > 0){
const snackBar = SnackBar(
content: Text('You cannot end something before you start it!'),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}else {
endTime = date;
}
});
},
currentTime: endTime,
locale: LocaleType.en);
});
},
child: Text(dateFormat.format(endTime),
style: TextStyle(
color: Colors.blue)))),
QuickTimeButton('Now', Function: (){
endTime = DateTime.now();
})
],
),
SizedBox(
height: 30,
),
Text('Duration : ' +
_printDuration(
endTime.difference(startTime)),
style:TextStyle(
fontSize: 20,
)),
Divider(
height: 30,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
],
)
]),
],
)),
)),
),
Expanded(
flex: 1,
child: Container(
padding:
EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
flex: 5,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
child: ElevatedButton(
style:ElevatedButton.styleFrom(
primary: Colors.red,
shape: StadiumBorder()
),
],
)
),
Container(
child: Divider(
height: 30,
)),
Container(
padding: EdgeInsets.all(10),
child: Text('Start Time')),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
QuickTimeButton('Last', Function: (){
if(User.activities.length > 0) {
startTime= User.activities[0].endTime;
}
})
,
Container(
padding: EdgeInsets.symmetric(
horizontal: 12, vertical: 1),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey, width: 2)),
child: MaterialButton(
onPressed: () {
setState(() {
DatePicker.showDateTimePicker(
context,
showTitleActions: true,
onChanged: (date) {
// print('change $date');
}, onConfirm: (date) {
setState(() {
if(endTime.compareTo(date) < 0){
const snackBar = SnackBar(
content: Text('You cannot start something after you ended it!'),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}else {
startTime = date;
}
});
},
currentTime: startTime,
locale: LocaleType.en);
});
},
child: Text(
dateFormat.format(startTime),
style: TextStyle(
color: Colors.blue)))),
QuickTimeButton('Now', Function: (){
startTime = DateTime.now();
})
],
),
SizedBox(
height: 10,
),
Container(
padding: EdgeInsets.all(10),
child: Text('Ended Time')),
Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(width: 60,),
Container(
padding: EdgeInsets.symmetric(
horizontal: 12, vertical: 1),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
border: Border.all(
color: Colors.grey, width: 2)),
child: MaterialButton(
onPressed: () {
setState(() {
DatePicker.showDateTimePicker(
context,
showTitleActions: true,
onChanged: (date) {
// print('change $date');
}, onConfirm: (date) {
setState(() {
if(startTime.compareTo(date) > 0){
const snackBar = SnackBar(
content: Text('You cannot end something before you start it!'),
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}else {
endTime = date;
}
});
},
currentTime: endTime,
locale: LocaleType.en);
});
},
child: Text(dateFormat.format(endTime),
style: TextStyle(
color: Colors.blue)))),
QuickTimeButton('Now', Function: (){
endTime = DateTime.now();
})
],
),
SizedBox(
height: 30,
),
Text('Duration : ' +
_printDuration(
endTime.difference(startTime)),
style:TextStyle(
fontSize: 20,
)),
Divider(
height: 30,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
],
)
]),
],
))),
Container(
padding:
EdgeInsets.symmetric(vertical: 10, horizontal: 20),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
flex: 5,
onPressed: () {
Navigator.pop(context);
},
child: Text('Back',
style: TextStyle(fontSize: 20))))),
Expanded(
flex: 6,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
child: ElevatedButton(
style:ElevatedButton.styleFrom(
primary: Colors.red,
primary: Colors.green,
shape: StadiumBorder()
),
onPressed: () {
Navigator.pop(context);
},
child: Text('Back',
style: TextStyle(fontSize: 20))))),
Expanded(
flex: 6,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 0),
child: ElevatedButton(
style:ElevatedButton.styleFrom(
primary: Colors.green,
shape: StadiumBorder()
),
onPressed: () {
onPressed: () {
add_action();
},
child: Text('Add Entry',
style: TextStyle(fontSize: 20))))),
],
))
add_action();
},
child: Text('Add Entry',
style: TextStyle(fontSize: 20))))),
],
)),
)
])));
}