rework ui
This commit is contained in:
@@ -40,7 +40,10 @@ public class Picture extends AbstractDateEntity {
|
|||||||
@Basic(fetch = FetchType.LAZY)
|
@Basic(fetch = FetchType.LAZY)
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
@Column(name = "evaluation")
|
||||||
|
private Integer evaluation;
|
||||||
|
|
||||||
|
@Column
|
||||||
private String category;
|
private String category;
|
||||||
|
|
||||||
@Column(name = "image")
|
@Column(name = "image")
|
||||||
@@ -83,7 +86,13 @@ public class Picture extends AbstractDateEntity {
|
|||||||
this.comment = comment;
|
this.comment = comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getEvaluation() {
|
||||||
|
return evaluation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEvaluation(Integer evaluation) {
|
||||||
|
this.evaluation = evaluation;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return category;
|
return category;
|
||||||
@@ -125,6 +134,10 @@ public class Picture extends AbstractDateEntity {
|
|||||||
public static class Builder {
|
public static class Builder {
|
||||||
private Picture instance = new Picture();
|
private Picture instance = new Picture();
|
||||||
|
|
||||||
|
public Builder(){
|
||||||
|
instance.evaluation = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public Builder username(String username) {
|
public Builder username(String username) {
|
||||||
instance.setUsername(username);
|
instance.setUsername(username);
|
||||||
return this;
|
return this;
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ import marketing.heyday.hartmann.fotodocumentation.core.model.Picture;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@Schema(name = "Picture")
|
@Schema(name = "Picture")
|
||||||
public record PictureValue(Long id, String comment, String category, String image, Date pictureDate, String username) {
|
public record PictureValue(Long id, String comment, String category, String image, Date pictureDate, String username, Integer evaluation) {
|
||||||
|
|
||||||
public static PictureValue builder(Picture picture) {
|
public static PictureValue builder(Picture picture) {
|
||||||
if (picture == null) {
|
if (picture == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new PictureValue(picture.getPictureId(), picture.getComment(), picture.getCategory(), picture.getImage(), picture.getPictureDate(), picture.getUsername());
|
return new PictureValue(picture.getPictureId(), picture.getComment(), picture.getCategory(), picture.getImage(), picture.getPictureDate(), picture.getUsername(), picture.getEvaluation());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
-- picture
|
||||||
|
|
||||||
|
alter table picture add column evaluation bigint;
|
||||||
|
|
||||||
|
update picture set evaluation = 0;
|
||||||
|
|
||||||
|
alter table picture alter column evaluation set not null;
|
||||||
@@ -5,11 +5,12 @@ class PictureDto {
|
|||||||
final String? comment;
|
final String? comment;
|
||||||
final String? category;
|
final String? category;
|
||||||
final String image;
|
final String image;
|
||||||
|
final int evaluation;
|
||||||
final DateTime pictureDate;
|
final DateTime pictureDate;
|
||||||
final String? username;
|
final String? username;
|
||||||
|
|
||||||
PictureDto(
|
PictureDto(
|
||||||
{required this.id, required this.comment, required this.category, required this.image, required this.pictureDate, required this.username});
|
{required this.id, required this.comment, required this.category, required this.image, required this.evaluation, required this.pictureDate, required this.username});
|
||||||
|
|
||||||
/// Create from JSON response
|
/// Create from JSON response
|
||||||
factory PictureDto.fromJson(Map<String, dynamic> json) {
|
factory PictureDto.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -18,6 +19,7 @@ class PictureDto {
|
|||||||
comment: json['comment'] as String?,
|
comment: json['comment'] as String?,
|
||||||
category: json['category'] as String?,
|
category: json['category'] as String?,
|
||||||
image: json['image'] as String,
|
image: json['image'] as String,
|
||||||
|
evaluation: json["evaluation"] as int,
|
||||||
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
|
pictureDate: DateTimeUtils.toDateTime(json['pictureDate']) ?? DateTime.now(),
|
||||||
username: json['username'] as String?
|
username: json['username'] as String?
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
"@loginLoginButtonLabel": {
|
"@loginLoginButtonLabel": {
|
||||||
"description": "Login Button Label"
|
"description": "Login Button Label"
|
||||||
},
|
},
|
||||||
"loginTitle": "BILDERUPLOAD",
|
"loginTitle": "FOTO-DOKU",
|
||||||
"@loginTitle": {
|
"@loginTitle": {
|
||||||
"description": "Login page title"
|
"description": "Login page title"
|
||||||
},
|
},
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
"@customerListHeaderLastDateSuffix": {
|
"@customerListHeaderLastDateSuffix": {
|
||||||
"description": "Customer list table header for ladt date"
|
"description": "Customer list table header for ladt date"
|
||||||
},
|
},
|
||||||
"customerListHeadline": "BILDERUPLOAD",
|
"customerListHeadline": "FOTO-DOKU",
|
||||||
"@customerListHeadline": {
|
"@customerListHeadline": {
|
||||||
"description": "Customer list page headline"
|
"description": "Customer list page headline"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ abstract class AppLocalizations {
|
|||||||
/// Login page title
|
/// Login page title
|
||||||
///
|
///
|
||||||
/// In de, this message translates to:
|
/// In de, this message translates to:
|
||||||
/// **'BILDERUPLOAD'**
|
/// **'FOTO-DOKU'**
|
||||||
String get loginTitle;
|
String get loginTitle;
|
||||||
|
|
||||||
/// Login error message for invalid credentials
|
/// Login error message for invalid credentials
|
||||||
@@ -211,7 +211,7 @@ abstract class AppLocalizations {
|
|||||||
/// Customer list page headline
|
/// Customer list page headline
|
||||||
///
|
///
|
||||||
/// In de, this message translates to:
|
/// In de, this message translates to:
|
||||||
/// **'BILDERUPLOAD'**
|
/// **'FOTO-DOKU'**
|
||||||
String get customerListHeadline;
|
String get customerListHeadline;
|
||||||
|
|
||||||
/// Empty customer list message
|
/// Empty customer list message
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
String get loginLoginButtonLabel => 'Einloggen';
|
String get loginLoginButtonLabel => 'Einloggen';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get loginTitle => 'BILDERUPLOAD';
|
String get loginTitle => 'FOTO-DOKU';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get loginErrorMessage => 'Falscher Benutzername oder Passwort';
|
String get loginErrorMessage => 'Falscher Benutzername oder Passwort';
|
||||||
@@ -71,7 +71,7 @@ class AppLocalizationsDe extends AppLocalizations {
|
|||||||
String get customerListHeaderLastDateSuffix => ' (zuletzt aktualisiert)';
|
String get customerListHeaderLastDateSuffix => ' (zuletzt aktualisiert)';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get customerListHeadline => 'BILDERUPLOAD';
|
String get customerListHeadline => 'FOTO-DOKU';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get customerListEmpty => 'Keine Ergebnisse gefunden';
|
String get customerListEmpty => 'Keine Ergebnisse gefunden';
|
||||||
|
|||||||
@@ -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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,15 +59,12 @@ class _CustomerListWidgetState extends State<CustomerListWidget> {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
PageHeaderWidget(text: AppLocalizations.of(context)!.customerListHeadline),
|
PageHeaderWidget(text: AppLocalizations.of(context)!.customerListHeadline),
|
||||||
_abcHeaderBar(),
|
//_abcHeaderBar(),
|
||||||
FractionallySizedBox(
|
const SizedBox(width: 48),
|
||||||
widthFactor: 0.5,
|
SearchBarWidget(
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: SearchBarWidget(
|
|
||||||
searchController: _searchController,
|
searchController: _searchController,
|
||||||
onSearch: (text) async => actionSearch(text),
|
onSearch: (text) async => actionSearch(text),
|
||||||
),
|
),
|
||||||
),
|
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _customerListWidget(),
|
child: _customerListWidget(),
|
||||||
),
|
),
|
||||||
@@ -227,14 +224,14 @@ class _CustomerListWidgetState extends State<CustomerListWidget> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _actionSelect(BuildContext context, CustomerListDto dto) async {
|
Future<void> _actionSelect(BuildContext context, CustomerListDto dto) async {
|
||||||
context.go("${GlobalRouter.pathCustomer}/${dto.id}");
|
context.push("${GlobalRouter.pathCustomer}/${dto.id}");
|
||||||
}
|
}
|
||||||
|
|
||||||
void _reloadData() {
|
void _reloadData() {
|
||||||
_dtos = _customerController.getAll(_searchController.text, _selectedLetter ?? "");
|
_dtos = _customerController.getAll(_searchController.text, _selectedLetter ?? "");
|
||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
Widget _abcHeaderBar() {
|
Widget _abcHeaderBar() {
|
||||||
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
return Padding(
|
return Padding(
|
||||||
@@ -271,5 +268,5 @@ class _CustomerListWidgetState extends State<CustomerListWidget> {
|
|||||||
}).toList(),
|
}).toList(),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'dart:convert' show base64Decode;
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fotodocumentation/controller/picture_controller.dart';
|
import 'package:fotodocumentation/controller/picture_controller.dart';
|
||||||
import 'package:fotodocumentation/dto/picture_dto.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:fotodocumentation/pages/customer/picture_delete_dialog.dart';
|
||||||
|
|
||||||
import 'package:go_router/go_router.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);
|
var subText = AppLocalizations.of(context)!.customerWidgetCustomerNumberPrefix(dto.customerNumber);
|
||||||
return Padding(
|
return Column(
|
||||||
padding: const EdgeInsets.all(8.0),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
PageHeaderWidget(text: dto.name, subText: subText),
|
PageHeaderWidget(text: dto.name, subText: subText),
|
||||||
_backButton(context),
|
CustomerBackButton(path: GlobalRouter.pathHome),
|
||||||
|
//_backButton(context),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
_downloadButton(context),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 24),
|
const SizedBox(height: 24),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _customerWidget(dto),
|
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(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Align(
|
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 dateStr = _dateFormat.format(pictureDto.pictureDate);
|
||||||
|
final evaluationColor = _generalStyle.evaluationColor(); // FIXME: set to color from DB
|
||||||
return InkWell(
|
return InkWell(
|
||||||
key: Key("table_row_${customerDto.id}"),
|
key: Key("table_row_${customerDto.id}"),
|
||||||
onTap: () => _actionSelect(context, customerDto, pictureDto),
|
onTap: () => _actionSelect(context, customerDto, pictureDto),
|
||||||
@@ -201,7 +217,7 @@ class _CustomerWidgetState extends State<CustomerWidget> {
|
|||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||||
child: Row(
|
child: Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
@@ -223,6 +239,20 @@ class _CustomerWidgetState extends State<CustomerWidget> {
|
|||||||
child: Text(pictureDto.comment ?? "", style: dataStyle),
|
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(
|
Expanded(
|
||||||
flex: 2,
|
flex: 2,
|
||||||
child: Align(
|
child: Align(
|
||||||
@@ -230,6 +260,17 @@ class _CustomerWidgetState extends State<CustomerWidget> {
|
|||||||
child: Text(dateStr, style: dataStyle),
|
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(
|
SizedBox(
|
||||||
width: 48,
|
width: 48,
|
||||||
child: IconButton(
|
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) {
|
Widget _backButton(BuildContext context) {
|
||||||
return ElevatedButton.icon(
|
return ElevatedButton.icon(
|
||||||
onPressed: () => context.go(GlobalRouter.pathHome),
|
onPressed: () => context.push(GlobalRouter.pathHome),
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.chevron_left,
|
Icons.chevron_left,
|
||||||
color: _generalStyle.secondaryTextLabelColor,
|
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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,21 @@ import 'dart:convert' show base64Decode;
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||||
import 'package:fotodocumentation/dto/picture_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/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/pages/ui_utils/general_style.dart';
|
||||||
import 'package:fotodocumentation/utils/di_container.dart';
|
import 'package:fotodocumentation/utils/di_container.dart';
|
||||||
|
import 'package:fotodocumentation/utils/global_router.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
|
class PictureWidgetHolder {
|
||||||
|
final CustomerDto customerDto;
|
||||||
|
final PictureDto pictureDto;
|
||||||
|
|
||||||
|
const PictureWidgetHolder(this.customerDto, this.pictureDto);
|
||||||
|
}
|
||||||
|
|
||||||
class PictureWidget extends StatefulWidget {
|
class PictureWidget extends StatefulWidget {
|
||||||
final CustomerDto customerDto;
|
final CustomerDto customerDto;
|
||||||
final PictureDto pictureDto;
|
final PictureDto pictureDto;
|
||||||
@@ -27,7 +37,7 @@ class _PictureWidgetState extends State<PictureWidget> {
|
|||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_dateFormat = DateFormat('dd MMMM yyyy');
|
_dateFormat = DateFormat('dd.MM.yyyy, hh:mm');
|
||||||
_selectedPicture = widget.pictureDto;
|
_selectedPicture = widget.pictureDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,117 +49,35 @@ class _PictureWidgetState extends State<PictureWidget> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final pictures = widget.customerDto.pictures;
|
return Scaffold(
|
||||||
final currentIndex = pictures.indexWhere((p) => p.id == _selectedPicture.id);
|
body: Container(
|
||||||
final hasPrevious = currentIndex > 0;
|
|
||||||
final hasNext = currentIndex < pictures.length - 1;
|
|
||||||
|
|
||||||
return Stack(
|
|
||||||
children: [
|
|
||||||
Container(
|
|
||||||
width: double.infinity,
|
|
||||||
height: double.infinity,
|
|
||||||
color: _generalStyle.pageBackgroundColor,
|
color: _generalStyle.pageBackgroundColor,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(top: 50.0, left: 50.0, right: 50.0, bottom: 8.0),
|
padding: const EdgeInsets.only(top: 8.0, left: 50.0, right: 50.0, bottom: 8.0),
|
||||||
child: _body(context),
|
child: _body(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// Left navigation button
|
);
|
||||||
if (hasPrevious)
|
}
|
||||||
Positioned(
|
|
||||||
left: 0,
|
Widget _body(BuildContext context) {
|
||||||
top: 0,
|
final pictures = widget.customerDto.pictures;
|
||||||
bottom: 0,
|
return Column(
|
||||||
child: GestureDetector(
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
onTap: () => _navigateToPicture(currentIndex - 1),
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
child: MouseRegion(
|
children: [
|
||||||
cursor: SystemMouseCursors.click,
|
PageHeaderWidget(text: widget.customerDto.name),
|
||||||
child: Container(
|
CustomerBackButton(path: GlobalRouter.pathCustomer),
|
||||||
width: 50,
|
const SizedBox(height: 24),
|
||||||
color: Colors.transparent,
|
Expanded(
|
||||||
child: Center(
|
child: _mainWidget(context),
|
||||||
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(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
_bottomNavigationWidget(pictures),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _navigateToPicture(int index) {
|
Widget _mainWidget(BuildContext context) {
|
||||||
final pictures = widget.customerDto.pictures;
|
|
||||||
if (index >= 0 && index < pictures.length) {
|
|
||||||
setState(() {
|
|
||||||
_selectedPicture = pictures[index];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget _body(BuildContext context) {
|
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (context, constraints) {
|
builder: (context, constraints) {
|
||||||
final isNarrow = constraints.maxWidth < 800;
|
final isNarrow = constraints.maxWidth < 800;
|
||||||
@@ -222,7 +150,7 @@ class _PictureWidgetState extends State<PictureWidget> {
|
|||||||
|
|
||||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||||
Text(
|
Text(
|
||||||
"INFORMATIONEN",
|
_dateFormat.format(dto.pictureDate),
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: 44,
|
fontSize: 44,
|
||||||
@@ -230,20 +158,7 @@ class _PictureWidgetState extends State<PictureWidget> {
|
|||||||
color: _generalStyle.primaryTextLabelColor,
|
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(
|
||||||
padding: const EdgeInsets.only(top: 20.0),
|
padding: const EdgeInsets.only(top: 20.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -258,20 +173,6 @@ class _PictureWidgetState extends State<PictureWidget> {
|
|||||||
style: contentStyle,
|
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(
|
||||||
padding: const EdgeInsets.only(top: 20.0),
|
padding: const EdgeInsets.only(top: 20.0),
|
||||||
child: Text(
|
child: Text(
|
||||||
@@ -281,13 +182,9 @@ class _PictureWidgetState extends State<PictureWidget> {
|
|||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.only(top: 4.0),
|
padding: const EdgeInsets.only(top: 4.0),
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 150,
|
height: 150,
|
||||||
decoration: BoxDecoration(
|
|
||||||
border: Border.all(color: _generalStyle.secondaryTextLabelColor.withValues(alpha: 0.3)),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
),
|
|
||||||
child: Scrollbar(
|
child: Scrollbar(
|
||||||
controller: _commentScrollController,
|
controller: _commentScrollController,
|
||||||
thumbVisibility: true,
|
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];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,60 +101,20 @@ class _LoginWidgetState extends State<LoginWidget> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
if (_error != null) ...[
|
if (_error != null) ...[
|
||||||
Center(
|
_errorWidget(),
|
||||||
child: Text(
|
|
||||||
_error!,
|
|
||||||
style: TextStyle(
|
|
||||||
color: _generalStyle.errorColor,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
fontSize: 16,
|
|
||||||
fontFamily: _generalStyle.fontFamily,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 40),
|
const SizedBox(height: 40),
|
||||||
],
|
],
|
||||||
TextFormField(
|
TextFormField(
|
||||||
key: Key("username"),
|
key: Key("username"),
|
||||||
controller: _usernameController,
|
controller: _usernameController,
|
||||||
decoration: InputDecoration(
|
decoration: _formFieldInputDecoration(AppLocalizations.of(context)!.loginUsernameTFLabel),
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: _error != null ? BorderSide(color: _generalStyle.errorColor) : BorderSide(),
|
|
||||||
),
|
|
||||||
enabledBorder: _error != null
|
|
||||||
? OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: BorderSide(color: _generalStyle.errorColor),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
labelText: AppLocalizations.of(context)!.loginUsernameTFLabel.toUpperCase(),
|
|
||||||
labelStyle: TextStyle(color: _generalStyle.primaryTextLabelColor, fontFamily: _generalStyle.fontFamily),
|
|
||||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
TextFormField(
|
TextFormField(
|
||||||
key: Key("password"),
|
key: Key("password"),
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
obscureText: true,
|
obscureText: true,
|
||||||
decoration: InputDecoration(
|
decoration: _formFieldInputDecoration(AppLocalizations.of(context)!.loginPasswordTFLabel),
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: _error != null ? BorderSide(color: _generalStyle.errorColor) : BorderSide(),
|
|
||||||
),
|
|
||||||
enabledBorder: _error != null
|
|
||||||
? OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
borderSide: BorderSide(color: _generalStyle.errorColor),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
labelText: AppLocalizations.of(context)!.loginPasswordTFLabel.toUpperCase(),
|
|
||||||
labelStyle: TextStyle(color: _generalStyle.primaryTextLabelColor, fontFamily: _generalStyle.fontFamily),
|
|
||||||
floatingLabelBehavior: FloatingLabelBehavior.always,
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
Center(
|
Center(
|
||||||
@@ -186,6 +146,46 @@ class _LoginWidgetState extends State<LoginWidget> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _errorWidget() {
|
||||||
|
return Center(
|
||||||
|
child: Text(
|
||||||
|
_error!,
|
||||||
|
style: TextStyle(
|
||||||
|
color: _generalStyle.errorColor,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
fontSize: 16,
|
||||||
|
fontFamily: _generalStyle.fontFamily,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
InputDecoration _formFieldInputDecoration(String text) {
|
||||||
|
var formLabelTextStyle = TextStyle(
|
||||||
|
color: _generalStyle.loginFormTextLabelColor,
|
||||||
|
fontFamily: _generalStyle.fontFamily,
|
||||||
|
fontSize: 14,
|
||||||
|
fontStyle: FontStyle.normal,
|
||||||
|
fontWeight: FontWeight.normal,
|
||||||
|
);
|
||||||
|
return InputDecoration(
|
||||||
|
border: OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
borderSide: _error != null ? BorderSide(color: _generalStyle.errorColor) : BorderSide(),
|
||||||
|
),
|
||||||
|
enabledBorder: _error != null
|
||||||
|
? OutlineInputBorder(
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
borderSide: BorderSide(color: _generalStyle.errorColor),
|
||||||
|
)
|
||||||
|
: null,
|
||||||
|
labelText: text.toUpperCase(),
|
||||||
|
labelStyle: formLabelTextStyle,
|
||||||
|
floatingLabelBehavior: FloatingLabelBehavior.always,
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _actionSubmit(BuildContext context) async {
|
Future<void> _actionSubmit(BuildContext context) async {
|
||||||
String username = _usernameController.text;
|
String username = _usernameController.text;
|
||||||
String password = _passwordController.text;
|
String password = _passwordController.text;
|
||||||
|
|||||||
@@ -1,8 +1,14 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fotodocumentation/utils/login_credentials.dart';
|
||||||
|
import 'package:go_router/go_router.dart';
|
||||||
|
|
||||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||||
import 'package:fotodocumentation/utils/di_container.dart';
|
import 'package:fotodocumentation/utils/di_container.dart';
|
||||||
|
import 'package:fotodocumentation/utils/global_router.dart';
|
||||||
|
|
||||||
class PageHeaderWidget extends StatelessWidget {
|
class PageHeaderWidget extends StatelessWidget {
|
||||||
|
LoginCredentials get loginCredentials => DiContainer.get();
|
||||||
|
|
||||||
final String text;
|
final String text;
|
||||||
final String subText;
|
final String subText;
|
||||||
|
|
||||||
@@ -30,6 +36,7 @@ class PageHeaderWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
|
_logoutButton(context),
|
||||||
Image.asset(
|
Image.asset(
|
||||||
'assets/images/logo.png',
|
'assets/images/logo.png',
|
||||||
height: 48,
|
height: 48,
|
||||||
@@ -52,4 +59,34 @@ class PageHeaderWidget extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _logoutButton(BuildContext context) {
|
||||||
|
return ElevatedButton.icon(
|
||||||
|
onPressed: () {
|
||||||
|
loginCredentials.logout();
|
||||||
|
context.go(GlobalRouter.pathLogin);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.logout_rounded,
|
||||||
|
color: _generalStyle.secondaryTextLabelColor,
|
||||||
|
size: 24,
|
||||||
|
),
|
||||||
|
label: Text(
|
||||||
|
"logout",
|
||||||
|
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),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
abstract interface class GeneralStyle {
|
abstract interface class GeneralStyle {
|
||||||
|
Color? evaluationColor({int value = 0});
|
||||||
|
|
||||||
|
Color get evaluationGoodColor;
|
||||||
|
Color get evaluationMiddleColor;
|
||||||
|
Color get evaluationBadColor;
|
||||||
|
|
||||||
|
Color get nextTextColor;
|
||||||
|
|
||||||
|
Color get loginFormTextLabelColor;
|
||||||
|
|
||||||
Color get primaryTextLabelColor;
|
Color get primaryTextLabelColor;
|
||||||
Color get secondaryTextLabelColor;
|
Color get secondaryTextLabelColor;
|
||||||
@@ -18,11 +27,36 @@ abstract interface class GeneralStyle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GeneralStyleImpl implements GeneralStyle {
|
class GeneralStyleImpl implements GeneralStyle {
|
||||||
|
@override
|
||||||
|
Color? evaluationColor({int value = 0}) {
|
||||||
|
switch (value) {
|
||||||
|
case 1:
|
||||||
|
return evaluationGoodColor;
|
||||||
|
case 2:
|
||||||
|
return evaluationMiddleColor;
|
||||||
|
case 3:
|
||||||
|
return evaluationBadColor;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get evaluationGoodColor => Colors.green;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get evaluationMiddleColor => Colors.yellow;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get evaluationBadColor => Colors.red;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get loginFormTextLabelColor => const Color(0xFF001689);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color get primaryTextLabelColor => const Color(0xFF0045FF);
|
Color get primaryTextLabelColor => const Color(0xFF0045FF);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color get secondaryTextLabelColor => const Color(0xFF2F2F2F);
|
Color get secondaryTextLabelColor => const Color(0xFF5B5B5B); //2F2F2F
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color get primaryButtonBackgroundColor => const Color(0xFF0045FF);
|
Color get primaryButtonBackgroundColor => const Color(0xFF0045FF);
|
||||||
@@ -36,6 +70,9 @@ class GeneralStyleImpl implements GeneralStyle {
|
|||||||
@override
|
@override
|
||||||
Color get pageBackgroundColor => const Color(0xFFF5F5F5);
|
Color get pageBackgroundColor => const Color(0xFFF5F5F5);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Color get nextTextColor => const Color(0xFF757575);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Color get errorColor => const Color(0xFFFF0000);
|
Color get errorColor => const Color(0xFFFF0000);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:fotodocumentation/main.dart';
|
import 'package:fotodocumentation/main.dart';
|
||||||
import 'package:fotodocumentation/pages/customer/customer_list_widget.dart';
|
import 'package:fotodocumentation/pages/customer/customer_list_widget.dart';
|
||||||
import 'package:fotodocumentation/pages/customer/customer_widget.dart';
|
import 'package:fotodocumentation/pages/customer/customer_widget.dart';
|
||||||
|
import 'package:fotodocumentation/pages/customer/picture_widget.dart';
|
||||||
import 'package:fotodocumentation/pages/login/login_widget.dart';
|
import 'package:fotodocumentation/pages/login/login_widget.dart';
|
||||||
import 'package:fotodocumentation/utils/di_container.dart';
|
import 'package:fotodocumentation/utils/di_container.dart';
|
||||||
import 'package:fotodocumentation/utils/login_credentials.dart';
|
import 'package:fotodocumentation/utils/login_credentials.dart';
|
||||||
@@ -16,6 +17,7 @@ class GlobalRouter {
|
|||||||
|
|
||||||
static final String pathHome = "/home";
|
static final String pathHome = "/home";
|
||||||
static final String pathCustomer = "/customer";
|
static final String pathCustomer = "/customer";
|
||||||
|
static final String pathPicture = "/picture";
|
||||||
static final String pathLogin = "/login";
|
static final String pathLogin = "/login";
|
||||||
|
|
||||||
static final GoRouter router = createRouter(pathHome);
|
static final GoRouter router = createRouter(pathHome);
|
||||||
@@ -45,6 +47,13 @@ class GlobalRouter {
|
|||||||
return CustomerWidget(customerId: id ?? -1);
|
return CustomerWidget(customerId: id ?? -1);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
GoRoute(
|
||||||
|
path: pathPicture,
|
||||||
|
builder: (context, state) {
|
||||||
|
PictureWidgetHolder holder = state.extra as PictureWidgetHolder;
|
||||||
|
return PictureWidget(customerDto: holder.customerDto, pictureDto: holder.pictureDto);
|
||||||
|
},
|
||||||
|
),
|
||||||
],
|
],
|
||||||
redirect: (context, state) {
|
redirect: (context, state) {
|
||||||
var uriStr = state.uri.toString();
|
var uriStr = state.uri.toString();
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fotodocumentation/utils/di_container.dart';
|
||||||
|
import 'package:fotodocumentation/utils/jwt_token_storage.dart';
|
||||||
|
|
||||||
abstract class LoginCredentials extends ChangeNotifier {
|
abstract class LoginCredentials extends ChangeNotifier {
|
||||||
String get fullname;
|
String get fullname;
|
||||||
@@ -9,6 +11,8 @@ abstract class LoginCredentials extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class LoginCredentialsImpl extends LoginCredentials {
|
class LoginCredentialsImpl extends LoginCredentials {
|
||||||
|
JwtTokenStorage get jwtTokenStorage => DiContainer.get();
|
||||||
|
|
||||||
bool loggedIn = false;
|
bool loggedIn = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -24,6 +28,8 @@ class LoginCredentialsImpl extends LoginCredentials {
|
|||||||
@override
|
@override
|
||||||
void logout() {
|
void logout() {
|
||||||
loggedIn = false;
|
loggedIn = false;
|
||||||
|
|
||||||
|
jwtTokenStorage.clearTokens;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ void _testDelete(PictureController controller, int response, bool expected) asyn
|
|||||||
|
|
||||||
when(client.delete(Uri.parse('http://localhost:8080/api/picture/4'), headers: {"Accept-Language": "en-US"})).thenAnswer((_) async => http.Response("", response));
|
when(client.delete(Uri.parse('http://localhost:8080/api/picture/4'), headers: {"Accept-Language": "en-US"})).thenAnswer((_) async => http.Response("", response));
|
||||||
|
|
||||||
var dto = await controller.delete(PictureDto(id: 4, image: "", pictureDate: DateTime.now(), category: "", comment: "", username: ""));
|
var dto = await controller.delete(PictureDto(id: 4, image: "", pictureDate: DateTime.now(), category: "", comment: "", evaluation: 1, username: ""));
|
||||||
expect(dto, expected);
|
expect(dto, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -31,6 +31,7 @@ void main() {
|
|||||||
image: _testImage,
|
image: _testImage,
|
||||||
pictureDate: DateTime(2024, 1, 15),
|
pictureDate: DateTime(2024, 1, 15),
|
||||||
username: 'user1',
|
username: 'user1',
|
||||||
|
evaluation: 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
pictureDto2 = PictureDto(
|
pictureDto2 = PictureDto(
|
||||||
@@ -40,6 +41,7 @@ void main() {
|
|||||||
image: _testImage,
|
image: _testImage,
|
||||||
pictureDate: DateTime(2024, 2, 20),
|
pictureDate: DateTime(2024, 2, 20),
|
||||||
username: 'user2',
|
username: 'user2',
|
||||||
|
evaluation: 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
pictureDto3 = PictureDto(
|
pictureDto3 = PictureDto(
|
||||||
@@ -49,6 +51,7 @@ void main() {
|
|||||||
image: _testImage,
|
image: _testImage,
|
||||||
pictureDate: DateTime(2024, 3, 25),
|
pictureDate: DateTime(2024, 3, 25),
|
||||||
username: 'user3',
|
username: 'user3',
|
||||||
|
evaluation: 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
customerDto = CustomerDto(
|
customerDto = CustomerDto(
|
||||||
@@ -111,7 +114,7 @@ void main() {
|
|||||||
expect(find.text('KOMMENTAR'), findsOneWidget);
|
expect(find.text('KOMMENTAR'), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('shows close button', (WidgetTester tester) async {
|
testWidgets('shows both navigation buttons at bottom', (WidgetTester tester) async {
|
||||||
setScreenSize(tester, 1024, 1024);
|
setScreenSize(tester, 1024, 1024);
|
||||||
|
|
||||||
await pumpApp(
|
await pumpApp(
|
||||||
@@ -120,25 +123,12 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Verify close button icon exists
|
// Both navigation buttons should always be visible at the bottom
|
||||||
expect(find.byIcon(Icons.close), findsOneWidget);
|
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||||
});
|
|
||||||
|
|
||||||
testWidgets('shows right navigation button when there are more pictures', (WidgetTester tester) async {
|
|
||||||
setScreenSize(tester, 1024, 1024);
|
|
||||||
|
|
||||||
await pumpApp(
|
|
||||||
tester,
|
|
||||||
PictureWidget(customerDto: customerDto, pictureDto: pictureDto1),
|
|
||||||
);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
|
|
||||||
// First picture should have right navigation (chevron_right), no left navigation
|
|
||||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||||
expect(find.byIcon(Icons.chevron_left), findsNothing);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('shows left navigation button when not on first picture', (WidgetTester tester) async {
|
testWidgets('shows both navigation buttons when on middle picture', (WidgetTester tester) async {
|
||||||
setScreenSize(tester, 1024, 1024);
|
setScreenSize(tester, 1024, 1024);
|
||||||
|
|
||||||
await pumpApp(
|
await pumpApp(
|
||||||
@@ -147,12 +137,12 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Middle picture should have both navigation buttons
|
// Both navigation buttons should be visible
|
||||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||||
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('shows only left navigation on last picture', (WidgetTester tester) async {
|
testWidgets('shows both navigation buttons on last picture', (WidgetTester tester) async {
|
||||||
setScreenSize(tester, 1024, 1024);
|
setScreenSize(tester, 1024, 1024);
|
||||||
|
|
||||||
await pumpApp(
|
await pumpApp(
|
||||||
@@ -161,9 +151,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// Last picture should have left navigation, no right navigation
|
// Both navigation buttons should be visible (right one is disabled)
|
||||||
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||||
expect(find.byIcon(Icons.chevron_right), findsNothing);
|
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('navigates to next picture when right button is tapped', (WidgetTester tester) async {
|
testWidgets('navigates to next picture when right button is tapped', (WidgetTester tester) async {
|
||||||
@@ -208,7 +198,7 @@ void main() {
|
|||||||
expect(find.text('Second picture comment'), findsNothing);
|
expect(find.text('Second picture comment'), findsNothing);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('shows no navigation buttons when only one picture', (WidgetTester tester) async {
|
testWidgets('shows disabled navigation buttons when only one picture', (WidgetTester tester) async {
|
||||||
setScreenSize(tester, 1024, 1024);
|
setScreenSize(tester, 1024, 1024);
|
||||||
|
|
||||||
final singlePictureCustomer = CustomerDto(
|
final singlePictureCustomer = CustomerDto(
|
||||||
@@ -224,9 +214,9 @@ void main() {
|
|||||||
);
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
// No navigation buttons should be shown
|
// Both navigation buttons should be shown but disabled
|
||||||
expect(find.byIcon(Icons.chevron_left), findsNothing);
|
expect(find.byIcon(Icons.chevron_left), findsOneWidget);
|
||||||
expect(find.byIcon(Icons.chevron_right), findsNothing);
|
expect(find.byIcon(Icons.chevron_right), findsOneWidget);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
|
testWidgets('opens fullscreen dialog when image is tapped', (WidgetTester tester) async {
|
||||||
|
|||||||
Reference in New Issue
Block a user