rework ui

This commit is contained in:
verboomp
2026-01-29 07:08:44 +01:00
parent ca514eea67
commit 38979c99e5
19 changed files with 457 additions and 293 deletions

View File

@@ -0,0 +1,42 @@
import 'package:flutter/material.dart';
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:go_router/go_router.dart';
import 'package:fotodocumentation/l10n/app_localizations.dart';
class CustomerBackButton extends StatelessWidget {
GeneralStyle get _generalStyle => DiContainer.get();
final String path;
const CustomerBackButton({super.key, required this.path});
@override
Widget build(BuildContext context) {
return ElevatedButton.icon(
onPressed: () => context.go(path),
icon: Icon(
Icons.chevron_left,
color: _generalStyle.secondaryTextLabelColor,
size: 24,
),
label: Text(
AppLocalizations.of(context)!.backButtonLabel,
style: TextStyle(
fontFamily: _generalStyle.fontFamily,
fontWeight: FontWeight.normal,
fontSize: 16,
color: _generalStyle.secondaryTextLabelColor,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
),
);
}
}

View File

@@ -59,14 +59,11 @@ class _CustomerListWidgetState extends State<CustomerListWidget> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PageHeaderWidget(text: AppLocalizations.of(context)!.customerListHeadline),
_abcHeaderBar(),
FractionallySizedBox(
widthFactor: 0.5,
alignment: Alignment.centerLeft,
child: SearchBarWidget(
searchController: _searchController,
onSearch: (text) async => actionSearch(text),
),
//_abcHeaderBar(),
const SizedBox(width: 48),
SearchBarWidget(
searchController: _searchController,
onSearch: (text) async => actionSearch(text),
),
Expanded(
child: _customerListWidget(),
@@ -227,14 +224,14 @@ class _CustomerListWidgetState extends State<CustomerListWidget> {
}
Future<void> _actionSelect(BuildContext context, CustomerListDto dto) async {
context.go("${GlobalRouter.pathCustomer}/${dto.id}");
context.push("${GlobalRouter.pathCustomer}/${dto.id}");
}
void _reloadData() {
_dtos = _customerController.getAll(_searchController.text, _selectedLetter ?? "");
setState(() {});
}
/*
Widget _abcHeaderBar() {
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
return Padding(
@@ -271,5 +268,5 @@ class _CustomerListWidgetState extends State<CustomerListWidget> {
}).toList(),
),
);
}
}*/
}

View File

@@ -3,6 +3,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/back_button.dart';
import 'package:fotodocumentation/pages/customer/picture_delete_dialog.dart';
import 'package:go_router/go_router.dart';
@@ -91,20 +92,24 @@ class _CustomerWidgetState extends State<CustomerWidget> {
}
var subText = AppLocalizations.of(context)!.customerWidgetCustomerNumberPrefix(dto.customerNumber);
return Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PageHeaderWidget(text: dto.name, subText: subText),
_backButton(context),
const SizedBox(height: 24),
Expanded(
child: _customerWidget(dto),
),
],
),
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
PageHeaderWidget(text: dto.name, subText: subText),
CustomerBackButton(path: GlobalRouter.pathHome),
//_backButton(context),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
_downloadButton(context),
],
),
const SizedBox(height: 24),
Expanded(
child: _customerWidget(dto),
),
],
);
}
@@ -170,6 +175,16 @@ class _CustomerWidgetState extends State<CustomerWidget> {
),
),
),
Expanded(
flex: 1,
child: Align(
alignment: Alignment.centerLeft,
child: Text(
'Bewertung',
style: headerStyle,
),
),
),
Expanded(
flex: 2,
child: Align(
@@ -180,7 +195,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
),
),
),
const SizedBox(width: 48),
const SizedBox(width: 96),
],
),
);
@@ -194,6 +209,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
);
final dateStr = _dateFormat.format(pictureDto.pictureDate);
final evaluationColor = _generalStyle.evaluationColor(); // FIXME: set to color from DB
return InkWell(
key: Key("table_row_${customerDto.id}"),
onTap: () => _actionSelect(context, customerDto, pictureDto),
@@ -201,7 +217,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Expanded(
flex: 1,
@@ -223,6 +239,20 @@ class _CustomerWidgetState extends State<CustomerWidget> {
child: Text(pictureDto.comment ?? "", style: dataStyle),
),
),
Expanded(
flex: 1,
child: Align(
alignment: Alignment.centerLeft,
child: Container(
width: 20,
height: 20,
decoration: BoxDecoration(
color: evaluationColor,
shape: BoxShape.circle,
),
),
),
),
Expanded(
flex: 2,
child: Align(
@@ -230,6 +260,17 @@ class _CustomerWidgetState extends State<CustomerWidget> {
child: Text(dateStr, style: dataStyle),
),
),
SizedBox(
width: 48,
child: IconButton(
key: Key("table_row_download_${pictureDto.id}"),
icon: Icon(
Icons.file_download_outlined,
color: _generalStyle.loginFormTextLabelColor,
),
onPressed: () => _actionDelete(context, customerDto, pictureDto),
),
),
SizedBox(
width: 48,
child: IconButton(
@@ -247,45 +288,9 @@ class _CustomerWidgetState extends State<CustomerWidget> {
);
}
Future<void> _actionDelete(BuildContext context, CustomerDto customerDto, PictureDto pictureDto) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
return PictureDeleteDialog();
},
);
if (confirmed == true) {
_pictureController.delete(pictureDto);
setState(() {
_dto = _customerController.get(id: widget.customerId);
});
}
}
Future<void> _actionSelect(BuildContext context, CustomerDto customerDto, PictureDto pictureDto) async {
showDialog(
context: context,
builder: (BuildContext context) {
return Dialog(
backgroundColor: _generalStyle.pageBackgroundColor,
insetPadding: const EdgeInsets.all(24),
child: ClipRRect(
borderRadius: BorderRadius.circular(12),
child: SizedBox(
width: MediaQuery.of(context).size.width * 0.9,
height: MediaQuery.of(context).size.height * 0.9,
child: PictureWidget(customerDto: customerDto, pictureDto: pictureDto),
),
),
);
},
);
}
Widget _backButton(BuildContext context) {
return ElevatedButton.icon(
onPressed: () => context.go(GlobalRouter.pathHome),
onPressed: () => context.push(GlobalRouter.pathHome),
icon: Icon(
Icons.chevron_left,
color: _generalStyle.secondaryTextLabelColor,
@@ -309,4 +314,56 @@ class _CustomerWidgetState extends State<CustomerWidget> {
),
);
}
Widget _downloadButton(BuildContext context) {
return ElevatedButton.icon(
key: Key("download_all_button"),
onPressed: () => _actionDownload(context),
iconAlignment: IconAlignment.end,
icon: Icon(
Icons.file_download_outlined,
color: _generalStyle.primaryButtonTextColor,
size: 24,
),
label: Text(
"Alle herunterladen",
style: TextStyle(
fontFamily: _generalStyle.fontFamily,
fontWeight: FontWeight.bold,
fontSize: 16,
color: _generalStyle.primaryButtonTextColor,
),
),
style: ElevatedButton.styleFrom(
backgroundColor: _generalStyle.secondaryWidgetBackgroundColor,
elevation: 0,
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
shape: const StadiumBorder(),
),
);
}
Future<void> _actionDelete(BuildContext context, CustomerDto customerDto, PictureDto pictureDto) async {
final confirmed = await showDialog<bool>(
context: context,
builder: (BuildContext context) {
return PictureDeleteDialog();
},
);
if (confirmed == true) {
_pictureController.delete(pictureDto);
setState(() {
_dto = _customerController.get(id: widget.customerId);
});
}
}
Future<void> _actionSelect(BuildContext context, CustomerDto customerDto, PictureDto pictureDto) async {
context.go(GlobalRouter.pathPicture, extra: PictureWidgetHolder(customerDto, pictureDto));
}
Future<void> _actionDownload(BuildContext context) async {
// FIXME: implement a download from the export
}
}

