Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8779628c81 | |||
| 5a09672436 |
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'pages/task_create_page.dart';
|
||||
import 'pages/task_edit_page.dart';
|
||||
import 'pages/task_overview_page.dart';
|
||||
|
||||
@@ -15,7 +14,6 @@ class MainApp extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
routes: {
|
||||
TaskCreatePage.routeName: (context) => TaskCreatePage(),
|
||||
TaskOverviewPage.routeName: (context) => TaskOverviewPage(),
|
||||
TaskEditPage.routeName: (context) => TaskEditPage(),
|
||||
},
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
import '../location.dart';
|
||||
import '../task.dart';
|
||||
|
||||
class CreateTaskRequest {
|
||||
final String title;
|
||||
final String description;
|
||||
final DateTime? start;
|
||||
final DateTime? due;
|
||||
final bool isCompleted;
|
||||
final String category;
|
||||
final List<Task> subtasks;
|
||||
final List<DateTime> alarms;
|
||||
final Location? location;
|
||||
final String url;
|
||||
|
||||
CreateTaskRequest({
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.start,
|
||||
required this.due,
|
||||
required this.isCompleted,
|
||||
required this.category,
|
||||
required this.subtasks,
|
||||
required this.alarms,
|
||||
required this.location,
|
||||
required this.url,
|
||||
});
|
||||
|
||||
CreateTaskRequest.fromTask(Task task)
|
||||
: title = task.title,
|
||||
description = task.description,
|
||||
start = task.start,
|
||||
due = task.due,
|
||||
isCompleted = task.isCompleted,
|
||||
category = task.category,
|
||||
subtasks = task.subtasks,
|
||||
alarms = task.alarms,
|
||||
location = task.location,
|
||||
url = task.url;
|
||||
|
||||
Task toTask({required String id, required int position}) {
|
||||
return Task(
|
||||
id: id,
|
||||
title: title,
|
||||
description: description,
|
||||
start: start,
|
||||
due: due,
|
||||
isCompleted: isCompleted,
|
||||
category: category,
|
||||
subtasks: subtasks,
|
||||
alarms: alarms,
|
||||
location: location,
|
||||
url: url,
|
||||
position: position,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TaskCreatePage extends StatelessWidget {
|
||||
static const routeName = '/create';
|
||||
const TaskCreatePage({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
}
|
||||
}
|
||||
@@ -8,10 +8,10 @@ class TaskEditPage extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final task = ModalRoute.of(context)!.settings.arguments as Task;
|
||||
final task = ModalRoute.of(context)!.settings.arguments as Task?;
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(task.title)),
|
||||
appBar: AppBar(title: Text(task?.title ?? 'Create Task')),
|
||||
body: Form(child: Column()),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import '../example_data.dart';
|
||||
import '../model/task.dart';
|
||||
import 'task_create_page.dart';
|
||||
import 'task_edit_page.dart';
|
||||
|
||||
class TaskOverviewPage extends StatefulWidget {
|
||||
@@ -66,8 +65,7 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||
void onCreateTaskTapped() async {
|
||||
//TODO: example data call
|
||||
final result =
|
||||
await Navigator.of(context).pushNamed(TaskCreatePage.routeName)
|
||||
as Task?;
|
||||
await Navigator.of(context).pushNamed(TaskEditPage.routeName) as Task?;
|
||||
|
||||
if (result != null) {
|
||||
tasks.add(result);
|
||||
|
||||
Reference in New Issue
Block a user