entityfield
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import 'package:base_project/core/providers/dynamic_theme_provider.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import '../../../core/providers/dynamic_theme_provider.dart';
|
||||
import '../../../core/constants/ui_constants.dart';
|
||||
import '../../../shared/widgets/app_bar/modern_app_bar.dart';
|
||||
import 'entity_card.dart';
|
||||
@@ -22,6 +22,9 @@ class EntityList extends StatefulWidget {
|
||||
final String title;
|
||||
final Function()? onAddNew;
|
||||
final List<Map<String, dynamic>> displayFields;
|
||||
// Optional: header insert action (e.g., Childform/Insert Support)
|
||||
final Function()? onInsertAction;
|
||||
final String? insertActionLabel;
|
||||
|
||||
const EntityList({
|
||||
super.key,
|
||||
@@ -39,6 +42,8 @@ class EntityList extends StatefulWidget {
|
||||
required this.title,
|
||||
this.onAddNew,
|
||||
this.displayFields = const [],
|
||||
this.onInsertAction,
|
||||
this.insertActionLabel,
|
||||
});
|
||||
|
||||
@override
|
||||
@@ -97,13 +102,21 @@ class _EntityListState extends State<EntityList> with TickerProviderStateMixin {
|
||||
title: widget.title,
|
||||
showBackButton: true,
|
||||
actions: [
|
||||
if (widget.onInsertAction != null)
|
||||
TextButton(
|
||||
onPressed: widget.onInsertAction,
|
||||
child: Text(
|
||||
widget.insertActionLabel ?? 'Unknown',
|
||||
style: TextStyle(
|
||||
color: colorScheme.primary,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (widget.onAddNew != null)
|
||||
IconButton(
|
||||
onPressed: widget.onAddNew,
|
||||
icon: Icon(
|
||||
Icons.add_rounded,
|
||||
color: colorScheme.primary,
|
||||
),
|
||||
icon: Icon(Icons.add_rounded, color: colorScheme.primary),
|
||||
tooltip: 'Add New',
|
||||
),
|
||||
],
|
||||
@@ -114,9 +127,7 @@ class _EntityListState extends State<EntityList> with TickerProviderStateMixin {
|
||||
_buildSearchBar(colorScheme),
|
||||
|
||||
// Content
|
||||
Expanded(
|
||||
child: _buildContent(colorScheme),
|
||||
),
|
||||
Expanded(child: _buildContent(colorScheme)),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -136,10 +147,7 @@ class _EntityListState extends State<EntityList> with TickerProviderStateMixin {
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
colorScheme.surface,
|
||||
colorScheme.surface.withOpacity(0.95),
|
||||
],
|
||||
colors: [colorScheme.surface, colorScheme.surface.withOpacity(0.95)],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(UIConstants.radius16),
|
||||
border: Border.all(
|
||||
@@ -234,10 +242,7 @@ class _EntityListState extends State<EntityList> with TickerProviderStateMixin {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
CircularProgressIndicator(
|
||||
color: colorScheme.primary,
|
||||
strokeWidth: 3,
|
||||
),
|
||||
CircularProgressIndicator(color: colorScheme.primary, strokeWidth: 3),
|
||||
const SizedBox(height: UIConstants.spacing16),
|
||||
Text(
|
||||
'Loading ${widget.title.toLowerCase()}...',
|
||||
@@ -292,10 +297,7 @@ class _EntityListState extends State<EntityList> with TickerProviderStateMixin {
|
||||
const SizedBox(height: UIConstants.spacing24),
|
||||
ElevatedButton.icon(
|
||||
onPressed: widget.onRefresh,
|
||||
icon: Icon(
|
||||
Icons.refresh_rounded,
|
||||
color: colorScheme.onPrimary,
|
||||
),
|
||||
icon: Icon(Icons.refresh_rounded, color: colorScheme.onPrimary),
|
||||
label: Text(
|
||||
'Retry',
|
||||
style: TextStyle(
|
||||
@@ -365,10 +367,7 @@ class _EntityListState extends State<EntityList> with TickerProviderStateMixin {
|
||||
const SizedBox(height: UIConstants.spacing24),
|
||||
ElevatedButton.icon(
|
||||
onPressed: widget.onAddNew,
|
||||
icon: Icon(
|
||||
Icons.add_rounded,
|
||||
color: colorScheme.onPrimary,
|
||||
),
|
||||
icon: Icon(Icons.add_rounded, color: colorScheme.onPrimary),
|
||||
label: Text(
|
||||
'Add ${widget.title}',
|
||||
style: TextStyle(
|
||||
@@ -454,10 +453,7 @@ class _EntityListState extends State<EntityList> with TickerProviderStateMixin {
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.topLeft,
|
||||
end: Alignment.bottomRight,
|
||||
colors: [
|
||||
colorScheme.surface,
|
||||
colorScheme.surface.withOpacity(0.95),
|
||||
],
|
||||
colors: [colorScheme.surface, colorScheme.surface.withOpacity(0.95)],
|
||||
),
|
||||
borderRadius: BorderRadius.circular(UIConstants.radius20),
|
||||
border: Border.all(
|
||||
|
||||
Reference in New Issue
Block a user