You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
163 lines
5.7 KiB
Dart
163 lines
5.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:tangheem/classes/const.dart';
|
|
|
|
class CommonAppbarWidget extends StatefulWidget {
|
|
final bool showDrawer;
|
|
final Widget child;
|
|
|
|
CommonAppbarWidget({Key key, this.showDrawer = false, @required this.child}) : super(key: key);
|
|
|
|
@override
|
|
_CommonAppbarWidgetState createState() {
|
|
return _CommonAppbarWidgetState();
|
|
}
|
|
}
|
|
|
|
class _CommonAppbarWidgetState extends State<CommonAppbarWidget> {
|
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
key: widget.showDrawer ? _scaffoldKey : null,
|
|
drawer: widget.showDrawer ? drawerView() : null,
|
|
drawerScrimColor: Colors.black.withOpacity(.3),
|
|
body: SafeArea(
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
color: Colors.white,
|
|
height: 100,
|
|
padding: EdgeInsets.only(top: 8, bottom: 8),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
IconButton(
|
|
icon: Icon(widget.showDrawer ? Icons.menu : Icons.arrow_back_ios, color: Const.textGrey),
|
|
padding: EdgeInsets.only(left: 16),
|
|
onPressed: () {
|
|
if (widget.showDrawer) {
|
|
_scaffoldKey.currentState.openDrawer();
|
|
} else {
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
),
|
|
SvgPicture.asset(
|
|
"assets/logos/tangheem_logo.svg",
|
|
height: 100,
|
|
width: 100,
|
|
alignment: Alignment.centerRight,
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Expanded(child: Directionality(textDirection: TextDirection.rtl, child: widget.child)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget drawerView() {
|
|
var height = MediaQuery.of(context).padding.top;
|
|
return Drawer(
|
|
elevation: 0,
|
|
child: Container(
|
|
color: Colors.white,
|
|
child: Column(
|
|
children: [
|
|
Container(
|
|
height: 100 + height,
|
|
padding: EdgeInsets.only(left: 0, top: height),
|
|
alignment: Alignment.centerLeft,
|
|
child: IconButton(
|
|
icon: Icon(Icons.clear, color: Const.textGrey),
|
|
onPressed: () {
|
|
if (_scaffoldKey.currentState.isDrawerOpen) {
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 8, bottom: 16),
|
|
padding: EdgeInsets.only(left: 12, right: 12),
|
|
child: Row(
|
|
children: [
|
|
commonIconButton("assets/icons/accessibility.svg", () {}),
|
|
commonIconButton("assets/icons/dark_mode.svg", () {}),
|
|
commonIconButton("assets/icons/bookmark.svg", () {}),
|
|
commonIconButton("assets/icons/increase_size.svg", () {}),
|
|
commonIconButton("assets/icons/reduce_size.svg", () {}),
|
|
commonIconButton("assets/icons/notification.svg", () {}),
|
|
commonIconButton("assets/icons/user_logged.svg", () {}),
|
|
],
|
|
),
|
|
),
|
|
Container(
|
|
height: 40,
|
|
margin: EdgeInsets.only(left: 24, right: 24),
|
|
padding: EdgeInsets.only(left: 8, right: 8),
|
|
alignment: Alignment.centerRight,
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(6),
|
|
gradient: LinearGradient(
|
|
stops: [0.0, 0.5],
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomCenter,
|
|
colors: [Const.gradientPink, Const.gradientOrange],
|
|
),
|
|
),
|
|
child: Row(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Text(
|
|
"الرئيسية",
|
|
style: TextStyle(fontSize: 14, color: Colors.white),
|
|
),
|
|
SizedBox(width: 8),
|
|
SvgPicture.asset("assets/icons /home.svg", height: 20, width: 20, color: Colors.white),
|
|
],
|
|
),
|
|
),
|
|
Expanded(child: Container()),
|
|
Container(
|
|
margin: EdgeInsets.only(top: 16, bottom: 0),
|
|
padding: EdgeInsets.only(left: 32, right: 32),
|
|
child: Row(
|
|
children: [
|
|
commonIconButton("assets/icons/linkedin.svg", () {}, size: 35),
|
|
commonIconButton("assets/icons/pinterest.svg", () {}, size: 35),
|
|
commonIconButton("assets/icons/whatsapp.svg", () {}, size: 35),
|
|
commonIconButton("assets/icons/facebook.svg", () {}, size: 35),
|
|
commonIconButton("assets/icons/instgram.svg", () {}, size: 35),
|
|
commonIconButton("assets/icons/twitter.svg", () {}, size: 35),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget commonIconButton(String icon, VoidCallback onPressed, {double size}) {
|
|
return Expanded(
|
|
child: IconButton(padding: EdgeInsets.zero, icon: SvgPicture.asset(icon, height: size ?? 25, width: size ?? 30, color: Const.textGrey), onPressed: onPressed),
|
|
);
|
|
}
|
|
}
|