125 lines
3.7 KiB
Dart
125 lines
3.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
/// A reusable side drawer that slides in from the right
|
|
/// Takes up 1/3 of the screen width
|
|
class SideDrawerPanel extends StatelessWidget {
|
|
final Widget child;
|
|
final String? title;
|
|
final VoidCallback? onClose;
|
|
final double? width;
|
|
|
|
const SideDrawerPanel({
|
|
Key? key,
|
|
required this.child,
|
|
this.title,
|
|
this.onClose,
|
|
this.width,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final screenWidth = MediaQuery.of(context).size.width;
|
|
final drawerWidth = width ?? screenWidth / 2;
|
|
|
|
return Container(
|
|
width: drawerWidth,
|
|
height: MediaQuery.of(context).size.height,
|
|
decoration: BoxDecoration(
|
|
color: Colors.white,
|
|
boxShadow: [
|
|
BoxShadow(
|
|
color: Colors.black.withOpacity(0.1),
|
|
blurRadius: 10,
|
|
spreadRadius: 2,
|
|
offset: const Offset(-2, 0),
|
|
),
|
|
],
|
|
),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
// Header
|
|
Container(
|
|
padding: const EdgeInsets.all(8),
|
|
decoration: BoxDecoration(
|
|
color: const Color(0xFFFFFFFF),
|
|
// color: const Color(0xFFF8F9FF),
|
|
border: Border(bottom: BorderSide(color: Colors.grey.shade200)),
|
|
),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
if (title != null)
|
|
Material(
|
|
color: Colors.white,
|
|
child: Text(
|
|
title!,
|
|
style: GoogleFonts.poppins(
|
|
fontSize: 14,
|
|
fontWeight: FontWeight.w600,
|
|
color: const Color(0xFF1E293B),
|
|
),
|
|
),
|
|
),
|
|
const Spacer(),
|
|
IconButton(
|
|
icon: const Icon(Icons.close),
|
|
onPressed: onClose ?? () => Navigator.of(context).pop(),
|
|
color: Colors.grey.shade600,
|
|
tooltip: 'Close',
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
// Content
|
|
Expanded(
|
|
child: SingleChildScrollView(
|
|
padding: const EdgeInsets.all(8),
|
|
// child: child,
|
|
child: Material(
|
|
color: Colors.white,
|
|
elevation: 0,
|
|
child: child, // Your CreateProposal_Quick()
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Show the drawer as a modal overlay
|
|
static Future<T?> show<T>({
|
|
required BuildContext context,
|
|
required Widget child,
|
|
String? title,
|
|
double? width,
|
|
bool barrierDismissible = true,
|
|
}) {
|
|
return showGeneralDialog<T>(
|
|
context: context,
|
|
barrierDismissible: barrierDismissible,
|
|
barrierLabel: 'Drawer',
|
|
barrierColor: Colors.black.withOpacity(0.5),
|
|
transitionDuration: const Duration(milliseconds: 300),
|
|
pageBuilder: (context, animation, secondaryAnimation) {
|
|
return Align(
|
|
alignment: Alignment.centerRight,
|
|
child: SideDrawerPanel(title: title, width: width, child: child),
|
|
);
|
|
},
|
|
transitionBuilder: (context, animation, secondaryAnimation, child) {
|
|
return SlideTransition(
|
|
position: Tween<Offset>(begin: const Offset(1, 0), end: Offset.zero)
|
|
.animate(
|
|
CurvedAnimation(parent: animation, curve: Curves.easeInOut),
|
|
),
|
|
child: child,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|