60 lines
1.9 KiB
Dart
60 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
|
|
import '../controller/bauteil_controller.dart';
|
|
import 'bauteil_photo.dart';
|
|
|
|
class BauteilPhotoPicker extends StatelessWidget {
|
|
const BauteilPhotoPicker({super.key, required this.controller});
|
|
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,
|
|
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'),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|