Skip to content

Commit e7f861a

Browse files
authored
Merge pull request #34 from deepikahr/appbar
components definition has been changed
2 parents 69f5066 + 3126344 commit e7f861a

36 files changed

+686
-763
lines changed

example/lib/assets/img.png

35.1 KB
Loading

example/lib/main.dart

Lines changed: 346 additions & 275 deletions
Large diffs are not rendered by default.

example/pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ dev_dependencies:
2121
flutter:
2222
uses-material-design: true
2323
assets:
24-
- lib/assets/food.jpeg
24+
- lib/assets/food.jpeg
25+
- lib/assets/img.png

lib/components/appbar/gf_appbar.dart

Lines changed: 4 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import 'package:flutter/services.dart';
55
import 'package:flutter/widgets.dart';
66
import 'package:flutter/material.dart';
77

8-
const double _kLeadingWidth =
9-
kToolbarHeight; // So the leading button is square.
8+
const double _kLeadingWidth = kToolbarHeight;
109

11-
// Bottom justify the kToolbarHeight child which may overflow the top.
1210
class _ToolbarContainerLayout extends SingleChildLayoutDelegate {
1311
const _ToolbarContainerLayout();
1412

@@ -31,115 +29,11 @@ class _ToolbarContainerLayout extends SingleChildLayoutDelegate {
3129
bool shouldRelayout(_ToolbarContainerLayout oldDelegate) => false;
3230
}
3331

34-
/// A material design app bar.
35-
///
3632
/// An app bar consists of a toolbar and potentially other widgets, such as a
37-
/// [TabBar] and a [FlexibleSpaceBar]. App bars typically expose one or more
38-
/// common [actions] with [IconButton]s which are optionally followed by a
39-
/// [PopupMenuButton] for less common operations (sometimes called the "overflow
40-
/// menu").
41-
///
42-
/// App bars are typically used in the [Scaffold.appBar] property, which places
43-
/// the app bar as a fixed-height widget at the top of the screen. For a scrollable
44-
/// app bar, see [SliverGFAppBar], which embeds an [GFAppBar] in a sliver for use in
45-
/// a [CustomScrollView].
46-
///
47-
/// When not used as [Scaffold.appBar], or when wrapped in a [Hero], place the app
48-
/// bar in a [MediaQuery] to take care of the padding around the content of the
49-
/// app bar if needed, as the padding will not be handled by [Scaffold].
50-
///
33+
/// [GFTabBar][TabBar] and a [FlexibleSpaceBar].
5134
/// The GFAppBar displays the toolbar widgets, [leading], [title], and [actions],
52-
/// above the [bottom] (if any). The [bottom] is usually used for a [TabBar]. If
53-
/// a [flexibleSpace] widget is specified then it is stacked behind the toolbar
54-
/// and the bottom widget. The following diagram shows where each of these slots
55-
/// appears in the toolbar when the writing language is left-to-right (e.g.
56-
/// English):
57-
///
58-
/// ![The leading widget is in the top left, the actions are in the top right,
59-
/// the title is between them. The bottom is, naturally, at the bottom, and the
60-
/// flexibleSpace is behind all of them.](https://flutter.github.io/assets-for-api-docs/assets/material/app_bar.png)
61-
///
62-
/// If the [leading] widget is omitted, but the [GFAppBar] is in a [Scaffold] with
63-
/// a [Drawer], then a button will be inserted to open the drawer. Otherwise, if
64-
/// the nearest [Navigator] has any previous routes, a [BackButton] is inserted
65-
/// instead. This behavior can be turned off by setting the [automaticallyImplyLeading]
66-
/// to false. In that case a null leading widget will result in the middle/title widget
67-
/// stretching to start.
68-
///
69-
/// {@tool dartpad --template=stateless_widget_material}
70-
///
71-
/// This sample shows an [GFAppBar] with two simple actions. The first action
72-
/// opens a [SnackBar], while the second action navigates to a new page.
73-
///
74-
/// ```dart preamble
75-
/// final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
76-
/// final SnackBar snackBar = const SnackBar(content: Text('Showing Snackbar'));
77-
///
78-
/// void openPage(BuildContext context) {
79-
/// Navigator.push(context, MaterialPageRoute(
80-
/// builder: (BuildContext context) {
81-
/// return Scaffold(
82-
/// appBar: GFAppBar(
83-
/// title: const Text('Next page'),
84-
/// ),
85-
/// body: const Center(
86-
/// child: Text(
87-
/// 'This is the next page',
88-
/// style: TextStyle(fontSize: 24),
89-
/// ),
90-
/// ),
91-
/// );
92-
/// },
93-
/// ));
94-
/// }
95-
/// ```
96-
///
97-
/// ```dart
98-
/// Widget build(BuildContext context) {
99-
/// return Scaffold(
100-
/// key: scaffoldKey,
101-
/// appBar: GFAppBar(
102-
/// title: const Text('GFAppBar Demo'),
103-
/// actions: <Widget>[
104-
/// IconButton(
105-
/// icon: const Icon(Icons.add_alert),
106-
/// tooltip: 'Show Snackbar',
107-
/// onPressed: () {
108-
/// scaffoldKey.currentState.showSnackBar(snackBar);
109-
/// },
110-
/// ),
111-
/// IconButton(
112-
/// icon: const Icon(Icons.navigate_next),
113-
/// tooltip: 'Next page',
114-
/// onPressed: () {
115-
/// openPage(context);
116-
/// },
117-
/// ),
118-
/// ],
119-
/// ),
120-
/// body: const Center(
121-
/// child: Text(
122-
/// 'This is the home page',
123-
/// style: TextStyle(fontSize: 24),
124-
/// ),
125-
/// ),
126-
/// );
127-
/// }
128-
/// ```
129-
/// {@end-tool}
130-
///
131-
/// See also:
132-
///
133-
/// * [Scaffold], which displays the [GFAppBar] in its [Scaffold.appBar] slot.
134-
/// * [SliverGFAppBar], which uses [GFAppBar] to provide a flexible app bar that
135-
/// can be used in a [CustomScrollView].
136-
/// * [TabBar], which is typically placed in the [bottom] slot of the [GFAppBar]
137-
/// if the screen has multiple pages arranged in tabs.
138-
/// * [IconButton], which is used with [actions] to show buttons on the app bar.
139-
/// * [PopupMenuButton], to show a popup menu on the app bar, via [actions].
140-
/// * [FlexibleSpaceBar], which is used with [flexibleSpace] when the app bar
141-
/// can expand and collapse.
142-
/// * <https://material.io/design/components/app-bars-top.html>
35+
/// above the [bottom] (if any). The [bottom] is usually used for a [TabBar].
36+
14337
class GFAppBar extends StatefulWidget implements PreferredSizeWidget {
14438
/// Creates a material design app bar.
14539
///
@@ -184,44 +78,6 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget {
18478
super(key: key);
18579

18680
/// A widget to display before the [title].
187-
///
188-
/// If this is null and [automaticallyImplyLeading] is set to true, the
189-
/// [GFAppBar] will imply an appropriate widget. For example, if the [GFAppBar] is
190-
/// in a [Scaffold] that also has a [Drawer], the [Scaffold] will fill this
191-
/// widget with an [IconButton] that opens the drawer (using [Icons.menu]). If
192-
/// there's no [Drawer] and the parent [Navigator] can go back, the [GFAppBar]
193-
/// will use a [BackButton] that calls [Navigator.maybePop].
194-
///
195-
/// {@tool sample}
196-
///
197-
/// The following code shows how the drawer button could be manually specified
198-
/// instead of relying on [automaticallyImplyLeading]:
199-
///
200-
/// ```dart
201-
/// GFAppBar(
202-
/// leading: Builder(
203-
/// builder: (BuildContext context) {
204-
/// return IconButton(
205-
/// icon: const Icon(Icons.menu),
206-
/// onPressed: () { Scaffold.of(context).openDrawer(); },
207-
/// tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip,
208-
/// );
209-
/// },
210-
/// ),
211-
/// )
212-
/// ```
213-
/// {@end-tool}
214-
///
215-
/// The [Builder] is used in this example to ensure that the `context` refers
216-
/// to that part of the subtree. That way this code snippet can be used even
217-
/// inside the very code that is creating the [Scaffold] (in which case,
218-
/// without the [Builder], the `context` wouldn't be able to see the
219-
/// [Scaffold], since it would refer to an ancestor of that widget).
220-
///
221-
/// See also:
222-
///
223-
/// * [Scaffold.appBar], in which an [GFAppBar] is usually placed.
224-
/// * [Scaffold.drawer], in which the [Drawer] is usually placed.
22581
final Widget leading;
22682

22783
/// Controls whether we should try to imply the leading widget if null.
@@ -817,65 +673,6 @@ class _SliverGFAppBarDelegate extends SliverPersistentHeaderDelegate {
817673
/// [actions], above the [bottom] (if any). If a [flexibleSpace] widget is
818674
/// specified then it is stacked behind the toolbar and the bottom widget.
819675
///
820-
/// {@tool sample}
821-
///
822-
/// This is an example that could be included in a [CustomScrollView]'s
823-
/// [CustomScrollView.slivers] list:
824-
///
825-
/// ```dart
826-
/// SliverGFAppBar(
827-
/// expandedHeight: 150.0,
828-
/// flexibleSpace: const FlexibleSpaceBar(
829-
/// title: Text('Available seats'),
830-
/// ),
831-
/// actions: <Widget>[
832-
/// IconButton(
833-
/// icon: const Icon(Icons.add_circle),
834-
/// tooltip: 'Add new entry',
835-
/// onPressed: () { /* ... */ },
836-
/// ),
837-
/// ]
838-
/// )
839-
/// ```
840-
/// {@end-tool}
841-
///
842-
/// ## Animated Examples
843-
///
844-
/// The following animations show how app bars with different configurations
845-
/// behave when a user scrolls up and then down again.
846-
///
847-
/// * App bar with [floating]: false, [pinned]: false, [snap]: false:
848-
/// {@animation 476 400 https://flutter.github.io/assets-for-api-docs/assets/material/app_bar.mp4}
849-
///
850-
/// * App bar with [floating]: true, [pinned]: false, [snap]: false:
851-
/// {@animation 476 400 https://flutter.github.io/assets-for-api-docs/assets/material/app_bar_floating.mp4}
852-
///
853-
/// * App bar with [floating]: true, [pinned]: false, [snap]: true:
854-
/// {@animation 476 400 https://flutter.github.io/assets-for-api-docs/assets/material/app_bar_floating_snap.mp4}
855-
///
856-
/// * App bar with [floating]: true, [pinned]: true, [snap]: false:
857-
/// {@animation 476 400 https://flutter.github.io/assets-for-api-docs/assets/material/app_bar_pinned_floating.mp4}
858-
///
859-
/// * App bar with [floating]: true, [pinned]: true, [snap]: true:
860-
/// {@animation 476 400 https://flutter.github.io/assets-for-api-docs/assets/material/app_bar_pinned_floating_snap.mp4}
861-
///
862-
/// * App bar with [floating]: false, [pinned]: true, [snap]: false:
863-
/// {@animation 476 400 https://flutter.github.io/assets-for-api-docs/assets/material/app_bar_pinned.mp4}
864-
///
865-
/// The property [snap] can only be set to true if [floating] is also true.
866-
///
867-
/// See also:
868-
///
869-
/// * [CustomScrollView], which integrates the [SliverGFAppBar] into its
870-
/// scrolling.
871-
/// * [GFAppBar], which is a fixed-height app bar for use in [Scaffold.appBar].
872-
/// * [TabBar], which is typically placed in the [bottom] slot of the [GFAppBar]
873-
/// if the screen has multiple pages arranged in tabs.
874-
/// * [IconButton], which is used with [actions] to show buttons on the app bar.
875-
/// * [PopupMenuButton], to show a popup menu on the app bar, via [actions].
876-
/// * [FlexibleSpaceBar], which is used with [flexibleSpace] when the app bar
877-
/// can expand and collapse.
878-
/// * <https://material.io/design/components/app-bars-top.html>
879676
class SliverGFAppBar extends StatefulWidget {
880677
/// Creates a material design app bar that can be placed in a [CustomScrollView].
881678
///

lib/components/avatar/gf_avatar.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:ui_kit/size/gf_size.dart';
55
import 'package:ui_kit/colors/gf_color.dart';
66

77
class GFAvatar extends StatelessWidget {
8+
89
/// Typically a [Text] widget. If the [CircleAvatar] is to have an image, use [backgroundImage] instead.
910
final Widget child;
1011

@@ -26,7 +27,7 @@ class GFAvatar extends StatelessWidget {
2627
/// The maximum size of the avatar, expressed as the radius (half the diameter).
2728
final double maxRadius;
2829

29-
/// size of avatar like [double] or [GFSize] i.e, 1.2, small, medium, large etc.
30+
/// size of avatar like [GFSize] i.e, 1.2, small, medium, large etc.
3031
final dynamic size;
3132

3233
/// shape of avatar [GFAvatarShape] i.e, standard, circle, square

lib/components/badge/gf_badge.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ import 'package:ui_kit/size/gf_size.dart';
44
import 'package:ui_kit/colors/gf_color.dart';
55

66
class GFBadge extends StatefulWidget {
7-
/// The border side for the button's [Material].
7+
/// The border side for the badge's [Material].
88
final BorderSide border;
99

10-
/// Typically the counter button's shape.
10+
/// Typically the counter badge's shape.
1111
final ShapeBorder borderShape;
1212

13-
/// Counter type of [GFBadgeShape] i.e, standard, pills, square,
13+
/// Counter type of [GFBadgeShape] i.e, standard, pills, square, circle
1414
final GFBadgeShape shape;
1515

1616
/// Pass [GFColor] or [Color]

0 commit comments

Comments
 (0)