many many many changes
This commit is contained in:
parent
2a707e51e4
commit
7b0947f93f
@ -1,5 +1,4 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class AppDrawer extends StatelessWidget {
|
||||
const AppDrawer({
|
||||
@ -25,13 +24,6 @@ class AppDrawer extends StatelessWidget {
|
||||
),
|
||||
title: const Text('Menü')),
|
||||
),
|
||||
ListTile(
|
||||
trailing: const Icon(Icons.today),
|
||||
title: const Text('Kalender'),
|
||||
onTap: () {
|
||||
context.goNamed('calendar');
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Einstellungen'),
|
||||
trailing: const Icon(Icons.settings),
|
||||
|
@ -1,20 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class CalendarWidget extends StatelessWidget {
|
||||
const CalendarWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: CalendarDatePicker(
|
||||
onDateChanged: (value) {
|
||||
context.goNamed('perDay', extra: value);
|
||||
},
|
||||
initialDate: DateTime.now(),
|
||||
firstDate: DateTime.now().subtract(const Duration(days: 30)),
|
||||
lastDate: DateTime.now(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,7 +1,4 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:kalodings/food_entry_bloc.dart';
|
||||
import 'package:kalodings/row_with_spacers_widget.dart';
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:kalodings/calendar.dart';
|
||||
import 'package:kalodings/food_entry_bloc.dart';
|
||||
import 'package:kalodings/perdate_widget.dart';
|
||||
import 'package:kalodings/storage/storage.dart';
|
||||
@ -24,6 +24,14 @@ class MainApp extends StatelessWidget {
|
||||
return FoodEntryBloc(FoodEntryState.init(), storage: storage);
|
||||
},
|
||||
child: MaterialApp.router(
|
||||
localizationsDelegates: const [
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: const [
|
||||
Locale('de'),
|
||||
],
|
||||
theme: ThemeData.dark(),
|
||||
routerConfig: router,
|
||||
),
|
||||
@ -36,25 +44,25 @@ final router = GoRouter(routes: [
|
||||
path: '/',
|
||||
name: 'perDayToday',
|
||||
builder: (context, state) {
|
||||
context
|
||||
.read<FoodEntryBloc>()
|
||||
.add(PageChangedEvent(changedToDate: DateTime.now()));
|
||||
return PerDateWidget(DateTime.now());
|
||||
}),
|
||||
GoRoute(
|
||||
path: '/day',
|
||||
name: 'perDay',
|
||||
builder: (context, state) {
|
||||
DateTime day;
|
||||
DateTime date;
|
||||
if (state.extra == null || state.extra is! DateTime) {
|
||||
day = DateTime.now();
|
||||
date = DateTime.now();
|
||||
} else {
|
||||
day = state.extra as DateTime;
|
||||
date = state.extra as DateTime;
|
||||
}
|
||||
context
|
||||
.read<FoodEntryBloc>()
|
||||
.add(PageChangedEvent(changedToDate: date));
|
||||
|
||||
return PerDateWidget(day);
|
||||
}),
|
||||
GoRoute(
|
||||
path: '/calendar',
|
||||
name: 'calendar',
|
||||
builder: (context, state) {
|
||||
return const CalendarWidget();
|
||||
return PerDateWidget(date);
|
||||
}),
|
||||
]);
|
||||
|
@ -7,29 +7,15 @@ import 'package:kalodings/food_entry_bloc.dart';
|
||||
import 'package:kalodings/food_entry_widget.dart';
|
||||
import 'package:kalodings/sum_widget.dart';
|
||||
|
||||
class PerDateWidget extends StatefulWidget {
|
||||
class PerDateWidget extends StatelessWidget {
|
||||
final DateTime date;
|
||||
const PerDateWidget(this.date, {super.key});
|
||||
|
||||
@override
|
||||
State<PerDateWidget> createState() => _PerDateWidgetState();
|
||||
}
|
||||
|
||||
class _PerDateWidgetState extends State<PerDateWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
context
|
||||
.read<FoodEntryBloc>()
|
||||
.add(PageChangedEvent(changedToDate: widget.date));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(widget.date.toString()),
|
||||
title: Text(date.toString()),
|
||||
),
|
||||
drawer: const AppDrawer(),
|
||||
body: BlocBuilder<FoodEntryBloc, FoodEntryState>(
|
||||
@ -45,7 +31,7 @@ class _PerDateWidgetState extends State<PerDateWidget> {
|
||||
onAdd: (context, entry) {
|
||||
context
|
||||
.read<FoodEntryBloc>()
|
||||
.add(FoodEntryEvent(entry: entry, date: widget.date));
|
||||
.add(FoodEntryEvent(entry: entry, date: date));
|
||||
},
|
||||
);
|
||||
}
|
||||
@ -55,8 +41,7 @@ class _PerDateWidgetState extends State<PerDateWidget> {
|
||||
onDelete: (callbackContext) {
|
||||
callbackContext.read<FoodEntryBloc>().add(
|
||||
FoodDeletionEvent(
|
||||
entryID: state.foodEntries[index].id,
|
||||
date: widget.date),
|
||||
entryID: state.foodEntries[index].id, date: date),
|
||||
);
|
||||
},
|
||||
);
|
||||
@ -65,12 +50,21 @@ class _PerDateWidgetState extends State<PerDateWidget> {
|
||||
},
|
||||
),
|
||||
floatingActionButton: FloatingActionButton(
|
||||
onPressed: () {
|
||||
context.goNamed('calendar');
|
||||
onPressed: () async {
|
||||
var router = GoRouter.of(context);
|
||||
var datePicked = await showDatePicker(
|
||||
locale: const Locale('de'),
|
||||
context: context,
|
||||
initialDate: date,
|
||||
currentDate: DateTime.now(),
|
||||
firstDate:
|
||||
DateTime.now().subtract(const Duration(days: 365 * 10)),
|
||||
lastDate: DateTime.now(),
|
||||
);
|
||||
|
||||
router.goNamed('perDay', extra: datePicked);
|
||||
},
|
||||
child: const Icon(Icons.today)),
|
||||
);
|
||||
}
|
||||
|
||||
void deleteCallback(BuildContext context, String idToDelete, DateTime date) {}
|
||||
}
|
||||
|
@ -6,6 +6,10 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <flutter_localization/flutter_localization_plugin.h>
|
||||
|
||||
void fl_register_plugins(FlPluginRegistry* registry) {
|
||||
g_autoptr(FlPluginRegistrar) flutter_localization_registrar =
|
||||
fl_plugin_registry_get_registrar_for_plugin(registry, "FlutterLocalizationPlugin");
|
||||
flutter_localization_plugin_register_with_registrar(flutter_localization_registrar);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_localization
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
@ -5,8 +5,12 @@
|
||||
import FlutterMacOS
|
||||
import Foundation
|
||||
|
||||
import flutter_localization
|
||||
import path_provider_foundation
|
||||
import shared_preferences_foundation
|
||||
|
||||
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
|
||||
FlutterLocalizationPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalizationPlugin"))
|
||||
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
|
||||
SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin"))
|
||||
}
|
||||
|
93
pubspec.lock
93
pubspec.lock
@ -73,6 +73,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -102,6 +110,19 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
flutter_localization:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_localization
|
||||
sha256: faaeb1eba307473032e2c2af737f36ced61fc98735608410d0a6d9c231b50912
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
flutter_localizations:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@ -120,6 +141,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.1.4"
|
||||
intl:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: intl
|
||||
sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.19.0"
|
||||
leak_tracker:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -280,6 +309,62 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
shared_preferences:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences
|
||||
sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.3"
|
||||
shared_preferences_android:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_android
|
||||
sha256: "93d0ec9dd902d85f326068e6a899487d1f65ffcd5798721a95330b26c8131577"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.3"
|
||||
shared_preferences_foundation:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_foundation
|
||||
sha256: "0a8a893bf4fd1152f93fec03a415d11c27c74454d96e2318a7ac38dd18683ab7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.0"
|
||||
shared_preferences_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_linux
|
||||
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
shared_preferences_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_platform_interface
|
||||
sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
shared_preferences_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_web
|
||||
sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.0"
|
||||
shared_preferences_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shared_preferences_windows
|
||||
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.3.2"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
@ -373,6 +458,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.2"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -10,7 +10,11 @@ dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_bloc: ^8.1.5
|
||||
flutter_localization: ^0.2.0
|
||||
flutter_localizations:
|
||||
sdk: flutter
|
||||
go_router: ^14.1.4
|
||||
intl: any
|
||||
path_provider: ^2.1.3
|
||||
quiver: ^3.2.1
|
||||
uuid: ^4.4.0
|
||||
|
@ -6,6 +6,9 @@
|
||||
|
||||
#include "generated_plugin_registrant.h"
|
||||
|
||||
#include <flutter_localization/flutter_localization_plugin_c_api.h>
|
||||
|
||||
void RegisterPlugins(flutter::PluginRegistry* registry) {
|
||||
FlutterLocalizationPluginCApiRegisterWithRegistrar(
|
||||
registry->GetRegistrarForPlugin("FlutterLocalizationPluginCApi"));
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
|
||||
list(APPEND FLUTTER_PLUGIN_LIST
|
||||
flutter_localization
|
||||
)
|
||||
|
||||
list(APPEND FLUTTER_FFI_PLUGIN_LIST
|
||||
|
Loading…
Reference in New Issue
Block a user