fluffychat/lib/pages/chat_list/navi_rail_item.dart

67 lines
1.9 KiB
Dart
Raw Normal View History

2023-01-03 18:00:56 +01:00
import 'package:flutter/material.dart';
import 'package:fluffychat/config/app_config.dart';
class NaviRailItem extends StatelessWidget {
final String toolTip;
final bool isSelected;
final void Function() onTap;
final Widget icon;
final Widget? selectedIcon;
const NaviRailItem({
required this.toolTip,
required this.isSelected,
required this.onTap,
required this.icon,
this.selectedIcon,
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
height: 64,
width: 64,
child: Stack(
children: [
Positioned(
top: 16,
bottom: 16,
left: 0,
child: AnimatedContainer(
width: isSelected ? 4 : 0,
duration: const Duration(milliseconds: 200),
decoration: BoxDecoration(
2023-01-03 18:01:53 +01:00
color: Theme.of(context).colorScheme.primary,
2023-01-03 18:00:56 +01:00
borderRadius: const BorderRadius.only(
topRight: Radius.circular(90),
bottomRight: Radius.circular(90),
),
),
),
),
Center(
child: IconButton(
onPressed: onTap,
tooltip: toolTip,
icon: Material(
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
color: isSelected
? Theme.of(context).colorScheme.primaryContainer
: Theme.of(context).colorScheme.background,
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 8.0,
vertical: 8.0,
),
child: isSelected ? selectedIcon ?? icon : icon,
)),
),
),
],
),
);
}
}