Better colorway, prettier features
parent
f83dedda4a
commit
7065e69241
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,4 @@
|
||||||
#Tue Oct 29 18:01:57 CET 2024
|
#Wed Oct 30 19:15:57 CET 2024
|
||||||
base.0=/Users/user/Documents/Programmierung/CPD/cpd_2024_todo/build/app/intermediates/dex/debug/mergeExtDexDebug/classes.dex
|
base.0=/Users/user/Documents/Programmierung/CPD/cpd_2024_todo/build/app/intermediates/dex/debug/mergeExtDexDebug/classes.dex
|
||||||
base.1=/Users/user/Documents/Programmierung/CPD/cpd_2024_todo/build/app/intermediates/dex/debug/mergeLibDexDebug/0/classes.dex
|
base.1=/Users/user/Documents/Programmierung/CPD/cpd_2024_todo/build/app/intermediates/dex/debug/mergeLibDexDebug/0/classes.dex
|
||||||
base.2=/Users/user/Documents/Programmierung/CPD/cpd_2024_todo/build/app/intermediates/dex/debug/mergeProjectDexDebug/0/classes.dex
|
base.2=/Users/user/Documents/Programmierung/CPD/cpd_2024_todo/build/app/intermediates/dex/debug/mergeProjectDexDebug/0/classes.dex
|
||||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
||||||
b1dbbd5f3120f7b6042aa8334edab1c8b68a8aa6
|
c90f7e0c7d3bf85952cc2520d7b349a1d904dbe1
|
Binary file not shown.
|
@ -7257,6 +7257,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
flutter_lints
|
flutter_lints
|
||||||
|
path_provider
|
||||||
|
path_provider_android
|
||||||
|
path_provider_foundation
|
||||||
path_provider_linux
|
path_provider_linux
|
||||||
path_provider_platform_interface
|
path_provider_platform_interface
|
||||||
path_provider_windows
|
path_provider_windows
|
||||||
|
@ -33605,6 +33608,39 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
sqflite
|
||||||
|
sqflite_android
|
||||||
|
sqflite_common
|
||||||
|
sqflite_darwin
|
||||||
|
sqflite_platform_interface
|
||||||
|
|
||||||
|
BSD 2-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2019, Alexandre Roux Tekartik
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
sqlite
|
sqlite
|
||||||
|
|
||||||
|
@ -33662,6 +33698,30 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
synchronized
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2016, Alexandre Roux Tekartik.
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
term_glyph
|
term_glyph
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ToDoItem {
|
||||||
this.status = 'Pending',
|
this.status = 'Pending',
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<String, dynamic> toMap() {
|
Map<String, dynamic> toJson() {
|
||||||
return {
|
return {
|
||||||
'id' : id,
|
'id' : id,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
@ -22,7 +22,7 @@ class ToDoItem {
|
||||||
'status': status,
|
'status': status,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
static ToDoItem fromMap(Map<String, dynamic> json) {
|
static ToDoItem fromJson(Map<String, dynamic> json) {
|
||||||
return ToDoItem(
|
return ToDoItem(
|
||||||
id: json['id'],
|
id: json['id'],
|
||||||
name: json['name'],
|
name: json['name'],
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:todo/database/PathProvider.dart';
|
import 'package:todo/database/PathProvider.dart';
|
||||||
|
import 'package:todo/database/SharedPref.dart';
|
||||||
import '../database/Sqlite.dart';
|
import '../database/Sqlite.dart';
|
||||||
import 'ToDoItem.dart';
|
import 'ToDoItem.dart';
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ class PathProvider implements DatabaseInterface {
|
||||||
}
|
}
|
||||||
Future<File> get _localFile async {
|
Future<File> get _localFile async {
|
||||||
final path = await _localPath;
|
final path = await _localPath;
|
||||||
|
print(path);
|
||||||
File file = File('$path/dataSeq.txt');
|
File file = File('$path/dataSeq.txt');
|
||||||
if (!file.existsSync()) {
|
if (!file.existsSync()) {
|
||||||
file = await file.create();
|
file = await file.create();
|
||||||
|
@ -24,9 +25,11 @@ class PathProvider implements DatabaseInterface {
|
||||||
Future<List<ToDoItem>> getToDoItems() async {
|
Future<List<ToDoItem>> getToDoItems() async {
|
||||||
final file = await _localFile;
|
final file = await _localFile;
|
||||||
final contents = await file.readAsString();
|
final contents = await file.readAsString();
|
||||||
List<dynamic> contentJson = jsonDecode(contents);
|
final contentJson = jsonDecode(contents);
|
||||||
|
|
||||||
List<ToDoItem> toDoList = contentJson.map((item) => ToDoItem.fromMap(item)).toList();
|
List<dynamic> contentList = contentJson is List ? contentJson : [contentJson];
|
||||||
|
|
||||||
|
List<ToDoItem> toDoList = contentList.map((item) => ToDoItem.fromJson(item)).toList();
|
||||||
return toDoList;
|
return toDoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,21 +39,21 @@ class PathProvider implements DatabaseInterface {
|
||||||
List<ToDoItem> l = await getToDoItems();
|
List<ToDoItem> l = await getToDoItems();
|
||||||
l.add(item);
|
l.add(item);
|
||||||
final file = await _localFile;
|
final file = await _localFile;
|
||||||
return file.writeAsString(jsonEncode(l.map((item) => item.toMap()).toList()));
|
return file.writeAsString(jsonEncode(l.map((item) => item.toJson()).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<File> updateToDoItem(ToDoItem item) async {
|
Future<File> updateToDoItem(ToDoItem item) async {
|
||||||
final file = await _localFile;
|
final file = await _localFile;
|
||||||
return file.writeAsString(item.toMap() as String);
|
return file.writeAsString(jsonEncode(item.toJson()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<File> deleteToDoItem(int id) async {
|
Future<File> deleteToDoItem(int id) async {
|
||||||
final file = await _localFile;
|
final file = await _localFile;
|
||||||
List<ToDoItem> l = await getToDoItems();
|
List<ToDoItem> l = await getToDoItems();
|
||||||
l.remove(l.where((item) => item.id == id).first);
|
l.remove(l.firstWhere((item) => item.id == id));
|
||||||
return file.writeAsString(jsonEncode(l.map((item) => item.toMap()).toList()));
|
return file.writeAsString(jsonEncode(l.map((item) => item.toJson()).toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
import 'dart:convert';
|
||||||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
import 'package:todo/database/DatabaseInterface.dart';
|
||||||
|
|
||||||
|
import '../buisness/ToDoItem.dart';
|
||||||
|
|
||||||
|
class SharedPref implements DatabaseInterface {
|
||||||
|
final todoKey = "todos";
|
||||||
|
|
||||||
|
Future<SharedPreferences> get _prefs async {
|
||||||
|
SharedPreferences preferences = await SharedPreferences.getInstance();
|
||||||
|
if (preferences.getString(todoKey) == null) {
|
||||||
|
preferences.setString(todoKey, "[]");
|
||||||
|
}
|
||||||
|
return preferences;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<ToDoItem> insertToDoItem(ToDoItem todo) async {
|
||||||
|
SharedPreferences preferences = await _prefs;
|
||||||
|
final String prefContent = preferences.getString(todoKey)!;
|
||||||
|
|
||||||
|
final List<dynamic> fileJson = jsonDecode(prefContent);
|
||||||
|
|
||||||
|
List<ToDoItem> todoList =
|
||||||
|
fileJson.map((todo) => ToDoItem.fromJson(todo)).toList();
|
||||||
|
|
||||||
|
todo.id = DateTime.now().millisecondsSinceEpoch;
|
||||||
|
todoList.add(todo);
|
||||||
|
|
||||||
|
preferences.setString(todoKey, jsonEncode(todoList));
|
||||||
|
|
||||||
|
return todo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteToDoItem(int id) async {
|
||||||
|
SharedPreferences preferences = await _prefs;
|
||||||
|
final String prefContent = preferences.getString(todoKey)!;
|
||||||
|
|
||||||
|
final List<dynamic> fileJson = jsonDecode(prefContent);
|
||||||
|
|
||||||
|
List<ToDoItem> todoList =
|
||||||
|
fileJson.map((todo) => ToDoItem.fromJson(todo)).toList();
|
||||||
|
|
||||||
|
todoList.removeWhere((todo) => todo.id == id);
|
||||||
|
|
||||||
|
preferences.setString(todoKey, jsonEncode(todoList));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<List<ToDoItem>> getToDoItems() async {
|
||||||
|
SharedPreferences preferences = await _prefs;
|
||||||
|
final String prefContent = preferences.getString(todoKey)!;
|
||||||
|
|
||||||
|
final List<dynamic> fileJson = jsonDecode(prefContent);
|
||||||
|
|
||||||
|
return fileJson.map((todo) => ToDoItem.fromJson(todo)).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> updateToDoItem(ToDoItem todo) async {
|
||||||
|
SharedPreferences preferences = await _prefs;
|
||||||
|
final String prefContent = preferences.getString(todoKey)!;
|
||||||
|
|
||||||
|
final List<dynamic> fileJson = jsonDecode(prefContent);
|
||||||
|
|
||||||
|
List<ToDoItem> todoList =
|
||||||
|
fileJson.map((todo) => ToDoItem.fromJson(todo)).toList();
|
||||||
|
|
||||||
|
final todoToUpdate = todoList.firstWhere((t) => t.id == todo.id);
|
||||||
|
final todoToUpdateIndex = todoList.indexOf(todoToUpdate);
|
||||||
|
|
||||||
|
todoToUpdate.name = todo.name;
|
||||||
|
todoToUpdate.description = todo.description;
|
||||||
|
todoToUpdate.status = todo.status;
|
||||||
|
todoToUpdate.dueDate = todo.dueDate;
|
||||||
|
|
||||||
|
todoList.replaceRange(todoToUpdateIndex, todoToUpdateIndex, [todoToUpdate]);
|
||||||
|
|
||||||
|
preferences.setString(todoKey, jsonEncode(todoList));
|
||||||
|
}
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ class Sqlite implements DatabaseInterface {
|
||||||
final db = await database;
|
final db = await database;
|
||||||
final id = await db.insert(
|
final id = await db.insert(
|
||||||
'todo_items',
|
'todo_items',
|
||||||
item.toMap(),
|
item.toJson(),
|
||||||
conflictAlgorithm: ConflictAlgorithm.replace,
|
conflictAlgorithm: ConflictAlgorithm.replace,
|
||||||
);
|
);
|
||||||
item.id = id;
|
item.id = id;
|
||||||
|
@ -57,7 +57,7 @@ class Sqlite implements DatabaseInterface {
|
||||||
final List<Map<String, dynamic>> maps = await db.query('todo_items');
|
final List<Map<String, dynamic>> maps = await db.query('todo_items');
|
||||||
|
|
||||||
return List.generate(maps.length, (i) {
|
return List.generate(maps.length, (i) {
|
||||||
return ToDoItem.fromMap(maps[i]);
|
return ToDoItem.fromJson(maps[i]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class Sqlite implements DatabaseInterface {
|
||||||
final db = await database;
|
final db = await database;
|
||||||
await db.update(
|
await db.update(
|
||||||
'todo_items',
|
'todo_items',
|
||||||
item.toMap(),
|
item.toJson(),
|
||||||
where: 'id = ?',
|
where: 'id = ?',
|
||||||
whereArgs: [item.id],
|
whereArgs: [item.id],
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ToDoApp extends StatelessWidget {
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
primarySwatch: Colors.orange,
|
primarySwatch: Colors.orange,
|
||||||
hintColor: Colors.black,
|
hintColor: Colors.white,
|
||||||
),
|
),
|
||||||
home: ToDoListScreen(),
|
home: ToDoListScreen(),
|
||||||
);
|
);
|
||||||
|
|
|
@ -7,6 +7,17 @@ class ToDoExpandableWidget extends StatelessWidget {
|
||||||
final ToDoItem toDoItem;
|
final ToDoItem toDoItem;
|
||||||
final int id;
|
final int id;
|
||||||
|
|
||||||
|
getStatusColor(String status) {
|
||||||
|
switch(status) {
|
||||||
|
case 'Pending':
|
||||||
|
return Colors.blueGrey;
|
||||||
|
case 'In Progress':
|
||||||
|
return Colors.lime;
|
||||||
|
case 'Completed':
|
||||||
|
return Colors.green;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ToDoExpandableWidget({
|
const ToDoExpandableWidget({
|
||||||
super.key,
|
super.key,
|
||||||
required this.toDoItem,
|
required this.toDoItem,
|
||||||
|
@ -16,7 +27,9 @@ class ToDoExpandableWidget extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Card(
|
return Card(
|
||||||
color: Colors.orange[100],
|
color: getStatusColor(toDoItem.status),
|
||||||
|
margin: const EdgeInsets.only(bottom: 16),
|
||||||
|
|
||||||
child: ExpansionTile(
|
child: ExpansionTile(
|
||||||
title: Text(toDoItem.name, style: const TextStyle(color: Colors.black)),
|
title: Text(toDoItem.name, style: const TextStyle(color: Colors.black)),
|
||||||
subtitle: Text('Due: ${toDoItem.dueDate.toLocal()}'),
|
subtitle: Text('Due: ${toDoItem.dueDate.toLocal()}'),
|
||||||
|
@ -26,24 +39,31 @@ class ToDoExpandableWidget extends StatelessWidget {
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text('Description: ${toDoItem.description}', style: const TextStyle(color: Colors.black)),
|
Text(toDoItem.description, style: const TextStyle(color: Colors.black)),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
ElevatedButton.icon(
|
TextButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Provider.of<ToDoProvider>(context, listen: false).deleteItem(toDoItem.id!);
|
Provider.of<ToDoProvider>(context, listen: false).deleteItem(toDoItem.id!);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.delete),
|
icon: const Icon(Icons.delete),
|
||||||
label: const Text("Delete"),
|
label: const Text("Delete"),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
|
foregroundColor: const Color(0xFFBB0000),
|
||||||
|
backgroundColor: getStatusColor(toDoItem.status),
|
||||||
textStyle: const TextStyle(fontSize: 15),
|
textStyle: const TextStyle(fontSize: 15),
|
||||||
iconColor: const Color(0xFFFF0000),
|
iconColor: const Color(0xFFBB0000),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Text('Status: ', style: TextStyle(color: Colors.black)),
|
Container(
|
||||||
DropdownButton<String>(
|
decoration: BoxDecoration(
|
||||||
|
color: getStatusColor(toDoItem.status),
|
||||||
|
borderRadius: BorderRadius.circular(20.0),
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
child: DropdownButton<String>(
|
||||||
value: toDoItem.status,
|
value: toDoItem.status,
|
||||||
items: ['Pending', 'In Progress', 'Completed']
|
items: ['Pending', 'In Progress', 'Completed']
|
||||||
.map((status) => DropdownMenuItem(
|
.map((status) => DropdownMenuItem(
|
||||||
|
@ -51,12 +71,15 @@ class ToDoExpandableWidget extends StatelessWidget {
|
||||||
child: Text(status),
|
child: Text(status),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
|
dropdownColor: getStatusColor(toDoItem.status),
|
||||||
|
borderRadius: BorderRadius.circular(20),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
Provider.of<ToDoProvider>(context, listen: false).updateStatus(id, value);
|
Provider.of<ToDoProvider>(context, listen: false).updateStatus(id, value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -10,12 +10,17 @@ class ToDoListScreen extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
backgroundColor: Colors.grey[900],
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text('To-Do List'),
|
backgroundColor: Colors.deepOrange[800],
|
||||||
|
title: const Text('To-Do List'),
|
||||||
|
titleSpacing: 150.0,
|
||||||
),
|
),
|
||||||
body: Consumer<ToDoProvider>(
|
body: Consumer<ToDoProvider>(
|
||||||
builder: (context, toDoProvider, child) {
|
builder: (context, toDoProvider, child) {
|
||||||
return ListView(
|
return Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: ListView(
|
||||||
children: toDoProvider.toDoList.map((todo) {
|
children: toDoProvider.toDoList.map((todo) {
|
||||||
return ToDoExpandableWidget(
|
return ToDoExpandableWidget(
|
||||||
toDoItem: todo,
|
toDoItem: todo,
|
||||||
|
@ -23,6 +28,7 @@ class ToDoListScreen extends StatelessWidget {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).toList()
|
).toList()
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
@ -37,12 +43,12 @@ class ToDoListScreen extends StatelessWidget {
|
||||||
onPressed: () => _showSortOptions(context),
|
onPressed: () => _showSortOptions(context),
|
||||||
backgroundColor: Colors.orange,
|
backgroundColor: Colors.orange,
|
||||||
heroTag: null,
|
heroTag: null,
|
||||||
child: Icon(Icons.sort), // Damit beide Floating Buttons keine Konflikte haben
|
child: const Icon(Icons.sort), // Damit beide Floating Buttons keine Konflikte haben
|
||||||
),
|
),
|
||||||
// Hinzufügen-Button unten rechts
|
// Hinzufügen-Button unten rechts
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onPressed: () => _showAddToDoDialog(context),
|
onPressed: () => _showAddToDoDialog(context),
|
||||||
child: Icon(Icons.add),
|
child: const Icon(Icons.add),
|
||||||
backgroundColor: Colors.orange,
|
backgroundColor: Colors.orange,
|
||||||
heroTag: null, // Damit beide Floating Buttons keine Konflikte haben
|
heroTag: null, // Damit beide Floating Buttons keine Konflikte haben
|
||||||
),
|
),
|
||||||
|
@ -55,29 +61,30 @@ class ToDoListScreen extends StatelessWidget {
|
||||||
// Sortier-Menü anzeigen
|
// Sortier-Menü anzeigen
|
||||||
void _showSortOptions(BuildContext context) {
|
void _showSortOptions(BuildContext context) {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
|
backgroundColor: Colors.orange,
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return Wrap(
|
return Wrap(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.text_fields),
|
leading: const Icon(Icons.text_fields),
|
||||||
title: Text('Sort by Name'),
|
title: const Text('Sort by Name'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Provider.of<ToDoProvider>(context, listen: false).sortByName();
|
Provider.of<ToDoProvider>(context, listen: false).sortByName();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.date_range),
|
leading: const Icon(Icons.date_range),
|
||||||
title: Text('Sort by Due Date'),
|
title: const Text('Sort by Due Date'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Provider.of<ToDoProvider>(context, listen: false).sortByDueDate();
|
Provider.of<ToDoProvider>(context, listen: false).sortByDueDate();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: Icon(Icons.flag),
|
leading: const Icon(Icons.flag),
|
||||||
title: Text('Sort by Status'),
|
title: const Text('Sort by Status'),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Provider.of<ToDoProvider>(context, listen: false).sortByStatus();
|
Provider.of<ToDoProvider>(context, listen: false).sortByStatus();
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
|
@ -99,24 +106,37 @@ class ToDoListScreen extends StatelessWidget {
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
title: Text('Add To-Do'),
|
backgroundColor: Colors.grey[700],
|
||||||
|
insetPadding: EdgeInsets.zero,
|
||||||
|
title: const Text('Add To-Do'),
|
||||||
content: Column(
|
content: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
children: [
|
children: [
|
||||||
TextField(
|
Padding(
|
||||||
decoration: InputDecoration(labelText: 'Name'),
|
padding: const EdgeInsets.only(bottom: 8.0),
|
||||||
|
child: TextField(
|
||||||
|
decoration: const InputDecoration(labelText: 'Name', filled: true),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
name = value;
|
name = value;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
),
|
||||||
TextField(
|
TextField(
|
||||||
decoration: InputDecoration(labelText: 'Description'),
|
decoration: const InputDecoration(labelText: 'Description', filled: true),
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
description = value;
|
description = value;
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
ElevatedButton(
|
Row(
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 16.0),
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: const ButtonStyle(
|
||||||
|
backgroundColor: WidgetStatePropertyAll<Color>(Colors.orange),
|
||||||
|
),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
DateTime? picked = await showDatePicker(
|
DateTime? picked = await showDatePicker(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -126,16 +146,35 @@ class ToDoListScreen extends StatelessWidget {
|
||||||
);
|
);
|
||||||
if (picked != null) dueDate = picked;
|
if (picked != null) dueDate = picked;
|
||||||
},
|
},
|
||||||
child: Text('Pick Due Date'),
|
child: const Text('Pick Due Date'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
Row(
|
||||||
onPressed: () => Navigator.of(context).pop(),
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
child: Text('Cancel'),
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextButton(
|
||||||
|
style: const ButtonStyle(
|
||||||
|
backgroundColor: WidgetStatePropertyAll<Color>(Colors.red),
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.of(context).pop(),
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: const ButtonStyle(
|
||||||
|
backgroundColor: WidgetStatePropertyAll<Color>(Colors.green),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
if (name.isNotEmpty && description.isNotEmpty && dueDate != null) {
|
if (name.isNotEmpty && description.isNotEmpty && dueDate != null) {
|
||||||
final newToDo = ToDoItem(
|
final newToDo = ToDoItem(
|
||||||
|
@ -147,8 +186,11 @@ class ToDoListScreen extends StatelessWidget {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text('Add'),
|
child: const Text('Add'),
|
||||||
),
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue