cleanup and added unit tests
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/dialog/delete_dialog.dart';
|
||||
|
||||
class CustomerRowItem extends StatelessWidget {
|
||||
final CustomerListDto dto;
|
||||
final Future<DeleteDialogResult> Function(CustomerListDto) doDelete;
|
||||
final Future<void> Function(CustomerListDto)? doSelect;
|
||||
|
||||
const CustomerRowItem({super.key, required this.dto, required this.doDelete, this.doSelect});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
leading: CircleAvatar(
|
||||
backgroundColor: Colors.grey[300],
|
||||
child: Text(
|
||||
dto.name.isNotEmpty ? dto.name[0].toUpperCase() : '?',
|
||||
style: TextStyle(
|
||||
color: Colors.grey[700],
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text(dto.name),
|
||||
subtitle: Text('CustomerNumber: ${dto.customerNumber}'),
|
||||
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
onTap: () async => await _doSelect(context),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _doSelect(BuildContext context) async {
|
||||
if (doSelect != null) {
|
||||
await doSelect!(dto);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/controller/picture_controller.dart';
|
||||
import 'package:fotodocumentation/dto/picture_dto.dart';
|
||||
import 'package:fotodocumentation/pages/customer/picture_delete_dialog.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -194,6 +195,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
|
||||
|
||||
final dateStr = _dateFormat.format(pictureDto.pictureDate);
|
||||
return InkWell(
|
||||
key: Key("table_row_${customerDto.id}"),
|
||||
onTap: () => _actionSelect(context, customerDto, pictureDto),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
@@ -231,6 +233,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
|
||||
SizedBox(
|
||||
width: 48,
|
||||
child: IconButton(
|
||||
key: Key("table_row_delete_${customerDto.id}"),
|
||||
icon: Icon(
|
||||
Icons.delete_outline,
|
||||
color: _generalStyle.errorColor,
|
||||
|
||||
@@ -28,6 +28,7 @@ class PictureDeleteDialog extends StatelessWidget {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
key: Key("picture_delete_no"),
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.deleteDialogButtonCancel,
|
||||
@@ -38,6 +39,7 @@ class PictureDeleteDialog extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
key: Key("picture_delete_yes"),
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.deleteDialogButtonApprove,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
import 'package:fotodocumentation/dto/picture_dto.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
import 'package:fotodocumentation/dto/picture_dto.dart';
|
||||
import 'package:fotodocumentation/pages/customer/picture_fullscreen_dialog.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
@@ -179,12 +180,17 @@ class _PictureWidgetState extends State<PictureWidget> {
|
||||
|
||||
Widget _imageWidget(PictureDto dto) {
|
||||
return GestureDetector(
|
||||
key: const Key("image"),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => _showFullscreenImage(dto),
|
||||
child: MouseRegion(
|
||||
cursor: SystemMouseCursors.click,
|
||||
child: Image.memory(
|
||||
base64Decode(dto.image),
|
||||
fit: BoxFit.contain,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minWidth: 100, minHeight: 100),
|
||||
child: Image.memory(
|
||||
base64Decode(dto.image),
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -234,7 +240,7 @@ class _PictureWidgetState extends State<PictureWidget> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Text(
|
||||
dto.customerListDto.name,
|
||||
widget.customerDto.name,
|
||||
style: contentStyle,
|
||||
),
|
||||
),
|
||||
@@ -248,7 +254,7 @@ class _PictureWidgetState extends State<PictureWidget> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Text(
|
||||
dto.customerListDto.customerNumber,
|
||||
widget.customerDto.customerNumber,
|
||||
style: contentStyle,
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user