-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53af9e7
commit e07fc48
Showing
7 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
example/lib/pages/components/screen_header_bar_example.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:zeta_example/widgets.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
class ScreenHeaderBarExample extends StatelessWidget { | ||
const ScreenHeaderBarExample({super.key}); | ||
|
||
static const String name = 'ScreenHeaderBar'; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ExampleScaffold( | ||
name: ScreenHeaderBarExample.name, | ||
child: ZetaScreenHeaderBar( | ||
title: Text("Add Subscribers"), | ||
actionButtonLabel: 'Done', | ||
onActionButtonPressed: () {}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
example/widgetbook/pages/components/screen_header_bar_widgetbook.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:widgetbook/widgetbook.dart'; | ||
import 'package:zeta_flutter/zeta_flutter.dart'; | ||
|
||
import '../../test/test_components.dart'; | ||
|
||
Widget screenHeaderBarUseCase(BuildContext context) { | ||
final title = context.knobs.string( | ||
label: 'Title', | ||
initialValue: 'Add Subscribers', | ||
); | ||
final rounded = context.knobs.boolean(label: 'Rounded', initialValue: true); | ||
|
||
return WidgetbookTestWidget( | ||
widget: ZetaScreenHeaderBar( | ||
title: Text(title), | ||
actionButtonLabel: 'Done', | ||
onActionButtonPressed: () {}, | ||
rounded: rounded, | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
lib/src/components/screen_header_bar/screen_header_bar.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import '../../../zeta_flutter.dart'; | ||
|
||
/// [ZetaScreenHeaderBar] | ||
class ZetaScreenHeaderBar extends StatelessWidget { | ||
/// Constructor for [ZetaScreenHeaderBar]. | ||
const ZetaScreenHeaderBar({ | ||
this.title, | ||
this.rounded = true, | ||
this.actionButtonLabel, | ||
this.onActionButtonPressed, | ||
super.key, | ||
}); | ||
|
||
/// The title of [ZetaScreenHeaderBar]. Normally a [Text] widget. | ||
final Widget? title; | ||
|
||
/// {@macro zeta-component-rounded} | ||
final bool rounded; | ||
|
||
/// The label of the action button. | ||
final String? actionButtonLabel; | ||
|
||
/// Called when the action button is pressed. | ||
final VoidCallback? onActionButtonPressed; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ZetaAppBar( | ||
leading: IconButton( | ||
onPressed: () async => Navigator.maybePop(context), | ||
icon: Icon(rounded ? ZetaIcons.chevron_left_round : ZetaIcons.chevron_left_sharp), | ||
), | ||
title: title, | ||
titleSpacing: 0, | ||
titleTextStyle: ZetaTextStyles.titleLarge, | ||
actions: actionButtonLabel == null | ||
? null | ||
: [ | ||
ZetaButton( | ||
label: actionButtonLabel!, | ||
onPressed: onActionButtonPressed, | ||
borderType: rounded ? ZetaWidgetBorder.rounded : ZetaWidgetBorder.sharp, | ||
), | ||
], | ||
); | ||
} | ||
|
||
@override | ||
void debugFillProperties(DiagnosticPropertiesBuilder properties) { | ||
super.debugFillProperties(properties); | ||
properties | ||
..add(DiagnosticsProperty<bool>('rounded', rounded)) | ||
..add(StringProperty('actionButtonLabel', actionButtonLabel)) | ||
..add(ObjectFlagProperty<VoidCallback?>.has('onActionButtonPressed', onActionButtonPressed)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters