Compare commits
1 Commits
5ef22c7b50
..
v0.1.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 392ec22dcd |
@@ -1,37 +0,0 @@
|
||||
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,6 +1,5 @@
|
||||
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';
|
||||
@@ -34,8 +33,6 @@ 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(),
|
||||
|
||||
@@ -80,9 +80,7 @@ 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,
|
||||
|
||||
@@ -22,16 +22,11 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
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,
|
||||
),
|
||||
appBar: AppBar(),
|
||||
body: ReorderableListView.builder(
|
||||
itemBuilder: itemBuilder,
|
||||
itemCount: tasks.length,
|
||||
onReorderItem: context.controller<TaskController>().reorderTask,
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: onCreateTaskTapped,
|
||||
@@ -43,31 +38,27 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
||||
Widget itemBuilder(BuildContext context, int index) {
|
||||
final task = tasks.elementAt(index);
|
||||
|
||||
return Padding(
|
||||
return TaskDismissible(
|
||||
key: Key(task.id),
|
||||
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),
|
||||
);
|
||||
}
|
||||
},
|
||||
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),
|
||||
);
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,10 +16,7 @@ class TaskDismissible extends StatelessWidget {
|
||||
key: key!,
|
||||
direction: DismissDirection.startToEnd,
|
||||
background: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
color: Theme.of(context).colorScheme.error,
|
||||
child: Align(
|
||||
alignment: AlignmentGeometry.centerLeft,
|
||||
child: Padding(
|
||||
|
||||
Reference in New Issue
Block a user