112 lines
2.7 KiB
Dart
112 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:mobile_monitoring/core/constants/colors.dart';
|
|
|
|
/// Custom AppBar - AppBar yang reusable
|
|
class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|
final String title;
|
|
final List<Widget>? actions;
|
|
final Widget? leading;
|
|
final bool centerTitle;
|
|
final Color? backgroundColor;
|
|
final Color? foregroundColor;
|
|
final double? elevation;
|
|
final PreferredSizeWidget? bottom;
|
|
|
|
const CustomAppBar({
|
|
super.key,
|
|
required this.title,
|
|
this.actions,
|
|
this.leading,
|
|
this.centerTitle = true,
|
|
this.backgroundColor,
|
|
this.foregroundColor,
|
|
this.elevation,
|
|
this.bottom,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AppBar(
|
|
title: Text(title),
|
|
actions: actions,
|
|
leading: leading,
|
|
centerTitle: centerTitle,
|
|
backgroundColor: backgroundColor ?? AppColors.primary,
|
|
foregroundColor: foregroundColor ?? AppColors.white,
|
|
elevation: elevation ?? 0,
|
|
bottom: bottom,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => Size.fromHeight(
|
|
kToolbarHeight + (bottom?.preferredSize.height ?? 0),
|
|
);
|
|
}
|
|
|
|
/// Custom Tab Bar - Tab bar yang reusable
|
|
class CustomTabBar extends StatelessWidget implements PreferredSizeWidget {
|
|
final List<Tab> tabs;
|
|
final Color? indicatorColor;
|
|
final Color? labelColor;
|
|
final Color? unselectedLabelColor;
|
|
|
|
const CustomTabBar({
|
|
super.key,
|
|
required this.tabs,
|
|
this.indicatorColor,
|
|
this.labelColor,
|
|
this.unselectedLabelColor,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TabBar(
|
|
tabs: tabs,
|
|
indicatorColor: indicatorColor ?? AppColors.white,
|
|
labelColor: labelColor ?? AppColors.white,
|
|
unselectedLabelColor: unselectedLabelColor ?? AppColors.white.withValues(alpha: 0.7),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
|
|
}
|
|
|
|
/// Sliver AppBar Custom - Sliver AppBar yang reusable
|
|
class CustomSliverAppBar extends StatelessWidget {
|
|
final String title;
|
|
final List<Widget>? actions;
|
|
final Widget? flexibleSpace;
|
|
final double expandedHeight;
|
|
final bool floating;
|
|
final bool pinned;
|
|
final bool snap;
|
|
|
|
const CustomSliverAppBar({
|
|
super.key,
|
|
required this.title,
|
|
this.actions,
|
|
this.flexibleSpace,
|
|
this.expandedHeight = 200,
|
|
this.floating = false,
|
|
this.pinned = true,
|
|
this.snap = false,
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return SliverAppBar(
|
|
title: Text(title),
|
|
actions: actions,
|
|
flexibleSpace: flexibleSpace,
|
|
expandedHeight: expandedHeight,
|
|
floating: floating,
|
|
pinned: pinned,
|
|
snap: snap,
|
|
backgroundColor: AppColors.primary,
|
|
foregroundColor: AppColors.white,
|
|
);
|
|
}
|
|
}
|