From 3ac4e919c0eba1d5724976e1dfccc9b9783b57ee Mon Sep 17 00:00:00 2001 From: AYM1607 Date: Sun, 31 Mar 2019 16:55:54 -0600 Subject: [PATCH] Created the custom app bar for screens different than home --- lib/src/screens/new_task_screen.dart | 7 +++- lib/src/widgets/custom_app_bar.dart | 51 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 lib/src/widgets/custom_app_bar.dart diff --git a/lib/src/screens/new_task_screen.dart b/lib/src/screens/new_task_screen.dart index 669d307..78594aa 100644 --- a/lib/src/screens/new_task_screen.dart +++ b/lib/src/screens/new_task_screen.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../blocs/new_task_bloc.dart'; +import '../widgets/custom_app_bar.dart'; class NewTaskScreen extends StatefulWidget { @override @@ -11,6 +12,10 @@ class _NewTaskScreenState extends State { final NewTaskBloc bloc = NewTaskBloc(); Widget build(BuildContext context) { - return Scaffold(); + return Scaffold( + appBar: CustomAppBar( + title: 'Add task', + ), + ); } } diff --git a/lib/src/widgets/custom_app_bar.dart b/lib/src/widgets/custom_app_bar.dart new file mode 100644 index 0000000..d6b60da --- /dev/null +++ b/lib/src/widgets/custom_app_bar.dart @@ -0,0 +1,51 @@ +import 'package:flutter/material.dart'; +import 'package:font_awesome_flutter/font_awesome_flutter.dart'; + +class CustomAppBar extends StatelessWidget implements PreferredSizeWidget { + final String title; + + CustomAppBar({this.title = ''}); + + Widget build(BuildContext context) { + return Material( + elevation: 10.0, + child: Container( + color: Theme.of(context).canvasColor, + child: SafeArea( + child: Container( + height: preferredSize.height, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + IconButton( + icon: Icon( + FontAwesomeIcons.arrowLeft, + color: Color.fromRGBO(112, 112, 112, 1), + ), + onPressed: () => Navigator.of(context).pop(), + ), + SizedBox( + height: 10, + ), + Padding( + padding: const EdgeInsets.only(left: 20.0), + child: Text( + title, + style: TextStyle( + fontSize: 40, + fontWeight: FontWeight.w700, + color: Colors.white, + ), + ), + ), + ], + ), + ), + ), + ), + ); + } + + @override + final preferredSize = Size.fromHeight(140.0); +}