add two views

This commit is contained in:
atseirjo
2026-10-27 15:00:16 +01:00
parent 864da57537
commit 07a1bb02fd
42 changed files with 3582 additions and 346 deletions
+10
View File
@@ -0,0 +1,10 @@
import 'package:intl/intl.dart';
class DisplayFormats {
static String number(num value) =>
NumberFormat('0.##', 'de_AT').format(value);
static String date(DateTime value) =>
DateFormat('dd.MM.yyyy · HH:mm').format(value);
static String duration(int minutes) =>
'${minutes ~/ 60} h ${minutes % 60} min';
}
+21
View File
@@ -0,0 +1,21 @@
import '../models/bauteil_model.dart';
class FilamentBestand {
static Map<String, double> verbrauch(
Iterable<BauteilModel> bauteile, {
String? ohneBauteilId,
}) {
final result = <String, double>{};
for (final bauteil in bauteile) {
if (bauteil.bauteilId == ohneBauteilId) continue;
for (final filament in bauteil.filamente) {
result.update(
filament.filamentId,
(value) => value + filament.verbrauchGramm,
ifAbsent: () => filament.verbrauchGramm,
);
}
}
return result;
}
}
+34
View File
@@ -0,0 +1,34 @@
class InputValidators {
static double? number(String? value) =>
double.tryParse((value ?? '').trim().replaceAll(',', '.'));
static String? requiredText(String? value) =>
value == null || value.trim().isEmpty ? 'Bitte ausfüllen' : null;
static String? nonNegative(String? value, {bool optional = false}) {
if (optional && (value ?? '').trim().isEmpty) return null;
final parsed = number(value);
return parsed == null || !parsed.isFinite || parsed < 0
? 'Zahl ab 0 eingeben'
: null;
}
static String? positive(String? value) {
final parsed = number(value);
return parsed == null || !parsed.isFinite || parsed <= 0
? 'Zahl größer 0 eingeben'
: null;
}
static String? hours(String? value) {
final parsed = int.tryParse((value ?? '').trim());
return parsed == null || parsed < 0 ? 'Ganze Zahl ab 0 eingeben' : null;
}
static String? minutes(String? value) {
final parsed = int.tryParse((value ?? '').trim());
return parsed == null || parsed < 0 || parsed > 59
? '0 bis 59 eingeben'
: null;
}
}
+6 -7
View File
@@ -1,11 +1,10 @@
import 'package:get/get.dart';
import '../../controller/home_controller.dart';
import '../controller/anwendung_controller.dart';
import '../controller/home_controller.dart';
class SampleBindings extends Bindings {
@override
void dependencies() {
@override
void dependencies() {
Get.lazyPut<HomeController>(() => HomeController());
Get.lazyPut<AnwendungController>(() => AnwendungController());
}
}
}
}
+21 -1
View File
@@ -1,15 +1,35 @@
import 'package:get/get.dart';
import '../controller/anwendung_controller.dart';
import '../controller/bauteil_controller.dart';
import '../pages/anwendung_view.dart';
import '../pages/bauteil_view.dart';
import '../pages/home_view.dart';
import 'sample_bindings.dart';
class SampleRouts {
static final sampleBindings = SampleBindings();
static List<GetPage<dynamic>> samplePages = [
GetPage(
name: '${AnwendungView.routeName}/:filamentId',
page: () => const AnwendungView(),
binding: BindingsBuilder(
() => Get.lazyPut<AnwendungController>(
() => AnwendungController(filamentId: Get.parameters['filamentId']!),
),
),
),
GetPage(
name: BauteilView.routeName,
page: () => const BauteilView(),
binding: BindingsBuilder(
() => Get.lazyPut<BauteilController>(() => BauteilController()),
),
),
GetPage(
name: HomeView.routeName,
page: () => const HomeView(),
binding: sampleBindings,
),
];
}
}
+5
View File
@@ -0,0 +1,5 @@
class StorageKeys {
static const filamente = 'kauf_filamente';
static const anwendungen = 'filament_anwendungen';
static const bauteile = 'gedruckte_bauteile';
}