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,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LandingPageWidget extends StatefulWidget {
|
||||
final Widget child;
|
||||
const LandingPageWidget({super.key, required this.child});
|
||||
|
||||
@override
|
||||
State<LandingPageWidget> createState() => _LandingPageWidgetState();
|
||||
}
|
||||
|
||||
class _LandingPageWidgetState extends State<LandingPageWidget> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: widget.child,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
|
||||
typedef SubmitCallback = void Function();
|
||||
|
||||
class GeneralSubmitWidget extends StatelessWidget {
|
||||
GeneralStyle get _generalStyle => DiContainer.get();
|
||||
|
||||
final SubmitCallback onSelect;
|
||||
final String? title;
|
||||
|
||||
const GeneralSubmitWidget({super.key, required this.onSelect, this.title});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
String text = title ?? AppLocalizations.of(context)!.submitWidget;
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
key: Key("SubmitWidgetButton"),
|
||||
style: _generalStyle.elevatedButtonStyle,
|
||||
onPressed: onSelect,
|
||||
child: Text(text),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,173 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:fotodocumentation/main.dart' show logger;
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/dialog/snackbar_utils.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
|
||||
class DeleteDialog extends StatelessWidget {
|
||||
static SnackbarUtils get _snackbarUtils => DiContainer.get();
|
||||
|
||||
const DeleteDialog({super.key});
|
||||
|
||||
static Future<void> show(BuildContext context, Future<DeleteDialogResult> Function() doDelete) async {
|
||||
await _openDialog(context).then((value) async {
|
||||
if (value != null && value && context.mounted) {
|
||||
logger.d("Delete popup result $value");
|
||||
var result = await doDelete();
|
||||
if (context.mounted && result.msg.isNotEmpty) {
|
||||
_snackbarUtils.showSnackbar(context, result.msg, result.warning);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static Future<bool?> _openDialog(BuildContext context) async {
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: false, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return const DeleteDialog(
|
||||
key: Key("delete_dialog"),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final loc = AppLocalizations.of(context)!;
|
||||
|
||||
return AlertDialog(
|
||||
backgroundColor: Colors.white,
|
||||
scrollable: false,
|
||||
titlePadding: const EdgeInsets.all(16.0),
|
||||
contentPadding: const EdgeInsets.fromLTRB(16.0, 0, 16.0, 16.0),
|
||||
title: _titleWidget(context, loc),
|
||||
content: _content(context, loc),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _titleWidget(BuildContext context, AppLocalizations loc) {
|
||||
return Card(
|
||||
elevation: 4,
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(
|
||||
color: Colors.grey[300]!,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: 32,
|
||||
color: Colors.orange[700],
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
loc.deleteDialogTitle,
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
IconButton(
|
||||
key: const Key("close_button"),
|
||||
icon: const Icon(Icons.close),
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _content(BuildContext context, AppLocalizations loc) {
|
||||
return SizedBox(
|
||||
width: 400,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Card(
|
||||
elevation: 2,
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
side: BorderSide(
|
||||
color: Colors.grey[300]!,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.warning_amber_rounded,
|
||||
size: 48,
|
||||
color: Colors.orange[700],
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Text(
|
||||
loc.deleteDialogText,
|
||||
style: Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
key: const Key("delete_dialog:cancel"),
|
||||
style: TextButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.pop(context, false),
|
||||
child: Text(loc.deleteDialogButtonCancel),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton.icon(
|
||||
key: const Key("delete_dialog:approve"),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
backgroundColor: Colors.red[600],
|
||||
foregroundColor: Colors.white,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
onPressed: () => Navigator.pop(context, true),
|
||||
icon: const Icon(Icons.delete, size: 20),
|
||||
label: Text(loc.deleteDialogButtonApprove),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class DeleteDialogResult {
|
||||
final String msg;
|
||||
final bool warning;
|
||||
|
||||
DeleteDialogResult({required this.msg, required this.warning});
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
abstract interface class SnackbarUtils {
|
||||
void showSnackbar(BuildContext context, String msg, bool warning);
|
||||
void showSnackbarPopup(BuildContext context, String msg, bool warning);
|
||||
}
|
||||
|
||||
class SnackbarUtilsImpl implements SnackbarUtils {
|
||||
@override
|
||||
void showSnackbar(BuildContext context, String msg, bool warning) {
|
||||
var snackBar = SnackBar(
|
||||
content: _contentFor(context, msg, warning),
|
||||
backgroundColor: Colors.white,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
showCloseIcon: true,
|
||||
closeIconColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
side: BorderSide(width: 2.0, style: BorderStyle.solid, color: Theme.of(context).colorScheme.inversePrimary),
|
||||
),
|
||||
margin: EdgeInsets.only(bottom: MediaQuery.of(context).size.height - 130, left: MediaQuery.of(context).size.width - 400, right: 10),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
@override
|
||||
void showSnackbarPopup(BuildContext context, String msg, bool warning) {
|
||||
var snackBar = SnackBar(
|
||||
content: _contentFor(context, msg, warning),
|
||||
backgroundColor: Colors.white,
|
||||
behavior: SnackBarBehavior.floating,
|
||||
showCloseIcon: true,
|
||||
closeIconColor: Theme.of(context).colorScheme.inversePrimary,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
side: BorderSide(width: 2.0, style: BorderStyle.solid, color: Theme.of(context).colorScheme.inversePrimary),
|
||||
),
|
||||
width: 350,
|
||||
//margin: EdgeInsets.only(bottom: MediaQuery.of(context).size.height - 100, left: MediaQuery.of(context).size.width - 350, right: 10),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
||||
}
|
||||
|
||||
Widget _contentFor(BuildContext context, String msg, bool warning) {
|
||||
var icon = _iconFor(context, warning);
|
||||
|
||||
var style = _textStyleFor(context, warning);
|
||||
return Wrap(
|
||||
alignment: WrapAlignment.start,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
icon,
|
||||
Text(
|
||||
msg,
|
||||
style: style,
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Icon _iconFor(BuildContext context, bool warning) {
|
||||
var color = _contentColor(context, warning);
|
||||
return warning ? Icon(Icons.error, color: color) : Icon(Icons.check_circle_outline, color: color);
|
||||
}
|
||||
|
||||
TextStyle _textStyleFor(BuildContext context, bool warning) {
|
||||
var color = _contentColor(context, warning);
|
||||
var bodyLarge = Theme.of(context).primaryTextTheme.bodyLarge!;
|
||||
var style = TextStyle(
|
||||
color: color,
|
||||
decoration: bodyLarge.decoration,
|
||||
fontFamily: bodyLarge.fontFamily,
|
||||
fontSize: bodyLarge.fontSize,
|
||||
fontWeight: bodyLarge.fontWeight,
|
||||
letterSpacing: bodyLarge.letterSpacing,
|
||||
textBaseline: bodyLarge.textBaseline);
|
||||
return style;
|
||||
}
|
||||
|
||||
Color _contentColor(BuildContext context, bool warning) {
|
||||
return warning ? Theme.of(context).colorScheme.error : Theme.of(context).colorScheme.inversePrimary;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
abstract interface class GeneralStyle {
|
||||
ButtonStyle get elevatedButtonStyle;
|
||||
ButtonStyle get roundedButtonStyle;
|
||||
|
||||
|
||||
Color get primaryTextLabelColor;
|
||||
Color get secondaryTextLabelColor;
|
||||
|
||||
@@ -14,23 +12,12 @@ abstract interface class GeneralStyle {
|
||||
|
||||
Color get pageBackgroundColor;
|
||||
|
||||
Color get primaryCardColor;
|
||||
|
||||
Color get errorColor;
|
||||
|
||||
String get fontFamily;
|
||||
}
|
||||
|
||||
class GeneralStyleImpl implements GeneralStyle {
|
||||
static final ButtonStyle _elevatedButtonStyle = ElevatedButton.styleFrom(textStyle: const TextStyle(fontSize: 20));
|
||||
static final ButtonStyle _roundedButtonStyle = ElevatedButton.styleFrom(shape: const CircleBorder(), padding: const EdgeInsets.all(8));
|
||||
|
||||
@override
|
||||
ButtonStyle get elevatedButtonStyle => _elevatedButtonStyle;
|
||||
|
||||
@override
|
||||
ButtonStyle get roundedButtonStyle => _roundedButtonStyle;
|
||||
|
||||
@override
|
||||
Color get primaryTextLabelColor => const Color(0xFF0045FF);
|
||||
|
||||
@@ -45,10 +32,7 @@ class GeneralStyleImpl implements GeneralStyle {
|
||||
|
||||
@override
|
||||
Color get primaryButtonTextColor => Colors.white;
|
||||
|
||||
@override
|
||||
Color get primaryCardColor => Colors.white;
|
||||
|
||||
|
||||
@override
|
||||
Color get pageBackgroundColor => const Color(0xFFF5F5F5);
|
||||
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class HeaderButtonWrapper extends StatefulWidget {
|
||||
final IconData icon;
|
||||
final String tooltip;
|
||||
final VoidCallback onPressed;
|
||||
final Color? iconColor;
|
||||
final int? badgeCount;
|
||||
|
||||
const HeaderButtonWrapper({
|
||||
super.key,
|
||||
required this.icon,
|
||||
required this.tooltip,
|
||||
required this.onPressed,
|
||||
this.iconColor,
|
||||
this.badgeCount,
|
||||
});
|
||||
|
||||
@override
|
||||
State<HeaderButtonWrapper> createState() => _HeaderButtonWrapperState();
|
||||
}
|
||||
|
||||
class _HeaderButtonWrapperState extends State<HeaderButtonWrapper> {
|
||||
bool _isHovered = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MouseRegion(
|
||||
onEnter: (_) => setState(() => _isHovered = true),
|
||||
onExit: (_) => setState(() => _isHovered = false),
|
||||
child: Tooltip(
|
||||
message: widget.tooltip,
|
||||
child: Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: _isHovered ? Colors.blue[50] : Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: _isHovered ? Colors.blue[200]! : Colors.transparent,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: IconButton(
|
||||
icon: Icon(
|
||||
widget.icon,
|
||||
size: 24,
|
||||
color: widget.iconColor ?? Colors.grey[700],
|
||||
),
|
||||
onPressed: widget.onPressed,
|
||||
splashRadius: 24,
|
||||
),
|
||||
),
|
||||
if (widget.badgeCount != null && widget.badgeCount! > 0)
|
||||
Positioned(
|
||||
right: 4,
|
||||
top: 4,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.all(4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.red[600],
|
||||
shape: BoxShape.circle,
|
||||
border: Border.all(
|
||||
color: Colors.white,
|
||||
width: 2,
|
||||
),
|
||||
),
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 20,
|
||||
minHeight: 20,
|
||||
),
|
||||
child: Text(
|
||||
widget.badgeCount! > 99 ? '99+' : widget.badgeCount.toString(),
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
import 'package:fotodocumentation/utils/login_credentials.dart';
|
||||
|
||||
abstract interface class HeaderUtils {
|
||||
Widget titleWidget(String text);
|
||||
}
|
||||
|
||||
class HeaderUtilsImpl extends HeaderUtils {
|
||||
LoginCredentials get _loginCredentials => DiContainer.get();
|
||||
|
||||
@override
|
||||
Widget titleWidget(String text) {
|
||||
return Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
Icons.school,
|
||||
size: 28,
|
||||
color: Colors.blue[700],
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Text(
|
||||
text,
|
||||
style: const TextStyle(
|
||||
fontSize: 22,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
if (_loginCredentials.fullname.isNotEmpty) ...[
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 40.0),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.blue[50],
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
border: Border.all(
|
||||
color: Colors.blue[200]!,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Icon(
|
||||
Icons.person_outline,
|
||||
size: 14,
|
||||
color: Colors.blue[700],
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
Text(
|
||||
_loginCredentials.fullname,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: Colors.blue[900],
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/header_button_wrapper.dart';
|
||||
|
||||
class ModernAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||
final Widget title;
|
||||
final List<Widget> actions;
|
||||
final Widget? leading;
|
||||
final bool automaticallyImplyLeading;
|
||||
|
||||
const ModernAppBar({
|
||||
super.key,
|
||||
required this.title,
|
||||
this.actions = const [],
|
||||
this.leading,
|
||||
this.automaticallyImplyLeading = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Widget? effectiveLeading = _effectiveLeading(context);
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.grey[50],
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey[300]!,
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
if (effectiveLeading != null) ...[
|
||||
effectiveLeading,
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
Expanded(child: title),
|
||||
const SizedBox(width: 16),
|
||||
...actions.map((action) => Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0),
|
||||
child: action,
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget? _effectiveLeading(BuildContext context) {
|
||||
// Determine if we should show a back button
|
||||
final ScaffoldState? scaffold = Scaffold.maybeOf(context);
|
||||
final ModalRoute<dynamic>? parentRoute = ModalRoute.of(context);
|
||||
final bool hasDrawer = scaffold?.hasDrawer ?? false;
|
||||
final bool canPop = parentRoute?.canPop ?? false;
|
||||
final bool useCloseButton = parentRoute is PageRoute<dynamic> && parentRoute.fullscreenDialog;
|
||||
|
||||
Widget? effectiveLeading = leading;
|
||||
if (effectiveLeading == null && automaticallyImplyLeading) {
|
||||
if (hasDrawer) {
|
||||
effectiveLeading = HeaderButtonWrapper(
|
||||
icon: Icons.menu,
|
||||
onPressed: () {
|
||||
Scaffold.of(context).openDrawer();
|
||||
},
|
||||
tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
|
||||
iconColor: Colors.grey[700],
|
||||
);
|
||||
} else if (canPop) {
|
||||
if (useCloseButton) {
|
||||
effectiveLeading = HeaderButtonWrapper(
|
||||
icon: Icons.close,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
tooltip: MaterialLocalizations.of(context).closeButtonTooltip,
|
||||
iconColor: Colors.grey[700],
|
||||
);
|
||||
} else {
|
||||
effectiveLeading = HeaderButtonWrapper(
|
||||
icon: Icons.arrow_back,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
|
||||
iconColor: Colors.grey[700],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return effectiveLeading;
|
||||
}
|
||||
|
||||
@override
|
||||
Size get preferredSize => const Size.fromHeight(80);
|
||||
}
|
||||
Reference in New Issue
Block a user