You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
77 lines
2.4 KiB
Dart
77 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
import 'package:test_sa/new_views/pages/land_page/land_page.dart';
|
|
import 'package:test_sa/new_views/swipe_module/dialoge/acknowledge_work_dialog.dart';
|
|
|
|
import '../app_style/app_color.dart';
|
|
|
|
class DefaultAppBar extends StatelessWidget implements PreferredSizeWidget {
|
|
final String? title;
|
|
final List<Widget>? actions;
|
|
final Function? onBackPress;
|
|
final bool showHomeActionButton;
|
|
final VoidCallback? onWillPopScope;
|
|
|
|
const DefaultAppBar({this.title, this.onBackPress, this.onWillPopScope, this.actions, this.showHomeActionButton = false, Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
List<Widget> _actions = [];
|
|
|
|
if (showHomeActionButton) {
|
|
_actions.add(
|
|
IconButton(
|
|
icon: const Icon(Icons.home),
|
|
onPressed: () {
|
|
// stopTimer();
|
|
Navigator.pop(context);
|
|
Navigator.popUntil(context, (ModalRoute.withName(LandPage.routeName)));
|
|
},
|
|
),
|
|
);
|
|
}
|
|
if (actions?.isNotEmpty ?? false) {
|
|
_actions.addAll(actions!);
|
|
}
|
|
return AppBar(
|
|
automaticallyImplyLeading: false,
|
|
titleSpacing: 16,
|
|
title: Row(
|
|
children: [
|
|
const Icon(Icons.arrow_back_ios).onPress(() {
|
|
if (onWillPopScope != null) {
|
|
showDialog(
|
|
context: context,
|
|
builder: (BuildContext cxt) => AcknowledgeWorkDialog(
|
|
onSave: onWillPopScope!,
|
|
onDiscard: () {
|
|
Navigator.of(cxt).pop();
|
|
},
|
|
),
|
|
);
|
|
return;
|
|
}
|
|
if (onBackPress != null) {
|
|
onBackPress!();
|
|
} else {
|
|
Navigator.of(context).pop();
|
|
}
|
|
}),
|
|
10.width,
|
|
Text(
|
|
title ?? "",
|
|
style: AppTextStyles.heading3.copyWith(fontWeight: FontWeight.w500, color: context.isDark ? AppColor.neutral30 : AppColor.neutral50),
|
|
).expanded,
|
|
],
|
|
),
|
|
actions: _actions,
|
|
);
|
|
}
|
|
|
|
@override
|
|
Size get preferredSize => Size.fromHeight(60.toScreenHeight);
|
|
}
|