Added support for tab navigation (bottom widgets) for the custom app bar
This commit is contained in:
parent
dd13cebb80
commit
74c63ee70a
2 changed files with 30 additions and 11 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
import '../utils.dart';
|
||||||
import '../blocs/event_bloc.dart';
|
import '../blocs/event_bloc.dart';
|
||||||
import '../widgets/custom_app_bar.dart';
|
import '../widgets/custom_app_bar.dart';
|
||||||
|
|
||||||
|
|
@ -14,18 +15,31 @@ class EventScreen extends StatefulWidget {
|
||||||
_EventScreenState createState() => _EventScreenState();
|
_EventScreenState createState() => _EventScreenState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _EventScreenState extends State<EventScreen> {
|
class _EventScreenState extends State<EventScreen>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
EventBloc bloc;
|
EventBloc bloc;
|
||||||
|
TabController _tabController;
|
||||||
initState() {
|
initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
bloc = EventBloc(eventName: widget.eventName);
|
bloc = EventBloc(eventName: widget.eventName);
|
||||||
|
_tabController = TabController(vsync: this, length: 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: CustomAppBar(
|
appBar: CustomAppBar(
|
||||||
title: widget.eventName,
|
title: widget.eventName,
|
||||||
|
bottom: TabBar(
|
||||||
|
controller: _tabController,
|
||||||
|
tabs: <Tab>[
|
||||||
|
Tab(
|
||||||
|
text: 'tab1',
|
||||||
|
),
|
||||||
|
Tab(
|
||||||
|
text: 'tab2',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
|
||||||
//TODO: add support for tabed navigation.
|
|
||||||
|
|
||||||
/// A custom app bar to match the DO> design rules.
|
/// A custom app bar to match the DO> design rules.
|
||||||
///
|
///
|
||||||
/// This app bar is meant to be usen in screens that are not the home screen.
|
/// This app bar is meant to be usen in screens that are not the home screen.
|
||||||
|
|
@ -12,16 +10,17 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
final String title;
|
final String title;
|
||||||
|
|
||||||
/// Widget to be shown on the bottom of the app bar.
|
/// Widget to be shown on the bottom of the app bar.
|
||||||
final PreferredSize bottom;
|
final PreferredSizeWidget bottom;
|
||||||
|
|
||||||
/// the preferred size for this widget.
|
|
||||||
final Size preferredSize;
|
|
||||||
|
|
||||||
|
/// The size of only the app bar part.
|
||||||
|
final double appBarHeight;
|
||||||
CustomAppBar({
|
CustomAppBar({
|
||||||
this.title = '',
|
this.title = '',
|
||||||
this.bottom,
|
this.bottom,
|
||||||
}) : preferredSize =
|
}) : appBarHeight = bottom == null ? 140.0 : 120.0;
|
||||||
Size.fromHeight(140.0 + (bottom?.preferredSize?.height ?? 0));
|
|
||||||
|
Size get preferredSize =>
|
||||||
|
Size.fromHeight(appBarHeight + (bottom?.preferredSize?.height ?? 0));
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget result = Container(
|
Widget result = Container(
|
||||||
|
|
@ -56,8 +55,14 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
|
||||||
|
|
||||||
if (bottom != null) {
|
if (bottom != null) {
|
||||||
result = Column(
|
result = Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
result,
|
Flexible(
|
||||||
|
child: ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxHeight: 140.0),
|
||||||
|
child: result,
|
||||||
|
),
|
||||||
|
),
|
||||||
bottom,
|
bottom,
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue