Skip to content

Commit

Permalink
chore: rename appbar to topappbar to match designs
Browse files Browse the repository at this point in the history
  • Loading branch information
thelukewalton committed May 16, 2024
1 parent b65a09a commit 5da47a6
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 50 deletions.
4 changes: 2 additions & 2 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:zeta_example/pages/components/accordion_example.dart';
import 'package:zeta_example/pages/components/app_bar_example.dart';
import 'package:zeta_example/pages/components/avatar_example.dart';
import 'package:zeta_example/pages/components/badges_example.dart';
import 'package:zeta_example/pages/components/banner_example.dart';
Expand Down Expand Up @@ -34,6 +33,7 @@ import 'package:zeta_example/pages/components/snackbar_example.dart';
import 'package:zeta_example/pages/components/tabs_example.dart';
import 'package:zeta_example/pages/components/pagination_example.dart';
import 'package:zeta_example/pages/components/tooltip_example.dart';
import 'package:zeta_example/pages/components/top_app_bar_example.dart';
import 'package:zeta_example/pages/theme/color_example.dart';
import 'package:zeta_example/pages/components/password_input_example.dart';
import 'package:zeta_example/pages/components/progress_example.dart';
Expand All @@ -53,7 +53,7 @@ class Component {

final List<Component> components = [
Component(AccordionExample.name, (context) => const AccordionExample()),
Component(AppBarExample.name, (context) => const AppBarExample()),
Component(TopAppBarExample.name, (context) => const TopAppBarExample()),
Component(AvatarExample.name, (context) => const AvatarExample()),
Component(BannerExample.name, (context) => const BannerExample()),
Component(BadgesExample.name, (context) => const BadgesExample()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import 'package:flutter/material.dart';
import 'package:zeta_example/widgets.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

class AppBarExample extends StatefulWidget {
const AppBarExample({super.key});
class TopAppBarExample extends StatefulWidget {
const TopAppBarExample({super.key});

static const String name = 'AppBar';
static const String name = 'TopAppBar';

@override
State<AppBarExample> createState() => _AppBarExampleState();
State<TopAppBarExample> createState() => _TopAppBarExampleState();
}

class _AppBarExampleState extends State<AppBarExample> {
class _TopAppBarExampleState extends State<TopAppBarExample> {
late final _searchController = AppBarSearchController();

void _showHideSearch() {
Expand All @@ -23,14 +23,14 @@ class _AppBarExampleState extends State<AppBarExample> {
@override
Widget build(BuildContext context) {
return ExampleScaffold(
name: AppBarExample.name,
name: TopAppBarExample.name,
child: SingleChildScrollView(
child: Column(
children: [
// Default
Padding(
padding: const EdgeInsets.only(top: ZetaSpacing.x4),
child: ZetaAppBar(
child: ZetaTopAppBar(
leading: IconButton(
onPressed: () {},
icon: Icon(Icons.menu_rounded),
Expand Down Expand Up @@ -64,8 +64,8 @@ class _AppBarExampleState extends State<AppBarExample> {
// Centered
Padding(
padding: const EdgeInsets.only(top: ZetaSpacing.x4),
child: ZetaAppBar(
type: ZetaAppBarType.centeredTitle,
child: ZetaTopAppBar(
type: ZetaTopAppBarType.centeredTitle,
leading: IconButton(
onPressed: () {},
icon: Icon(Icons.menu_rounded),
Expand All @@ -83,7 +83,7 @@ class _AppBarExampleState extends State<AppBarExample> {
// Contextual
Padding(
padding: const EdgeInsets.only(top: ZetaSpacing.x4),
child: ZetaAppBar(
child: ZetaTopAppBar(
leading: IconButton(
onPressed: () {},
icon: Icon(ZetaIcons.close_round),
Expand Down Expand Up @@ -115,8 +115,8 @@ class _AppBarExampleState extends State<AppBarExample> {
padding: const EdgeInsets.only(top: ZetaSpacing.x4),
child: Column(
children: [
ZetaAppBar(
type: ZetaAppBarType.centeredTitle,
ZetaTopAppBar(
type: ZetaTopAppBarType.centeredTitle,
leading: BackButton(),
title: Text("Title"),
actions: [
Expand Down Expand Up @@ -151,8 +151,8 @@ class _AppBarExampleState extends State<AppBarExample> {
// Extended
Padding(
padding: const EdgeInsets.only(top: ZetaSpacing.x4),
child: ZetaAppBar(
type: ZetaAppBarType.extendedTitle,
child: ZetaTopAppBar(
type: ZetaTopAppBarType.extendedTitle,
leading: IconButton(
onPressed: () {},
icon: Icon(Icons.menu),
Expand Down
8 changes: 4 additions & 4 deletions example/widgetbook/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:zeta_flutter/zeta_flutter.dart';

import 'pages/assets/icon_widgetbook.dart';
import 'pages/components/accordion_widgetbook.dart';
import 'pages/components/app_bar_widgetbook.dart';
import 'pages/components/top_app_bar_widgetbook.dart';
import 'pages/components/avatar_widgetbook.dart';
import 'pages/components/badges_widgetbook.dart';
import 'pages/components/banner_widgetbook.dart';
Expand Down Expand Up @@ -61,10 +61,10 @@ class HotReload extends StatelessWidget {
isInitiallyExpanded: false,
children: [
WidgetbookComponent(
name: 'App Bar',
name: 'Top App Bar',
useCases: [
WidgetbookUseCase(name: 'Default', builder: (context) => defaultAppBarUseCase(context)),
WidgetbookUseCase(name: 'Search', builder: (context) => searchAppBarUseCase(context)),
WidgetbookUseCase(name: 'Default', builder: (context) => defaultTopAppBarUseCase(context)),
WidgetbookUseCase(name: 'Search', builder: (context) => searchTopAppBarUseCase(context)),
],
),
WidgetbookComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@ import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';

Widget defaultAppBarUseCase(BuildContext context) {
Widget defaultTopAppBarUseCase(BuildContext context) {
return WidgetbookTestWidget(
widget: StatefulBuilder(
builder: (context, setState) {
final title = context.knobs.string(label: "Title", initialValue: "Title");

final type = context.knobs.list(
label: "Type",
options: [
ZetaAppBarType.defaultAppBar,
ZetaAppBarType.centeredTitle,
ZetaAppBarType.extendedTitle,
ZetaTopAppBarType.defaultAppBar,
ZetaTopAppBarType.centeredTitle,
ZetaTopAppBarType.extendedTitle,
],
initialOption: ZetaAppBarType.defaultAppBar,
initialOption: ZetaTopAppBarType.defaultAppBar,
labelBuilder: (type) => type.name,
);

Expand Down Expand Up @@ -48,7 +47,7 @@ Widget defaultAppBarUseCase(BuildContext context) {
labelBuilder: (icon) => icon.key.toString(),
);

return ZetaAppBar(
return ZetaTopAppBar(
leading: IconButton(
onPressed: () {},
icon: leadingIcon,
Expand Down Expand Up @@ -77,7 +76,7 @@ Widget defaultAppBarUseCase(BuildContext context) {
);
}

Widget searchAppBarUseCase(BuildContext context) {
Widget searchTopAppBarUseCase(BuildContext context) {
return WidgetbookTestWidget(
widget: _SearchUseCase(),
);
Expand All @@ -100,11 +99,11 @@ class _SearchUseCaseState extends State<_SearchUseCase> {
final type = context.knobs.list(
label: "Type",
options: [
ZetaAppBarType.defaultAppBar,
ZetaAppBarType.centeredTitle,
ZetaAppBarType.extendedTitle,
ZetaTopAppBarType.defaultAppBar,
ZetaTopAppBarType.centeredTitle,
ZetaTopAppBarType.extendedTitle,
],
initialOption: ZetaAppBarType.defaultAppBar,
initialOption: ZetaTopAppBarType.defaultAppBar,
labelBuilder: (type) => type.name,
);

Expand Down Expand Up @@ -135,7 +134,7 @@ class _SearchUseCaseState extends State<_SearchUseCase> {
initialValue: false,
);

return ZetaAppBar(
return ZetaTopAppBar(
leading: IconButton(
onPressed: () {},
icon: leadingIcon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ZetaScreenHeaderBar extends StatelessWidget {

@override
Widget build(BuildContext context) {
return ZetaAppBar(
return ZetaTopAppBar(
leading: IconButton(
onPressed: () async => Navigator.maybePop(context),
icon: Icon(rounded ? ZetaIcons.chevron_left_round : ZetaIcons.chevron_left_sharp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import 'package:flutter/material.dart';
import '../../../zeta_flutter.dart';

/// Zeta app bar.
class ZetaAppBar extends StatefulWidget implements PreferredSizeWidget {
class ZetaTopAppBar extends StatefulWidget implements PreferredSizeWidget {
/// Creates a Zeta app bar.
const ZetaAppBar({
const ZetaTopAppBar({
this.actions,
this.automaticallyImplyLeading = true,
this.searchController,
this.leading,
this.title,
this.titleSpacing,
this.titleTextStyle,
this.type = ZetaAppBarType.defaultAppBar,
this.type = ZetaTopAppBarType.defaultAppBar,
this.onSearch,
this.searchHintText = 'Search',
this.onSearchMicrophoneIconPressed,
Expand Down Expand Up @@ -51,10 +51,10 @@ class ZetaAppBar extends StatefulWidget implements PreferredSizeWidget {
final TextStyle? titleTextStyle;

/// Defines the styles of the app bar.
final ZetaAppBarType type;
final ZetaTopAppBarType type;

@override
State<ZetaAppBar> createState() => _ZetaAppBarState();
State<ZetaTopAppBar> createState() => _ZetaTopAppBarState();

@override
Size get preferredSize => const Size.fromHeight(kToolbarHeight);
Expand Down Expand Up @@ -84,14 +84,14 @@ class ZetaAppBar extends StatefulWidget implements PreferredSizeWidget {
),
)
..add(StringProperty('searchHintText', searchHintText))
..add(EnumProperty<ZetaAppBarType>('type', type))
..add(EnumProperty<ZetaAppBarType>('type', type))
..add(EnumProperty<ZetaTopAppBarType>('type', type))
..add(EnumProperty<ZetaTopAppBarType>('type', type))
..add(DoubleProperty('titleSpacing', titleSpacing))
..add(DiagnosticsProperty<TextStyle?>('titleTextStyle', titleTextStyle));
}
}

class _ZetaAppBarState extends State<ZetaAppBar> {
class _ZetaTopAppBarState extends State<ZetaTopAppBar> {
bool _isSearchEnabled = false;

@override
Expand All @@ -114,7 +114,7 @@ class _ZetaAppBarState extends State<ZetaAppBar> {
}

Widget? _getTitle() {
return widget.type != ZetaAppBarType.extendedTitle
return widget.type != ZetaTopAppBarType.extendedTitle
? Padding(
padding: EdgeInsets.symmetric(horizontal: widget.titleSpacing ?? ZetaSpacing.b),
child: widget.title,
Expand All @@ -140,7 +140,7 @@ class _ZetaAppBarState extends State<ZetaAppBar> {
leadingWidth: ZetaSpacing.x10,
leading: widget.leading,
automaticallyImplyLeading: widget.automaticallyImplyLeading,
centerTitle: widget.type == ZetaAppBarType.centeredTitle,
centerTitle: widget.type == ZetaTopAppBarType.centeredTitle,
titleSpacing: 0,
titleTextStyle: widget.titleTextStyle == null
? ZetaTextStyles.bodyLarge.copyWith(
Expand Down Expand Up @@ -192,7 +192,7 @@ class _ZetaAppBarState extends State<ZetaAppBar> {
),
]
: widget.actions,
flexibleSpace: widget.type == ZetaAppBarType.extendedTitle
flexibleSpace: widget.type == ZetaTopAppBarType.extendedTitle
? Padding(
padding: EdgeInsets.only(
top: widget.preferredSize.height,
Expand All @@ -214,7 +214,7 @@ class _ZetaAppBarState extends State<ZetaAppBar> {
}

/// Defines the style of the app bar.
enum ZetaAppBarType {
enum ZetaTopAppBarType {
/// Title positioned on the left side.
defaultAppBar,

Expand All @@ -238,7 +238,7 @@ class _SearchField extends StatefulWidget {
final Widget? child;
final String hintText;
final AppBarSearchController? searchController;
final ZetaAppBarType type;
final ZetaTopAppBarType type;

@override
State<_SearchField> createState() => _SearchFieldState();
Expand All @@ -260,7 +260,7 @@ class _SearchField extends StatefulWidget {
searchController,
),
)
..add(EnumProperty<ZetaAppBarType>('type', type));
..add(EnumProperty<ZetaTopAppBarType>('type', type));
}
}

Expand Down Expand Up @@ -358,7 +358,7 @@ class _SearchFieldState extends State<_SearchField> with SingleTickerProviderSta
children: [
Row(
mainAxisAlignment:
widget.type == ZetaAppBarType.centeredTitle ? MainAxisAlignment.center : MainAxisAlignment.start,
widget.type == ZetaTopAppBarType.centeredTitle ? MainAxisAlignment.center : MainAxisAlignment.start,
children: [
widget.child ?? const SizedBox(),
],
Expand Down
2 changes: 1 addition & 1 deletion lib/zeta_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ library zeta_flutter;

export 'src/assets/icons.dart';
export 'src/components/accordion/accordion.dart';
export 'src/components/app_bar/app_bar.dart';
export 'src/components/avatars/avatar.dart';
export 'src/components/badges/badge.dart';
export 'src/components/badges/indicator.dart';
Expand Down Expand Up @@ -51,6 +50,7 @@ export 'src/components/switch/zeta_switch.dart';
export 'src/components/tabs/tab.dart';
export 'src/components/tabs/tab_bar.dart';
export 'src/components/tooltip/tooltip.dart';
export 'src/components/top_app_bar/top_app_bar.dart';
export 'src/theme/color_extensions.dart';
export 'src/theme/color_scheme.dart';
export 'src/theme/color_swatch.dart';
Expand Down

0 comments on commit 5da47a6

Please sign in to comment.