Added app theming #2
@@ -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 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import 'app_theme.dart';
|
||||||
import 'model/repositories/local_repository.dart';
|
import 'model/repositories/local_repository.dart';
|
||||||
import 'pages/task_edit_page.dart';
|
import 'pages/task_edit_page.dart';
|
||||||
import 'pages/task_overview_page.dart';
|
import 'pages/task_overview_page.dart';
|
||||||
@@ -33,6 +34,8 @@ class MainApp extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
|
theme: AppTheme.lightTheme,
|
||||||
|
darkTheme: AppTheme.darkTheme,
|
||||||
routes: {
|
routes: {
|
||||||
TaskOverviewPage.routeName: (context) => TaskOverviewPage(),
|
TaskOverviewPage.routeName: (context) => TaskOverviewPage(),
|
||||||
TaskEditPage.routeName: (context) => TaskEditPage(),
|
TaskEditPage.routeName: (context) => TaskEditPage(),
|
||||||
|
|||||||
@@ -80,7 +80,9 @@ class _TaskEditPageState extends State<TaskEditPage> {
|
|||||||
horizontal: MediaQuery.of(context).size.width * 0.05,
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
spacing: 12,
|
||||||
children: [
|
children: [
|
||||||
|
SizedBox(height: 6),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
controller: titleController,
|
controller: titleController,
|
||||||
|
|||||||
@@ -22,11 +22,16 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(),
|
appBar: AppBar(title: Text('Hallo Yannick')),
|
||||||
body: ReorderableListView.builder(
|
body: Padding(
|
||||||
itemBuilder: itemBuilder,
|
padding: EdgeInsetsGeometry.symmetric(
|
||||||
itemCount: tasks.length,
|
horizontal: MediaQuery.of(context).size.width * 0.05,
|
||||||
onReorderItem: context.controller<TaskController>().reorderTask,
|
),
|
||||||
|
child: ReorderableListView.builder(
|
||||||
|
itemBuilder: itemBuilder,
|
||||||
|
itemCount: tasks.length,
|
||||||
|
onReorderItem: context.controller<TaskController>().reorderTask,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
floatingActionButton: FloatingActionButton(
|
floatingActionButton: FloatingActionButton(
|
||||||
onPressed: onCreateTaskTapped,
|
onPressed: onCreateTaskTapped,
|
||||||
@@ -38,27 +43,31 @@ class _TaskOverviewPageState extends State<TaskOverviewPage> {
|
|||||||
Widget itemBuilder(BuildContext context, int index) {
|
Widget itemBuilder(BuildContext context, int index) {
|
||||||
final task = tasks.elementAt(index);
|
final task = tasks.elementAt(index);
|
||||||
|
|
||||||
return TaskDismissible(
|
return Padding(
|
||||||
key: Key(task.id),
|
key: Key(task.id),
|
||||||
onDismissedRight: () =>
|
padding: const EdgeInsets.only(bottom: 12),
|
||||||
context.controller<TaskController>().deleteTask(task),
|
child: TaskDismissible(
|
||||||
child: ListTile(
|
key: Key(task.id),
|
||||||
title: Text(task.title),
|
onDismissedRight: () =>
|
||||||
subtitle: task.description.isNotEmpty ? Text(task.description) : null,
|
context.controller<TaskController>().deleteTask(task),
|
||||||
trailing: Checkbox(
|
child: ListTile(
|
||||||
value: task.isCompleted,
|
title: Text(task.title),
|
||||||
onChanged: (isCompleted) => context
|
subtitle: task.description.isNotEmpty ? Text(task.description) : null,
|
||||||
.controller<TaskController>()
|
trailing: Checkbox(
|
||||||
.saveTask(task.copyWith(isCompleted: isCompleted)),
|
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),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user