Skip to content

Commit

Permalink
Improve design
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMedo committed Oct 29, 2024
1 parent 1f13e5f commit 92f4214
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 71 deletions.
45 changes: 21 additions & 24 deletions lib/screen/details/details_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ class _DetailsScreenState extends State<DetailsScreen> {

@override
Widget build(BuildContext context) {
final brightness = MediaQuery.of(context).platformBrightness;
final isDarkMode = brightness == Brightness.dark;

return PopScope(
onPopInvokedWithResult: (isPopped, _) {
if (isPopped && text != widget.todo.text) {
Expand All @@ -53,33 +50,33 @@ class _DetailsScreenState extends State<DetailsScreen> {
style: Theme.of(context).textTheme.headlineLarge,
),
centerTitle: true,
),
body: Column(
children: [
TextField(
controller: _controller,
decoration: InputDecoration(
border: OutlineInputBorder(),
),
onChanged: (value) {
setState(() {
text = value;
});
},
),
ElevatedButton(
actions: [
IconButton(
onPressed: () {
_deleteTodo(widget.todo.id);
Navigator.of(context).pop();
},
style: ElevatedButton.styleFrom(
backgroundColor: isDarkMode ? Colors.red : Colors.deepOrange,
foregroundColor: Colors.white,
),
child: Text('Delete'),
),
icon: Icon(Icons.delete_outline),
tooltip: 'Delete',
)
],
),
body: Padding(
padding: const EdgeInsets.all(16),
child: Column(
children: [
TextField(
controller: _controller,
decoration: InputDecoration(labelText: 'Edit todo'),
onChanged: (value) {
setState(() {
text = value;
});
},
),
],
),
),
),
);
}
Expand Down
60 changes: 33 additions & 27 deletions lib/screen/home/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,31 @@ class _HomeScreenState extends State<HomeScreen> {
),
body: Column(
children: [
SearchFilterBar(
onChanged: (query) {
setState(() {
searchQuery = query;
displayTodos = _filterTodos(allTodos);
});
},
onFilter: () {
showModalBottomSheet<bool>(
context: context,
builder: (context) {
return FilterBottomSheet(
initialHideCompleted: hideCompleted,
onHideCompleted: (checked) {
setState(() {
hideCompleted = checked;
displayTodos = _filterTodos(allTodos);
});
},
);
});
},
Padding(
padding: const EdgeInsets.all(16),
child: SearchFilterBar(
onChanged: (query) {
setState(() {
searchQuery = query;
displayTodos = _filterTodos(allTodos);
});
},
onFilter: () {
showModalBottomSheet<bool>(
context: context,
builder: (context) {
return FilterBottomSheet(
initialHideCompleted: hideCompleted,
onHideCompleted: (checked) {
setState(() {
hideCompleted = checked;
displayTodos = _filterTodos(allTodos);
});
},
);
});
},
),
),
Expanded(
child: TodosList(
Expand All @@ -104,11 +107,14 @@ class _HomeScreenState extends State<HomeScreen> {
},
),
),
TextInputRow(
onAdd: (text) {
if (userId == null) return;
_addTodo(text, userId);
},
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: TextInputRow(
onAdd: (text) {
if (userId == null) return;
_addTodo(text, userId);
},
),
),
],
),
Expand Down
21 changes: 4 additions & 17 deletions lib/screen/home/widgets/search_filter_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,38 +39,25 @@ class _SearchFilterBarState extends State<SearchFilterBar> {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.2),
spreadRadius: 1,
blurRadius: 4,
offset: const Offset(0, 2),
),
],
color: Theme.of(context).colorScheme.primary.withOpacity(0.1),
),
child: TextField(
controller: _controller,
onChanged: widget.onChanged,
decoration: InputDecoration(
prefixIcon: const Icon(
Icons.search,
color: Colors.grey,
),
prefixIcon: const Icon(Icons.search),
suffixIcon: _controller.text.isNotEmpty
? IconButton(
icon: const Icon(Icons.clear),
onPressed: _clearSearch,
color: Colors.grey,
)
: IconButton(
icon: const Icon(Icons.more_vert),
onPressed: widget.onFilter,
color: Colors.grey,
),
hintText: 'Search...',
hintStyle: const TextStyle(
color: Colors.grey,
fontSize: 16,
hintStyle: TextStyle(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
),
border: InputBorder.none,
contentPadding: const EdgeInsets.symmetric(
Expand Down
13 changes: 12 additions & 1 deletion lib/screen/home/widgets/text_input_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ class _TextInputRowState extends State<TextInputRow> {
controller: _controller,
decoration: InputDecoration(
hintText: 'Enter your todo',
border: OutlineInputBorder(),
hintStyle: TextStyle(
color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6),
),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(25),
),
prefixIcon: Icon(Icons.edit_outlined),
),
),
),
Expand All @@ -39,6 +45,11 @@ class _TextInputRowState extends State<TextInputRow> {
_controller.clear();
}
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blueGrey,
foregroundColor: Colors.white,
fixedSize: const Size(88, 54),
),
child: Text('Add'),
),
],
Expand Down
2 changes: 0 additions & 2 deletions lib/screen/home/widgets/todos_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ class TodosList extends StatelessWidget {

@override
Widget build(BuildContext context) {
if (todos.isEmpty) return Center(child: Text('Add your first ToDo'));

return ListView.builder(
itemCount: todos.length,
itemBuilder: (context, index) {
Expand Down

0 comments on commit 92f4214

Please sign in to comment.