Completed the UI for the new task screen
This commit is contained in:
parent
1fdae70358
commit
2c42d3c4a2
4 changed files with 177 additions and 18 deletions
|
|
@ -4,6 +4,8 @@ import '../blocs/new_task_bloc.dart';
|
||||||
import '../widgets/custom_app_bar.dart';
|
import '../widgets/custom_app_bar.dart';
|
||||||
import '../widgets/custom_dropdown.dart';
|
import '../widgets/custom_dropdown.dart';
|
||||||
import '../widgets/big_text_input.dart';
|
import '../widgets/big_text_input.dart';
|
||||||
|
import '../widgets/gradient_touchable_container.dart';
|
||||||
|
import '../widgets/priority_selector.dart';
|
||||||
|
|
||||||
class NewTaskScreen extends StatefulWidget {
|
class NewTaskScreen extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
|
|
@ -11,6 +13,17 @@ class NewTaskScreen extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _NewTaskScreenState extends State<NewTaskScreen> {
|
class _NewTaskScreenState extends State<NewTaskScreen> {
|
||||||
|
static const kLabelStyle = TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
);
|
||||||
|
static const kButtonStyle = TextStyle(
|
||||||
|
color: Colors.white,
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
);
|
||||||
|
|
||||||
final NewTaskBloc bloc = NewTaskBloc();
|
final NewTaskBloc bloc = NewTaskBloc();
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
@ -26,9 +39,41 @@ class _NewTaskScreenState extends State<NewTaskScreen> {
|
||||||
height: 95,
|
height: 95,
|
||||||
),
|
),
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 10,
|
height: 15,
|
||||||
),
|
),
|
||||||
|
buildDropdownSection(),
|
||||||
|
SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
buildPrioritySelectorSection(),
|
||||||
|
SizedBox(
|
||||||
|
height: 20,
|
||||||
|
),
|
||||||
|
GradientTouchableContainer(
|
||||||
|
height: 40,
|
||||||
|
width: 330,
|
||||||
|
radius: 8,
|
||||||
|
child: Text(
|
||||||
|
'Submit',
|
||||||
|
style: kButtonStyle,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildDropdownSection() {
|
||||||
|
return Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
'Event',
|
||||||
|
style: kLabelStyle,
|
||||||
|
),
|
||||||
|
Spacer(),
|
||||||
CustomDropdownButton(
|
CustomDropdownButton(
|
||||||
|
width: 230,
|
||||||
hint: Text('Event'),
|
hint: Text('Event'),
|
||||||
onChanged: (item) {},
|
onChanged: (item) {},
|
||||||
items: ['Math', 'Lenguajes', 'Redes'].map((String name) {
|
items: ['Math', 'Lenguajes', 'Redes'].map((String name) {
|
||||||
|
|
@ -42,8 +87,22 @@ class _NewTaskScreenState extends State<NewTaskScreen> {
|
||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildPrioritySelectorSection() {
|
||||||
|
return Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Text(
|
||||||
|
'Priority',
|
||||||
|
style: kLabelStyle,
|
||||||
),
|
),
|
||||||
|
Spacer(),
|
||||||
|
PrioritySelector(
|
||||||
|
onChage: (priority) {},
|
||||||
|
width: 230,
|
||||||
),
|
),
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,20 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import './models/task_model.dart';
|
import './models/task_model.dart';
|
||||||
|
|
||||||
// TODO: migrate to enum https://github.com/AYM1607/do_more/issues/4
|
const kLowPriorityColor = Color(0xFF06AD12);
|
||||||
|
const kMediumPriorityColor = Color(0xFFF6A93B);
|
||||||
|
const kHighPriorityColor = Color(0xFFF42850);
|
||||||
|
|
||||||
Color getColorFromPriority(TaskPriority priority) {
|
Color getColorFromPriority(TaskPriority priority) {
|
||||||
switch (priority) {
|
switch (priority) {
|
||||||
case TaskPriority.low:
|
case TaskPriority.low:
|
||||||
return Color(0xFF06AD12);
|
return kLowPriorityColor;
|
||||||
break;
|
break;
|
||||||
case TaskPriority.medium:
|
case TaskPriority.medium:
|
||||||
return Color(0xFFF6A93B);
|
return kMediumPriorityColor;
|
||||||
break;
|
break;
|
||||||
case TaskPriority.high:
|
case TaskPriority.high:
|
||||||
return Color(0xFFF42850);
|
return kHighPriorityColor;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return Colors.white;
|
return Colors.white;
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ class _DropdownMenuPainter extends CustomPainter {
|
||||||
|
|
||||||
// Modified the original recatngle to be flush with the button instead of
|
// Modified the original recatngle to be flush with the button instead of
|
||||||
// overflowing its original size.
|
// overflowing its original size.
|
||||||
final Rect rect = Rect.fromLTRB(20, top.evaluate(resize) + 10,
|
final Rect rect = Rect.fromLTRB(16, top.evaluate(resize) + 10,
|
||||||
size.width - 20, bottom.evaluate(resize));
|
size.width - 20, bottom.evaluate(resize));
|
||||||
|
|
||||||
_painter.paint(canvas, rect.topLeft, ImageConfiguration(size: rect.size));
|
_painter.paint(canvas, rect.topLeft, ImageConfiguration(size: rect.size));
|
||||||
|
|
@ -543,6 +543,7 @@ class CustomDropdownButton<T> extends StatefulWidget {
|
||||||
this.iconSize = 24.0,
|
this.iconSize = 24.0,
|
||||||
this.isDense = false,
|
this.isDense = false,
|
||||||
this.isExpanded = false,
|
this.isExpanded = false,
|
||||||
|
this.width = 200,
|
||||||
}) : assert(items == null ||
|
}) : assert(items == null ||
|
||||||
items.isEmpty ||
|
items.isEmpty ||
|
||||||
value == null ||
|
value == null ||
|
||||||
|
|
@ -596,6 +597,8 @@ class CustomDropdownButton<T> extends StatefulWidget {
|
||||||
|
|
||||||
final bool isElevated;
|
final bool isElevated;
|
||||||
|
|
||||||
|
final double width;
|
||||||
|
|
||||||
/// The text style to use for text in the dropdown button and the dropdown
|
/// The text style to use for text in the dropdown button and the dropdown
|
||||||
/// menu that appears when you tap the button.
|
/// menu that appears when you tap the button.
|
||||||
///
|
///
|
||||||
|
|
@ -779,6 +782,7 @@ class _DropdownButtonState<T> extends State<CustomDropdownButton<T>>
|
||||||
),
|
),
|
||||||
padding: padding.resolve(Directionality.of(context)),
|
padding: padding.resolve(Directionality.of(context)),
|
||||||
height: 35.0,
|
height: 35.0,
|
||||||
|
width: widget.width,
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
|
||||||
93
lib/src/widgets/priority_selector.dart
Normal file
93
lib/src/widgets/priority_selector.dart
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
|
import '../models/task_model.dart';
|
||||||
|
import '../utils.dart';
|
||||||
|
|
||||||
|
class PrioritySelector extends StatefulWidget {
|
||||||
|
final double width;
|
||||||
|
final Function(TaskPriority) onChage;
|
||||||
|
|
||||||
|
PrioritySelector({
|
||||||
|
this.width = 200,
|
||||||
|
@required this.onChage,
|
||||||
|
});
|
||||||
|
|
||||||
|
_PrioritySelectorState createState() => _PrioritySelectorState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PrioritySelectorState extends State<PrioritySelector> {
|
||||||
|
TaskPriority selectedPriority = TaskPriority.high;
|
||||||
|
|
||||||
|
static const kCheckMark = Center(
|
||||||
|
child: Icon(
|
||||||
|
FontAwesomeIcons.checkCircle,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
height: 35.0,
|
||||||
|
width: widget.width,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Expanded(
|
||||||
|
flex: 8,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => setPriority(TaskPriority.high),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kHighPriorityColor,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
selectedPriority == TaskPriority.high ? kCheckMark : null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(
|
||||||
|
flex: 2,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
flex: 8,
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => setPriority(TaskPriority.medium),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kMediumPriorityColor,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child:
|
||||||
|
selectedPriority == TaskPriority.medium ? kCheckMark : null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Spacer(
|
||||||
|
flex: 2,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: GestureDetector(
|
||||||
|
onTap: () => setPriority(TaskPriority.low),
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: kLowPriorityColor,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
),
|
||||||
|
child: selectedPriority == TaskPriority.low ? kCheckMark : null,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
flex: 8,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setPriority(TaskPriority priority) {
|
||||||
|
widget.onChage(priority);
|
||||||
|
setState(() {
|
||||||
|
selectedPriority = priority;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue