First designs for ui
This commit is contained in:
@@ -0,0 +1,275 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/controller/base_controller.dart';
|
||||
import 'package:fotodocumentation/controller/customer_controller.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/general_error_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/page_header_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/search_bar_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/waiting_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:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class CustomerListWidget extends StatefulWidget {
|
||||
const CustomerListWidget({super.key});
|
||||
|
||||
@override
|
||||
State<CustomerListWidget> createState() => _CustomerListWidgetState();
|
||||
}
|
||||
|
||||
class _CustomerListWidgetState extends State<CustomerListWidget> {
|
||||
CustomerController get _customerController => DiContainer.get();
|
||||
GeneralStyle get _generalStyle => DiContainer.get();
|
||||
|
||||
final _searchController = TextEditingController();
|
||||
late Future<List<CustomerListDto>> _dtos;
|
||||
String? _selectedLetter;
|
||||
late DateFormat _dateFormat;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_dateFormat = DateFormat('dd MMMM yyyy');
|
||||
_dtos = _customerController.getAll(_searchController.text, "");
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_searchController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
body: _body(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
return Container(
|
||||
color: _generalStyle.pageBackgroundColor,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 8.0, left: 50.0, right: 50.0, bottom: 8.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
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),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: _customerListWidget(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _customerListWidget() {
|
||||
return FutureBuilder<List<CustomerListDto>>(
|
||||
future: _dtos,
|
||||
builder: (BuildContext context, AsyncSnapshot<List<CustomerListDto>> snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const WaitingWidget();
|
||||
}
|
||||
if (snapshot.hasData) {
|
||||
List<CustomerListDto> dtos = snapshot.data ?? [];
|
||||
|
||||
return _listWidget(dtos);
|
||||
} else if (snapshot.hasError) {
|
||||
var error = snapshot.error;
|
||||
return (error is ServerError) ? GeneralErrorWidget.fromServerError(error) : GeneralErrorWidget(error: snapshot.error.toString());
|
||||
}
|
||||
return const WaitingWidget();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _listWidget(List<CustomerListDto> dtos) {
|
||||
if (dtos.isEmpty) {
|
||||
return Text(AppLocalizations.of(context)!.customerListEmpty,
|
||||
style: TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
color: _generalStyle.secondaryWidgetBackgroundColor,
|
||||
));
|
||||
}
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_tableHeaderRow(context),
|
||||
Divider(thickness: 2, height: 1, color: _generalStyle.secondaryWidgetBackgroundColor),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.all(0),
|
||||
itemCount: dtos.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return _tableDataRow(context, dtos[index]);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) => Divider(
|
||||
color: _generalStyle.secondaryWidgetBackgroundColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tableHeaderRow(BuildContext context) {
|
||||
final headerStyle = TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
color: _generalStyle.secondaryWidgetBackgroundColor,
|
||||
);
|
||||
|
||||
final headerStyleSuffix = TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 20,
|
||||
color: _generalStyle.secondaryWidgetBackgroundColor,
|
||||
);
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
children: [
|
||||
const SizedBox(width: 48),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.customerListHeaderCustomerNumber,
|
||||
style: headerStyle,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.customerListHeaderName,
|
||||
style: headerStyle,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Wrap(
|
||||
children: [
|
||||
Text(
|
||||
AppLocalizations.of(context)!.customerListHeaderLastDate,
|
||||
style: headerStyle,
|
||||
),
|
||||
Text(
|
||||
AppLocalizations.of(context)!.customerListHeaderLastDateSuffix,
|
||||
style: headerStyleSuffix,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tableDataRow(BuildContext context, CustomerListDto dto) {
|
||||
final dataStyle = TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontSize: 16.0,
|
||||
color: _generalStyle.secondaryTextLabelColor,
|
||||
);
|
||||
|
||||
final dateStr = dto.lastUpdateDate == null ? "" : _dateFormat.format(dto.lastUpdateDate!);
|
||||
return InkWell(
|
||||
onTap: () => _actionSelect(context, dto),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
SizedBox(
|
||||
width: 48,
|
||||
child: Icon(Icons.folder_open_outlined, color: _generalStyle.secondaryWidgetBackgroundColor),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Text(dto.customerNumber, style: dataStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Text(dto.name, style: dataStyle),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Text(dateStr, style: dataStyle),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> actionSearch(String text) async {
|
||||
_reloadData();
|
||||
}
|
||||
|
||||
Future<void> _actionSelect(BuildContext context, CustomerListDto dto) async {
|
||||
context.go("${GlobalRouter.pathCustomer}/${dto.id}");
|
||||
}
|
||||
|
||||
void _reloadData() {
|
||||
_dtos = _customerController.getAll(_searchController.text, _selectedLetter ?? "");
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
Widget _abcHeaderBar() {
|
||||
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: Wrap(
|
||||
spacing: 8,
|
||||
runSpacing: 8,
|
||||
children: letters.split('').map((letter) {
|
||||
final isSelected = _selectedLetter == letter;
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
_selectedLetter = isSelected ? null : letter;
|
||||
_reloadData();
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
|
||||
decoration: BoxDecoration(
|
||||
color: isSelected ? _generalStyle.secondaryWidgetBackgroundColor : Colors.white,
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
child: Text(
|
||||
letter,
|
||||
style: TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20.0,
|
||||
color: isSelected ? Colors.white : _generalStyle.secondaryWidgetBackgroundColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,260 @@
|
||||
import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:fotodocumentation/controller/base_controller.dart';
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
import 'package:fotodocumentation/controller/customer_controller.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/general_error_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/page_header_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/waiting_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';
|
||||
|
||||
class CustomerWidget extends StatefulWidget {
|
||||
const CustomerWidget({super.key});
|
||||
final int customerId;
|
||||
const CustomerWidget({super.key, required this.customerId});
|
||||
|
||||
@override
|
||||
State<CustomerWidget> createState() => _CustomerWidgetState();
|
||||
}
|
||||
|
||||
class _CustomerWidgetState extends State<CustomerWidget> {
|
||||
CustomerController get _customerController => DiContainer.get();
|
||||
GeneralStyle get _generalStyle => DiContainer.get();
|
||||
|
||||
late Future<CustomerDto?> _dto;
|
||||
late DateFormat _dateFormat;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_dateFormat = DateFormat('dd MMMM yyyy');
|
||||
_dto = _customerController.get(id: widget.customerId);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Placeholder();
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
return FutureBuilder<CustomerDto?>(
|
||||
future: _dto,
|
||||
builder: (BuildContext context, AsyncSnapshot<CustomerDto?> snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const WaitingWidget();
|
||||
}
|
||||
if (snapshot.hasData) {
|
||||
CustomerDto? dto = snapshot.data;
|
||||
|
||||
return _mainWidget(dto);
|
||||
} else if (snapshot.hasError) {
|
||||
var error = snapshot.error;
|
||||
return (error is ServerError) ? GeneralErrorWidget.fromServerError(error) : GeneralErrorWidget(error: snapshot.error.toString());
|
||||
}
|
||||
return const WaitingWidget();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _mainWidget(CustomerDto? dto) {
|
||||
if (dto == null) {
|
||||
return Text(
|
||||
AppLocalizations.of(context)!.customerWidgetNotFound,
|
||||
style: TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
color: _generalStyle.secondaryWidgetBackgroundColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
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),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _customerWidget(CustomerDto dto) {
|
||||
var dtos = dto.pictures;
|
||||
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Column(
|
||||
children: [
|
||||
_tableHeaderRow(context),
|
||||
Divider(thickness: 2, height: 1, color: _generalStyle.secondaryWidgetBackgroundColor),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
itemCount: dtos.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return _tableDataRow(context, dtos[index]);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) => Divider(color: _generalStyle.secondaryWidgetBackgroundColor),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tableHeaderRow(BuildContext context) {
|
||||
final headerStyle = TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
color: _generalStyle.secondaryWidgetBackgroundColor,
|
||||
);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.customerWidgetHeaderFoto,
|
||||
style: headerStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.customerWidgetHeaderComment,
|
||||
style: headerStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.customerWidgetHeaderUploadDate,
|
||||
style: headerStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _tableDataRow(BuildContext context, PictureDto dto) {
|
||||
final dataStyle = TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontSize: 16.0,
|
||||
color: _generalStyle.secondaryTextLabelColor,
|
||||
);
|
||||
|
||||
final dateStr = _dateFormat.format(dto.pictureDate);
|
||||
return InkWell(
|
||||
onTap: () => _actionSelect(context, dto),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 70, maxHeight: 70),
|
||||
child: Image.memory(
|
||||
base64Decode(dto.image),
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 3,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(dto.comment ?? "", style: dataStyle),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Align(
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(dateStr, style: dataStyle),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _actionSelect(BuildContext context, PictureDto dto) async {
|
||||
context.go("${GlobalRouter.pathPicture}/${dto.id}");
|
||||
}
|
||||
|
||||
Widget _backButton(BuildContext context) {
|
||||
return ElevatedButton.icon(
|
||||
onPressed: () => context.go(GlobalRouter.pathHome),
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
import 'dart:convert' show base64Decode;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/controller/picture_controller.dart';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import 'package:fotodocumentation/controller/base_controller.dart';
|
||||
import 'package:fotodocumentation/dto/customer_dto.dart';
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/general_error_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/waiting_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
|
||||
class PictureWidget extends StatefulWidget {
|
||||
final int id;
|
||||
const PictureWidget({super.key, required this.id});
|
||||
|
||||
@override
|
||||
State<PictureWidget> createState() => _PictureWidgetState();
|
||||
}
|
||||
|
||||
class _PictureWidgetState extends State<PictureWidget> {
|
||||
PictureController get _pictureController => DiContainer.get();
|
||||
GeneralStyle get _generalStyle => DiContainer.get();
|
||||
|
||||
late Future<PictureDto?> _dto;
|
||||
late DateFormat _dateFormat;
|
||||
final ScrollController _commentScrollController = ScrollController();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_dateFormat = DateFormat('dd MMMM yyyy');
|
||||
_dto = _pictureController.get(id: widget.id);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_commentScrollController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
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),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
return FutureBuilder<PictureDto?>(
|
||||
future: _dto,
|
||||
builder: (BuildContext context, AsyncSnapshot<PictureDto?> snapshot) {
|
||||
if (snapshot.connectionState != ConnectionState.done) {
|
||||
return const WaitingWidget();
|
||||
}
|
||||
if (snapshot.hasData) {
|
||||
PictureDto? dto = snapshot.data;
|
||||
|
||||
return _mainWidget(dto);
|
||||
} else if (snapshot.hasError) {
|
||||
var error = snapshot.error;
|
||||
return (error is ServerError) ? GeneralErrorWidget.fromServerError(error) : GeneralErrorWidget(error: snapshot.error.toString());
|
||||
}
|
||||
return const WaitingWidget();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _mainWidget(PictureDto? dto) {
|
||||
if (dto == null) {
|
||||
return Text(
|
||||
AppLocalizations.of(context)!.customerWidgetNotFound,
|
||||
style: TextStyle(
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 20,
|
||||
color: _generalStyle.secondaryWidgetBackgroundColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return Card(
|
||||
margin: EdgeInsets.zero,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
final isNarrow = constraints.maxWidth < 800;
|
||||
return SingleChildScrollView(
|
||||
child: isNarrow
|
||||
? Column(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_imageWidget(dto),
|
||||
const SizedBox(height: 32),
|
||||
_contentWidget(dto),
|
||||
],
|
||||
)
|
||||
: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_imageWidget(dto),
|
||||
const SizedBox(width: 32),
|
||||
_contentWidget(dto),
|
||||
],
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _imageWidget(PictureDto dto) {
|
||||
return Image.memory(
|
||||
base64Decode(dto.image),
|
||||
fit: BoxFit.contain,
|
||||
);
|
||||
}
|
||||
|
||||
Widget _contentWidget(PictureDto dto) {
|
||||
final labelStyle = TextStyle(
|
||||
fontWeight: FontWeight.normal,
|
||||
fontSize: 16,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
color: _generalStyle.primaryTextLabelColor,
|
||||
);
|
||||
|
||||
final contentStyle = TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
color: _generalStyle.secondaryTextLabelColor,
|
||||
);
|
||||
|
||||
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
||||
Text(
|
||||
"INFORMATIONEN",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 44,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
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(
|
||||
"Name of apotheke",
|
||||
style: contentStyle,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20.0),
|
||||
child: Text(
|
||||
"KUNDENNUMMER",
|
||||
style: labelStyle,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Text(
|
||||
"123445587474873",
|
||||
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(
|
||||
"KOMMENTAR",
|
||||
style: labelStyle,
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 4.0),
|
||||
child: Container(
|
||||
width: 300,
|
||||
height: 150,
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: _generalStyle.secondaryTextLabelColor.withValues(alpha: 0.3)),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: Scrollbar(
|
||||
controller: _commentScrollController,
|
||||
thumbVisibility: true,
|
||||
child: SingleChildScrollView(
|
||||
controller: _commentScrollController,
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
dto.comment ?? "",
|
||||
style: contentStyle,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,7 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:fotodocumentation/controller/login_controller.dart';
|
||||
import 'package:fotodocumentation/dto/jwt_token_pair_dto.dart';
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/component/general_submit_widget.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/header_utils.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/modern_app_bar.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
import 'package:fotodocumentation/utils/login_credentials.dart';
|
||||
|
||||
@@ -20,9 +18,9 @@ class LoginWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LoginWidgetState extends State<LoginWidget> {
|
||||
HeaderUtils get _headerUtils => DiContainer.get();
|
||||
LoginController get _loginController => DiContainer.get();
|
||||
LoginCredentials get _loginCredentials => DiContainer.get();
|
||||
GeneralStyle get _generalStyle => DiContainer.get();
|
||||
|
||||
final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
|
||||
|
||||
@@ -43,26 +41,13 @@ class _LoginWidgetState extends State<LoginWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: ModernAppBar(
|
||||
title: _headerUtils.titleWidget("Login title"),
|
||||
actions: [],
|
||||
),
|
||||
body: _body(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _body(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topCenter,
|
||||
end: Alignment.bottomCenter,
|
||||
colors: [
|
||||
Colors.grey[50]!,
|
||||
Colors.white,
|
||||
],
|
||||
),
|
||||
),
|
||||
color: _generalStyle.pageBackgroundColor,
|
||||
child: _content(context),
|
||||
);
|
||||
}
|
||||
@@ -81,49 +66,116 @@ class _LoginWidgetState extends State<LoginWidget> {
|
||||
},
|
||||
child: ListView(
|
||||
children: [
|
||||
Card(
|
||||
elevation: 4,
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(30.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
TextFormField(
|
||||
key: Key("username"),
|
||||
controller: _usernameController,
|
||||
decoration: InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
labelText: AppLocalizations.of(context)!.loginUsernameTFLabel,
|
||||
),
|
||||
padding: const EdgeInsets.symmetric(vertical: 40.0),
|
||||
child: Image.asset(
|
||||
'assets/images/logo.png',
|
||||
height: 120,
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxWidth: 500),
|
||||
child: Card(
|
||||
elevation: 0,
|
||||
margin: EdgeInsets.zero,
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(70.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Center(
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.loginTitle,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
color: _generalStyle.primaryTextLabelColor,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
fontSize: 50,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
if (_error != null) ...[
|
||||
Center(
|
||||
child: Text(
|
||||
_error!,
|
||||
style: TextStyle(
|
||||
color: _generalStyle.errorColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 40),
|
||||
],
|
||||
TextFormField(
|
||||
key: Key("username"),
|
||||
controller: _usernameController,
|
||||
decoration: 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: 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),
|
||||
TextFormField(
|
||||
key: Key("password"),
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: 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: 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),
|
||||
Center(
|
||||
child: ElevatedButton(
|
||||
key: Key("SubmitWidgetButton"),
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: _generalStyle.primaryButtonBackgroundColor,
|
||||
foregroundColor: _generalStyle.primaryButtonTextColor,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 20),
|
||||
),
|
||||
onPressed: () async => await _actionSubmit(context),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.loginLoginButtonLabel,
|
||||
style: TextStyle(fontWeight: FontWeight.bold, fontFamily: _generalStyle.fontFamily),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
TextFormField(
|
||||
key: Key("password"),
|
||||
controller: _passwordController,
|
||||
obscureText: true,
|
||||
decoration: InputDecoration(
|
||||
border: UnderlineInputBorder(),
|
||||
labelText: AppLocalizations.of(context)!.loginPasswordTFLabel,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (_error != null) ...[
|
||||
Text(
|
||||
_error!,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
GeneralSubmitWidget(
|
||||
key: const Key("submit"),
|
||||
onSelect: () async => await _actionSubmit(context),
|
||||
title: AppLocalizations.of(context)!.loginLoginButtonLabel,
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -142,7 +194,7 @@ class _LoginWidgetState extends State<LoginWidget> {
|
||||
|
||||
JwtTokenPairDto? jwtTokenPairDto = authenticateReply.jwtTokenPairDto;
|
||||
if (jwtTokenPairDto == null) {
|
||||
setState(() => _error = "Error message");
|
||||
setState(() => _error = AppLocalizations.of(context)!.loginErrorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,65 +1,54 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/pages/ui_utils/general_style.dart';
|
||||
import 'package:fotodocumentation/utils/di_container.dart';
|
||||
|
||||
class PageHeaderWidget extends StatelessWidget {
|
||||
final IconData iconData;
|
||||
final String text;
|
||||
final String subText;
|
||||
final Color? iconColor;
|
||||
|
||||
const PageHeaderWidget({super.key, this.iconData = Icons.business, required this.text, this.subText = "", this.iconColor});
|
||||
const PageHeaderWidget({super.key, required this.text, this.subText = ""});
|
||||
|
||||
GeneralStyle get _generalStyle => DiContainer.get();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = iconColor ?? Theme.of(context).colorScheme.primary;
|
||||
return 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(24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.all(8),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withAlpha(51),
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
child: Icon(
|
||||
iconData,
|
||||
size: 32,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Text(
|
||||
text,
|
||||
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (subText.isNotEmpty) ...[
|
||||
const SizedBox(height: 16),
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top:24.0, bottom: 24.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
subText,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Colors.grey[600],
|
||||
),
|
||||
key: Key("PageHeaderTextHeadline"),
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 50,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
color: _generalStyle.primaryTextLabelColor,
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
Image.asset(
|
||||
'assets/images/logo.png',
|
||||
height: 48,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (subText.isNotEmpty) ...[
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
key: Key("PageHeaderTextSubHeadline"),
|
||||
subText,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
color: _generalStyle.secondaryTextLabelColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
|
||||
class SearchBarCardWidget extends StatefulWidget {
|
||||
final TextEditingController searchController;
|
||||
final Function(String) onSearch;
|
||||
const SearchBarCardWidget({super.key, required this.searchController, required this.onSearch});
|
||||
|
||||
@override
|
||||
State<SearchBarCardWidget> createState() => _SearchBarCardWidgetState();
|
||||
}
|
||||
|
||||
class _SearchBarCardWidgetState extends State<SearchBarCardWidget> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return 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.symmetric(horizontal: 16.0, vertical: 8.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
key: Key("Search_text_field"),
|
||||
controller: widget.searchController,
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
decoration: InputDecoration(
|
||||
hintText: AppLocalizations.of(context)!.searchTFHint,
|
||||
border: InputBorder.none,
|
||||
prefixIcon: const Icon(Icons.search, size: 28),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
isDense: true,
|
||||
suffixIcon: InkWell(
|
||||
key: Key("Search_text_clear_button"),
|
||||
onTap: () => _actionClear(),
|
||||
child: const Icon(
|
||||
Icons.close,
|
||||
color: Colors.black,
|
||||
),
|
||||
)
|
||||
),
|
||||
onSubmitted: (_) => _actionSubmit(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
ElevatedButton.icon(
|
||||
key: Key("Search_text_button"),
|
||||
onPressed: _actionSubmit,
|
||||
icon: const Icon(Icons.search, size: 18),
|
||||
label: Text(AppLocalizations.of(context)!.searchButtonLabel),
|
||||
style: ElevatedButton.styleFrom(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _actionSubmit() {
|
||||
widget.onSearch(widget.searchController.text);
|
||||
}
|
||||
|
||||
void _actionClear() {
|
||||
widget.searchController.text = "";
|
||||
widget.onSearch(widget.searchController.text);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
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';
|
||||
|
||||
class SearchBarWidget extends StatefulWidget {
|
||||
final TextEditingController searchController;
|
||||
final Function(String) onSearch;
|
||||
const SearchBarWidget({super.key, required this.searchController, required this.onSearch});
|
||||
|
||||
@override
|
||||
State<SearchBarWidget> createState() => _SearchBarWidgetState();
|
||||
}
|
||||
|
||||
class _SearchBarWidgetState extends State<SearchBarWidget> {
|
||||
GeneralStyle get _generalStyle => DiContainer.get();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 0.0, vertical: 16.0),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(
|
||||
child: TextField(
|
||||
key: Key("Search_text_field"),
|
||||
controller: widget.searchController,
|
||||
textAlignVertical: TextAlignVertical.center,
|
||||
decoration: InputDecoration(
|
||||
hint: Text(
|
||||
AppLocalizations.of(context)!.searchTFHint,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontFamily: _generalStyle.fontFamily,
|
||||
color: _generalStyle.secondaryTextLabelColor.withValues(alpha: 0.5),
|
||||
),
|
||||
),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
borderSide: BorderSide(color: _generalStyle.secondaryTextLabelColor),
|
||||
),
|
||||
prefixIcon: Icon(Icons.search, size: 30, color: _generalStyle.secondaryWidgetBackgroundColor,),
|
||||
contentPadding: EdgeInsets.zero,
|
||||
isDense: true,
|
||||
),
|
||||
onSubmitted: (_) => _actionSubmit(),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void _actionSubmit() {
|
||||
widget.onSearch(widget.searchController.text);
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fotodocumentation/l10n/app_localizations.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
class TextInputWidget extends StatelessWidget {
|
||||
final String labelText;
|
||||
final bool required;
|
||||
final bool obscureText;
|
||||
final bool readOnly;
|
||||
final Function? onTap;
|
||||
const TextInputWidget({super.key, required this.labelText, this.required = false, this.obscureText = false, this.readOnly = false, this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<TextEditingController>(builder: (context, controller, child) {
|
||||
return TextFormField(
|
||||
readOnly: readOnly,
|
||||
obscureText: obscureText,
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
border: const UnderlineInputBorder(),
|
||||
labelText: labelText,
|
||||
),
|
||||
validator: (String? value) => required && (value == null || value.isEmpty) ? AppLocalizations.of(context)!.textInputWidgetValidatorText : null,
|
||||
onTap: () => onTap?.call(),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class TextMultiInputWidget extends StatelessWidget {
|
||||
final String labelText;
|
||||
final bool required;
|
||||
final bool obscureText;
|
||||
final bool readOnly;
|
||||
final Function? onTap;
|
||||
final int maxLines;
|
||||
const TextMultiInputWidget({super.key, required this.labelText, this.required = false, this.obscureText = false, this.readOnly = false, this.maxLines = 6, this.onTap});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Consumer<TextEditingController>(builder: (context, controller, child) {
|
||||
return TextFormField(
|
||||
readOnly: readOnly,
|
||||
minLines: 3, // Set this
|
||||
maxLines: maxLines, // and this
|
||||
keyboardType: TextInputType.multiline,
|
||||
obscureText: obscureText,
|
||||
controller: controller,
|
||||
decoration: InputDecoration(
|
||||
border: const UnderlineInputBorder(),
|
||||
labelText: labelText,
|
||||
),
|
||||
validator: (String? value) => required && (value == null || value.isEmpty) ? AppLocalizations.of(context)!.textInputWidgetValidatorText : null,
|
||||
onTap: () => onTap?.call(),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
class DialogResult<T> {
|
||||
final DialogResultType type;
|
||||
final T? dto;
|
||||
|
||||
const DialogResult({required this.type, this.dto});
|
||||
}
|
||||
|
||||
enum DialogResultType {
|
||||
create,
|
||||
add;
|
||||
}
|
||||
@@ -1,36 +1,55 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:pinput/pinput.dart';
|
||||
|
||||
abstract interface class GeneralStyle {
|
||||
PinTheme get pinTheme;
|
||||
|
||||
ButtonStyle get elevatedButtonStyle;
|
||||
ButtonStyle get roundedButtonStyle;
|
||||
|
||||
Color get primaryTextLabelColor;
|
||||
Color get secondaryTextLabelColor;
|
||||
|
||||
Color get primaryButtonBackgroundColor;
|
||||
Color get primaryButtonTextColor;
|
||||
|
||||
Color get secondaryWidgetBackgroundColor;
|
||||
|
||||
Color get pageBackgroundColor;
|
||||
|
||||
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
|
||||
PinTheme get pinTheme => _getPinTheme();
|
||||
|
||||
@override
|
||||
ButtonStyle get elevatedButtonStyle => _elevatedButtonStyle;
|
||||
|
||||
@override
|
||||
ButtonStyle get roundedButtonStyle => _roundedButtonStyle;
|
||||
|
||||
PinTheme _getPinTheme() {
|
||||
return PinTheme(
|
||||
width: 56,
|
||||
height: 56,
|
||||
textStyle: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.grey),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
);
|
||||
}
|
||||
@override
|
||||
Color get primaryTextLabelColor => const Color(0xFF0045FF);
|
||||
|
||||
@override
|
||||
Color get secondaryTextLabelColor => const Color(0xFF2F2F2F);
|
||||
|
||||
@override
|
||||
Color get primaryButtonBackgroundColor => const Color(0xFF0045FF);
|
||||
|
||||
@override
|
||||
Color get secondaryWidgetBackgroundColor => const Color(0xFF001689);
|
||||
|
||||
@override
|
||||
Color get primaryButtonTextColor => Colors.white;
|
||||
|
||||
@override
|
||||
Color get pageBackgroundColor => const Color(0xFFF5F5F5);
|
||||
|
||||
@override
|
||||
Color get errorColor => const Color(0xFFFF0000);
|
||||
|
||||
@override
|
||||
String get fontFamily => 'Panton';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user