price per item is printed
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
class AppVersion extends StatefulWidget {
|
||||
const AppVersion({super.key});
|
||||
|
||||
@override
|
||||
State<AppVersion> createState() => _AppVersionState();
|
||||
}
|
||||
|
||||
class _AppVersionState extends State<AppVersion> {
|
||||
late final Future<PackageInfo> _info = PackageInfo.fromPlatform();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => FutureBuilder<PackageInfo>(
|
||||
future: _info,
|
||||
builder: (context, snapshot) {
|
||||
final info = snapshot.data;
|
||||
return ListTile(
|
||||
leading: const Icon(Icons.info_outline),
|
||||
title: Text(info == null ? 'Version' : 'Version ${info.version}'),
|
||||
subtitle: Text(
|
||||
info == null
|
||||
? (snapshot.hasError ? 'Nicht verfügbar' : 'Wird geladen …')
|
||||
: 'Build ${info.buildNumber}',
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -102,6 +102,10 @@ class BauteilCard extends StatelessWidget {
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
_detail(DisplayFormats.duration(bauteil.druckdauerMinuten)),
|
||||
if (bauteil.gesamtpreis != null)
|
||||
_detail(
|
||||
'Gesamtpreis ${DisplayFormats.currency(bauteil.gesamtpreis!)}',
|
||||
),
|
||||
_detail(
|
||||
'Bauteil ${DisplayFormats.number(bauteil.gewichtGramm)} g',
|
||||
),
|
||||
|
||||
@@ -64,6 +64,13 @@ class BauteilForm extends StatelessWidget {
|
||||
unit: 'g',
|
||||
validator: InputValidators.nonNegative,
|
||||
),
|
||||
EntryNumberField(
|
||||
controller: controller.gesamtpreisController,
|
||||
label: 'Gesamtpreis (optional)',
|
||||
unit: '€',
|
||||
validator: (value) =>
|
||||
InputValidators.nonNegative(value, optional: true),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
|
||||
@@ -9,51 +9,58 @@ class BauteilPhotoPicker extends StatelessWidget {
|
||||
final BauteilController controller;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Obx(
|
||||
() => Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
BauteilPhoto(bytes: controller.foto.value),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) => Obx(() {
|
||||
final photo = BauteilPhoto(bytes: controller.foto.value);
|
||||
final controls = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const Text(
|
||||
'Bauteilfoto (optional)',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
const Text(
|
||||
'Bauteilfoto (optional)',
|
||||
style: TextStyle(fontWeight: FontWeight.w600),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: [
|
||||
OutlinedButton.icon(
|
||||
onPressed:
|
||||
controller.isPickingPhoto.value ||
|
||||
controller.isSaving.value
|
||||
? null
|
||||
: controller.pickPhoto,
|
||||
icon: const Icon(Icons.add_photo_alternate_outlined),
|
||||
label: Text(
|
||||
controller.isPickingPhoto.value
|
||||
? 'Wird geladen …'
|
||||
: 'Foto auswählen',
|
||||
),
|
||||
),
|
||||
if (controller.foto.value != null)
|
||||
TextButton(
|
||||
onPressed: controller.isSaving.value
|
||||
? null
|
||||
: controller.removePhoto,
|
||||
child: const Text('Foto entfernen'),
|
||||
),
|
||||
],
|
||||
OutlinedButton.icon(
|
||||
onPressed:
|
||||
controller.isPickingPhoto.value || controller.isSaving.value
|
||||
? null
|
||||
: controller.pickPhoto,
|
||||
icon: const Icon(Icons.add_photo_alternate_outlined),
|
||||
label: Text(
|
||||
controller.isPickingPhoto.value
|
||||
? 'Wird geladen …'
|
||||
: 'Foto auswählen',
|
||||
),
|
||||
),
|
||||
if (controller.foto.value != null)
|
||||
TextButton(
|
||||
onPressed: controller.isSaving.value
|
||||
? null
|
||||
: controller.removePhoto,
|
||||
child: const Text('Foto entfernen'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
if (constraints.maxWidth < 400) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [photo, const SizedBox(height: 12), controls],
|
||||
);
|
||||
}
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
photo,
|
||||
const SizedBox(width: 16),
|
||||
Expanded(child: controls),
|
||||
],
|
||||
);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -12,12 +12,14 @@ class FilamentCard extends StatelessWidget {
|
||||
required this.onTap,
|
||||
required this.onAction,
|
||||
this.verbrauchGramm = 0,
|
||||
this.hatProfil = false,
|
||||
});
|
||||
|
||||
final KaufFilamentModel filament;
|
||||
final VoidCallback onTap;
|
||||
final ValueChanged<String> onAction;
|
||||
final double verbrauchGramm;
|
||||
final bool hatProfil;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -155,6 +157,11 @@ class FilamentCard extends StatelessWidget {
|
||||
icon: Icons.layers_outlined,
|
||||
),
|
||||
_DetailPill(label: weight, icon: Icons.scale_outlined),
|
||||
if (hatProfil)
|
||||
const _DetailPill(
|
||||
label: 'Profil erstellt',
|
||||
icon: Icons.check_circle_outline,
|
||||
),
|
||||
],
|
||||
),
|
||||
const Padding(
|
||||
|
||||
@@ -32,6 +32,7 @@ class FilamentInventory extends StatelessWidget {
|
||||
sliver: Obx(() {
|
||||
final filamente = controller.filamente.toList();
|
||||
final verbrauch = Map<String, double>.from(controller.verbrauch);
|
||||
final filamentIdsMitProfil = controller.filamentIdsMitProfil.toSet();
|
||||
final total = filamente.fold<double>(
|
||||
0,
|
||||
(sum, item) => sum + item.preis,
|
||||
@@ -144,6 +145,9 @@ class FilamentInventory extends StatelessWidget {
|
||||
key: ValueKey(filament.filamentId),
|
||||
filament: filament,
|
||||
verbrauchGramm: verbrauch[filament.filamentId] ?? 0,
|
||||
hatProfil: filamentIdsMitProfil.contains(
|
||||
filament.filamentId,
|
||||
),
|
||||
onTap: () => onOpen(filament),
|
||||
onAction: (action) => onAction(action, filament),
|
||||
);
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Keeps the navigator (including dialogs) usable in very narrow browser tabs.
|
||||
/// The native Windows/Linux runners use the same minimum client width.
|
||||
class ResponsiveViewport extends StatelessWidget {
|
||||
const ResponsiveViewport({super.key, required this.child});
|
||||
|
||||
static const minimumWidth = 320.0;
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
if (constraints.maxWidth >= minimumWidth) return child;
|
||||
final media = MediaQuery.of(context);
|
||||
return SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
primary: false,
|
||||
child: SizedBox(
|
||||
width: minimumWidth,
|
||||
height: constraints.maxHeight,
|
||||
child: MediaQuery(
|
||||
data: media.copyWith(size: Size(minimumWidth, media.size.height)),
|
||||
child: child,
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user