bharat_erp/lib/shared/widgets/page_header.dart
2026-07-14 16:02:04 +05:30

85 lines
2.6 KiB
Dart

import 'package:flutter/material.dart';
import '../../core/utils/responsive_utils.dart';
class PageHeader extends StatelessWidget {
const PageHeader({
super.key,
required this.title,
this.subtitle,
this.actions,
this.leading,
});
final String title;
final String? subtitle;
final List<Widget>? actions;
final Widget? leading;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 12),
child: context.isMobile
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
if (leading != null) ...[
leading!,
const SizedBox(width: 8),
],
Expanded(
child: Text(
title,
style: Theme.of(context).textTheme.headlineSmall,
),
),
],
),
if (subtitle != null) ...[
const SizedBox(height: 4),
Text(
subtitle!,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
if (actions != null && actions!.isNotEmpty) ...[
const SizedBox(height: 16),
Wrap(spacing: 8, runSpacing: 8, children: actions!),
],
],
)
: Row(
children: [
if (leading != null) ...[
leading!,
const SizedBox(width: 8),
],
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(title, style: Theme.of(context).textTheme.headlineSmall),
if (subtitle != null) ...[
const SizedBox(height: 4),
Text(
subtitle!,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: Theme.of(context).colorScheme.onSurfaceVariant,
),
),
],
],
),
),
if (actions != null) ...actions!,
],
),
);
}
}