View File

@@ -3,11 +3,21 @@ 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/customer_back_button.dart';
import 'package:fotodocumentation/pages/customer/picture_fullscreen_dialog.dart';
import 'package:fotodocumentation/pages/ui_utils/component/page_header_widget.dart';
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
import 'package:fotodocumentation/utils/di_container.dart';
import 'package:fotodocumentation/utils/global_router.dart';
import 'package:intl/intl.dart';
class PictureWidgetHolder {
final CustomerDto customerDto;
final PictureDto pictureDto;
const PictureWidgetHolder(this.customerDto, this.pictureDto);
}
class PictureWidget extends StatefulWidget {
final CustomerDto customerDto;
final PictureDto pictureDto;
@@ -27,7 +37,7 @@ class _PictureWidgetState extends State<PictureWidget> {
@override
void initState() {
super.initState();
_dateFormat = DateFormat('dd MMMM yyyy');
_dateFormat = DateFormat('dd.MM.yyyy, hh:mm');
_selectedPicture = widget.pictureDto;
}
@@ -39,117 +49,35 @@ class _PictureWidgetState extends State<PictureWidget> {
@override
Widget build(BuildContext context) {
final pictures = widget.customerDto.pictures;
final currentIndex = pictures.indexWhere((p) => p.id == _selectedPicture.id);
final hasPrevious = currentIndex > 0;
final hasNext = currentIndex < pictures.length - 1;
return Scaffold(
body: Container(
color: _generalStyle.pageBackgroundColor,
child: Padding(
padding: const EdgeInsets.only(top: 8.0, left: 50.0, right: 50.0, bottom: 8.0),
child: _body(context),
),
),
);
}
return Stack(
Widget _body(BuildContext context) {
final pictures = widget.customerDto.pictures;
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: double.infinity,
height: double.infinity,
color: _generalStyle.pageBackgroundColor,
child: Padding(
padding: const EdgeInsets.only(top: 50.0, left: 50.0, right: 50.0, bottom: 8.0),
child: _body(context),
),
),
// Left navigation button
if (hasPrevious)
Positioned(
left: 0,
top: 0,
bottom: 0,
child: GestureDetector(
onTap: () => _navigateToPicture(currentIndex - 1),
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Container(
width: 50,
color: Colors.transparent,
child: Center(
child: Container(
decoration: BoxDecoration(
color: _generalStyle.primaryButtonBackgroundColor,
shape: BoxShape.circle,
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.chevron_left,
color: _generalStyle.primaryButtonTextColor,
size: 32,
),
),
),
),
),
),
),
),
// Right navigation button
if (hasNext)
Positioned(
right: 0,
top: 0,
bottom: 0,
child: GestureDetector(
onTap: () => _navigateToPicture(currentIndex + 1),
child: MouseRegion(
cursor: SystemMouseCursors.click,
child: Container(
width: 50,
color: Colors.transparent,
child: Center(
child: Container(
decoration: BoxDecoration(
color: _generalStyle.primaryButtonBackgroundColor,
shape: BoxShape.circle,
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Icon(
Icons.chevron_right,
color: _generalStyle.primaryButtonTextColor,
size: 32,
),
),
),
),
),
),
),
),
// Close button
Positioned(
top: 16,
right: 16,
child: Container(
decoration: BoxDecoration(
color: _generalStyle.primaryButtonBackgroundColor,
shape: BoxShape.circle,
),
child: IconButton(
icon: Icon(Icons.close, color: _generalStyle.primaryButtonTextColor, size: 24),
onPressed: () => Navigator.of(context).pop(),
),
),
PageHeaderWidget(text: widget.customerDto.name),
CustomerBackButton(path: GlobalRouter.pathCustomer),
const SizedBox(height: 24),
Expanded(
child: _mainWidget(context),
),
_bottomNavigationWidget(pictures),
],
);
}
void _navigateToPicture(int index) {
final pictures = widget.customerDto.pictures;
if (index >= 0 && index < pictures.length) {
setState(() {
_selectedPicture = pictures[index];
});
}
}
Widget _body(BuildContext context) {
Widget _mainWidget(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
final isNarrow = constraints.maxWidth < 800;
@@ -222,7 +150,7 @@ class _PictureWidgetState extends State<PictureWidget> {
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(
"INFORMATIONEN",
_dateFormat.format(dto.pictureDate),
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 44,
@@ -230,20 +158,7 @@ class _PictureWidgetState extends State<PictureWidget> {
color: _generalStyle.primaryTextLabelColor,
),
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
"APOTHEKE",
style: labelStyle,
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
widget.customerDto.name,
style: contentStyle,
),
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
@@ -258,20 +173,6 @@ class _PictureWidgetState extends State<PictureWidget> {
style: contentStyle,
),
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
"DATUM",
style: labelStyle,
),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Text(
_dateFormat.format(dto.pictureDate),
style: contentStyle,
),
),
Padding(
padding: const EdgeInsets.only(top: 20.0),
child: Text(
@@ -281,13 +182,9 @@ class _PictureWidgetState extends State<PictureWidget> {
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Container(
child: SizedBox(
width: double.infinity,
height: 150,
decoration: BoxDecoration(
border: Border.all(color: _generalStyle.secondaryTextLabelColor.withValues(alpha: 0.3)),
borderRadius: BorderRadius.circular(8),
),
child: Scrollbar(
controller: _commentScrollController,
thumbVisibility: true,
@@ -304,4 +201,73 @@ class _PictureWidgetState extends State<PictureWidget> {
),
]);
}
// Bottom navigation buttons
Widget _bottomNavigationWidget(List<PictureDto> pictures) {
final currentIndex = pictures.indexWhere((p) => p.id == _selectedPicture.id);
final hasPrevious = currentIndex > 0;
final hasNext = currentIndex < pictures.length - 1;
return Padding(
padding: const EdgeInsets.only(bottom: 24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
// Previous button
IconButton(
onPressed: hasPrevious ? () => _actionNavigateToPicture(currentIndex - 1) : null,
icon: Icon(Icons.chevron_left, color: _generalStyle.nextTextColor, size: 32),
),
const SizedBox(width: 24),
// Picture counter text
Row(
mainAxisSize: MainAxisSize.min,
children: [
Container(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 6),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8),
),
child: Text(
'${currentIndex + 1}',
style: TextStyle(
fontFamily: _generalStyle.fontFamily,
fontSize: 16,
fontWeight: FontWeight.bold,
color: _generalStyle.nextTextColor,
),
),
),
const SizedBox(width: 8),
Text(
'von ${pictures.length}',
style: TextStyle(
fontFamily: _generalStyle.fontFamily,
fontSize: 16,
fontWeight: FontWeight.normal,
color: _generalStyle.nextTextColor,
),
),
],
),
const SizedBox(width: 24),
// Next button
IconButton(
onPressed: hasNext ? () => _actionNavigateToPicture(currentIndex + 1) : null,
icon: Icon(Icons.chevron_right, color: _generalStyle.nextTextColor, size: 32),
),
],
),
);
}
void _actionNavigateToPicture(int index) {
final pictures = widget.customerDto.pictures;
if (index >= 0 && index < pictures.length) {
setState(() {
_selectedPicture = pictures[index];
});
}
}
}