198 lines
4.9 KiB
Dart
198 lines
4.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mobile_monitoring/core/constants/colors.dart';
|
|
|
|
/// Section Header - Header untuk section di halaman
|
|
class SectionHeader extends StatelessWidget {
|
|
final String title;
|
|
final String? subtitle;
|
|
final Widget? trailing;
|
|
final VoidCallback? onTrailingTap;
|
|
final String? trailingText;
|
|
final EdgeInsetsGeometry? padding;
|
|
final bool showDivider;
|
|
|
|
const SectionHeader({
|
|
super.key,
|
|
required this.title,
|
|
this.subtitle,
|
|
this.trailing,
|
|
this.onTrailingTap,
|
|
this.trailingText,
|
|
this.padding,
|
|
this.showDivider = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: padding ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
child: Row(
|
|
children: [
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.bold,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
if (subtitle != null) ...[
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
subtitle!,
|
|
style: const TextStyle(
|
|
fontSize: 14,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
if (trailing != null)
|
|
trailing!
|
|
else if (trailingText != null)
|
|
TextButton(
|
|
onPressed: onTrailingTap,
|
|
child: Text(trailingText!),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
if (showDivider) const Divider(height: 1),
|
|
],
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Simple Section Header - Header sederhana untuk section
|
|
class SimpleSectionHeader extends StatelessWidget {
|
|
final String title;
|
|
final EdgeInsetsGeometry? padding;
|
|
|
|
const SimpleSectionHeader({
|
|
super.key,
|
|
required this.title,
|
|
this.padding,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Padding(
|
|
padding: padding ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Icon Section Header - Section header dengan icon
|
|
class IconSectionHeader extends StatelessWidget {
|
|
final String title;
|
|
final IconData icon;
|
|
final Color? iconColor;
|
|
final VoidCallback? onTap;
|
|
final EdgeInsetsGeometry? padding;
|
|
|
|
const IconSectionHeader({
|
|
super.key,
|
|
required this.title,
|
|
required this.icon,
|
|
this.iconColor,
|
|
this.onTap,
|
|
this.padding,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return InkWell(
|
|
onTap: onTap,
|
|
child: Padding(
|
|
padding: padding ?? const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
|
child: Row(
|
|
children: [
|
|
Icon(
|
|
icon,
|
|
color: iconColor ?? AppColors.primary,
|
|
size: 24,
|
|
),
|
|
const SizedBox(width: 12),
|
|
Expanded(
|
|
child: Text(
|
|
title,
|
|
style: const TextStyle(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.textPrimary,
|
|
),
|
|
),
|
|
),
|
|
if (onTap != null)
|
|
const Icon(
|
|
Icons.chevron_right,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Divider with Text - Divider dengan teks di tengah
|
|
class DividerWithText extends StatelessWidget {
|
|
final String text;
|
|
final Color? color;
|
|
final double? thickness;
|
|
|
|
const DividerWithText({
|
|
super.key,
|
|
required this.text,
|
|
this.color,
|
|
this.thickness,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Row(
|
|
children: [
|
|
Expanded(
|
|
child: Divider(
|
|
color: color ?? AppColors.borderLight,
|
|
thickness: thickness ?? 1,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
|
child: Text(
|
|
text,
|
|
style: const TextStyle(
|
|
fontSize: 12,
|
|
color: AppColors.textSecondary,
|
|
),
|
|
),
|
|
),
|
|
Expanded(
|
|
child: Divider(
|
|
color: color ?? AppColors.borderLight,
|
|
thickness: thickness ?? 1,
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|