Compare commits
8 Commits
a3258b84fe
...
v0.1.3
| Author | SHA1 | Date | |
|---|---|---|---|
| 81222de7fe | |||
| 6dc7161b41 | |||
| f1756b30d1 | |||
| 77a524f3ec | |||
| 392ec22dcd | |||
| 064c014f8b | |||
| 410a7eb843 | |||
| 20b017b066 |
@@ -0,0 +1,37 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppTheme {
|
||||
AppTheme._();
|
||||
|
||||
static ThemeData get lightTheme => _baseTheme(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.indigo,
|
||||
brightness: Brightness.light,
|
||||
),
|
||||
);
|
||||
|
||||
static ThemeData get darkTheme => _baseTheme(
|
||||
colorScheme: ColorScheme.fromSeed(
|
||||
seedColor: Colors.indigo,
|
||||
brightness: Brightness.dark,
|
||||
),
|
||||
);
|
||||
|
||||
static ThemeData _baseTheme({required ColorScheme colorScheme}) {
|
||||
final theme = ThemeData(useMaterial3: true, colorScheme: colorScheme);
|
||||
final universalBorderRadius = BorderRadius.circular(12);
|
||||
|
||||
return theme.copyWith(
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
border: OutlineInputBorder(borderRadius: universalBorderRadius),
|
||||
),
|
||||
|
||||
listTileTheme: ListTileThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: universalBorderRadius,
|
||||
side: BorderSide(color: colorScheme.secondaryContainer, width: 2),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'app_theme.dart';
|
||||
import 'model/repositories/local_repository.dart';
|
||||
import 'pages/task_edit_page.dart';
|
||||
import 'pages/task_overview_page.dart';
|
||||
@@ -33,6 +34,8 @@ class MainApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: AppTheme.lightTheme,
|
||||
darkTheme: AppTheme.darkTheme,
|
||||
routes: {
|
||||
TaskOverviewPage.routeName: (context) => TaskOverviewPage(),
|
||||
TaskEditPage.routeName: (context) => TaskEditPage(),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import '../location.dart';
|
||||
import '../task.dart';
|
||||
|
||||
class CreateTaskRequest {
|
||||
|
||||
@@ -22,7 +22,12 @@ class LocalRepository
|
||||
if (_prefs == null) {
|
||||
await SharedPreferencesWithCache.create(
|
||||
cacheOptions: const SharedPreferencesWithCacheOptions(
|
||||
allowList: <String>{_tasksKey, _taskOrderKey},
|
||||
allowList: <String>{
|
||||
_tasksKey,
|
||||
_taskOrderKey,
|
||||
_alarmsKey,
|
||||
_locationsKey,
|
||||
},
|
||||
),
|
||||
).then((value) => _prefs = value);
|
||||
}
|
||||
|
||||
@@ -80,7 +80,9 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
||||
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||
),
|
||||
child: Column(
|
||||
spacing: 12,
|
||||
children: [
|
||||
SizedBox(height: 6),
|
||||
TextFormField(
|
||||
autofocus: true,
|
||||
controller: titleController,
|
||||
|
||||
@@ -5,6 +5,7 @@ import '../model/extensions/controller_context.dart';
|
||||
import '../model/task.dart';
|
||||
import '../service/controllers/task_controller.dart';
|
||||
import '../service/tools.dart';
|
||||
import '../widgets/task_dismissible.dart';
|
||||
import 'task_edit_page.dart';
|
||||
|
||||
class TaskOverviewPage extends StatefulWidget {
|
||||
@@ -21,11 +22,16 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: ReorderableListView.builder(
|
||||
itemBuilder: itemBuilder,
|
||||
itemCount: tasks.length,
|
||||
onReorderItem: context.controller<TaskController>().reorderTask,
|
||||
appBar: AppBar(title: Text('Hallo Yannick')),
|
||||
body: Padding(
|
||||
padding: EdgeInsetsGeometry.symmetric(
|
||||
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||
),
|
||||
child: ReorderableListView.builder(
|
||||
itemBuilder: itemBuilder,
|
||||
itemCount: tasks.length,
|
||||
onReorderItem: context.controller<TaskController>().reorderTask,
|
||||
),
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: onCreateTaskTapped,
|
||||
@@ -37,24 +43,32 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||
Widget itemBuilder(BuildContext context, int index) {
|
||||
final task = tasks.elementAt(index);
|
||||
|
||||
return ListTile(
|
||||
return Padding(
|
||||
key: Key(task.id),
|
||||
title: Text(task.title),
|
||||
subtitle: task.description.isNotEmpty ? Text(task.description) : null,
|
||||
trailing: Checkbox(
|
||||
value: task.isCompleted,
|
||||
onChanged: (isCompleted) => context
|
||||
.controller<TaskController>()
|
||||
.saveTask(task.copyWith(isCompleted: isCompleted)),
|
||||
padding: const EdgeInsets.only(bottom: 12),
|
||||
child: TaskDismissible(
|
||||
key: Key(task.id),
|
||||
onDismissedRight: () =>
|
||||
context.controller<TaskController>().deleteTask(task),
|
||||
child: ListTile(
|
||||
title: Text(task.title),
|
||||
subtitle: task.description.isNotEmpty ? Text(task.description) : null,
|
||||
trailing: Checkbox(
|
||||
value: task.isCompleted,
|
||||
onChanged: (isCompleted) => context
|
||||
.controller<TaskController>()
|
||||
.saveTask(task.copyWith(isCompleted: isCompleted)),
|
||||
),
|
||||
onTap: () async {
|
||||
final result = await onTaskTapped(task);
|
||||
if (result != null && context.mounted) {
|
||||
context.controller<TaskController>().saveTask(
|
||||
result.toTask(id: task.id),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
onTap: () async {
|
||||
final result = await onTaskTapped(task);
|
||||
if (result != null && context.mounted) {
|
||||
context.controller<TaskController>().saveTask(
|
||||
result.toTask(id: task.id),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TaskDismissible extends StatelessWidget {
|
||||
const TaskDismissible({
|
||||
required super.key,
|
||||
this.onDismissedRight,
|
||||
required this.child,
|
||||
});
|
||||
|
||||
final VoidCallback? onDismissedRight;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dismissible(
|
||||
key: key!,
|
||||
direction: DismissDirection.startToEnd,
|
||||
background: Container(
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
child: Align(
|
||||
alignment: AlignmentGeometry.centerLeft,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Icon(
|
||||
Icons.delete,
|
||||
color: Theme.of(context).colorScheme.onError,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
onDismissed: onDismissed,
|
||||
child: child,
|
||||
);
|
||||
}
|
||||
|
||||
void onDismissed(DismissDirection direction) {
|
||||
if (direction == DismissDirection.startToEnd && onDismissedRight != null) {
|
||||
onDismissedRight!();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user