nav bar
main_design2.0
nextwo 2 years ago
parent dd524bcbd1
commit b0992da201

@ -7,45 +7,42 @@ import 'notification_icon.dart';
class HomeAppBar extends StatefulWidget implements PreferredSizeWidget { class HomeAppBar extends StatefulWidget implements PreferredSizeWidget {
final int notificationCount; final int notificationCount;
final String userImage; final String userImage;
const HomeAppBar({Key key, this.notificationCount, this.userImage}) : super(key: key); GlobalKey<ScaffoldState> scaffoldKey;
HomeAppBar({Key key, this.notificationCount, this.userImage, this.scaffoldKey}) : super(key: key);
@override @override
State<HomeAppBar> createState() => _AppBarState(); State<HomeAppBar> createState() => _AppBarState();
@override @override
Size get preferredSize => const Size.fromHeight(150); Size get preferredSize => const Size.fromHeight(60);
} }
class _AppBarState extends State<HomeAppBar> { class _AppBarState extends State<HomeAppBar> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Padding( return AppBar(
padding: const EdgeInsets.only(top: 30.0, right: 12, left: 12), automaticallyImplyLeading: false,
child: PreferredSize( elevation: 0,
child: Column( title: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Row( Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
UserImage( InkWell(
onTap: (){
widget.scaffoldKey.currentState.openDrawer();
},
child: UserImage(
url: widget.userImage, url: widget.userImage,
), ),
NotificationIcon( ),
notificationCount: 3, NotificationIcon(
) notificationCount: 3,
], )
), ],
// SizedBox(height: 15), ),
// Column( ],
// crossAxisAlignment: CrossAxisAlignment.start,
// children: [
// Text("welcome," , style: Theme.of(context).textTheme.titleLarge?.copyWith(fontWeight: FontWeight.w500, color: AppColor.neutral20)),
// Text("Engineer name" , style: Theme.of(context).textTheme.headlineMedium?.copyWith(fontWeight: FontWeight.w600)),
// ],
// )
],
),
), ),
); );
} }

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:test_sa/extensions/context_extension.dart';
import '../../app_style/app_color.dart'; import '../../app_style/app_color.dart';
@ -10,7 +11,7 @@ class NotificationIcon extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Stack( return Stack(
children: <Widget>[ children: <Widget>[
const Icon(Icons.notifications, size: 36,), Icon(Icons.notifications, size: 36, ),
if(notificationCount != null) if(notificationCount != null)
Positioned( Positioned(
right: 0, right: 0,

@ -19,6 +19,7 @@ class LandPage extends StatefulWidget {
} }
class _LandPageState extends State<LandPage> { class _LandPageState extends State<LandPage> {
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
int currentPageIndex = 0; int currentPageIndex = 0;
static const List<Widget> _pages = <Widget>[ static const List<Widget> _pages = <Widget>[
DashboardPage(), DashboardPage(),
@ -49,7 +50,8 @@ class _LandPageState extends State<LandPage> {
return false; return false;
}, },
child: Scaffold( child: Scaffold(
appBar: HomeAppBar(), key: _scaffoldKey,
appBar: HomeAppBar(scaffoldKey:_scaffoldKey),
body: Padding( body: Padding(
padding: EdgeInsets.only(left: 16.toScreenWidth, top: 11.toScreenHeight), padding: EdgeInsets.only(left: 16.toScreenWidth, top: 11.toScreenHeight),
child: _pages[currentPageIndex], child: _pages[currentPageIndex],

Loading…
Cancel
Save