notes/lib/drawer_item.dart

76 lines
1.9 KiB
Dart
Raw Normal View History

2022-10-23 13:50:44 +00:00
import 'package:flutter/material.dart';
class DrawerItem extends StatelessWidget {
const DrawerItem(
{Key? key,
required this.dta,
this.endText,
required this.collapsed,
required this.active,
required this.onTap})
2022-10-23 13:50:44 +00:00
: super(key: key);
final ItemData dta;
final String? endText;
final bool collapsed;
final bool active;
final void Function() onTap;
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onTap,
child: Padding(
padding: const EdgeInsets.only(left: 9, top: 7, bottom: 7, right: 9),
child: ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
color: active ? const Color(0xff6e6e6e) : Colors.transparent,
2022-10-23 13:50:44 +00:00
child: Padding(
padding:
const EdgeInsets.only(left: 9, top: 7, bottom: 7, right: 9),
2022-10-23 13:50:44 +00:00
child: Row(
children: [
Icon(
dta.icon,
size: 26,
color: const Color(0xffdbdbdb),
2022-10-23 13:50:44 +00:00
),
if (!collapsed) ...[
const SizedBox(
width: 10,
),
Text(
dta.name,
style: const TextStyle(color: Color(0xffe9e9e9)),
2022-10-23 13:50:44 +00:00
),
Expanded(child: Container()),
Text(
endText ?? '',
style: const TextStyle(color: Color(0xffafafaf)),
2022-10-23 13:50:44 +00:00
),
const SizedBox(
width: 15,
)
]
],
),
),
),
),
),
);
}
}
class ItemData {
String name;
IconData icon;
ItemData(this.name, this.icon);
@override
String toString() {
return 'ItemData{name: $name, icon: $icon}';
}
}