2023-01-03 18:00:56 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
2023-01-07 09:22:31 +01:00
|
|
|
import '../../config/themes.dart';
|
2023-01-03 18:00:56 +01:00
|
|
|
|
|
|
|
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,
|
2023-01-07 09:22:31 +01:00
|
|
|
duration: FluffyThemes.animationDuration,
|
|
|
|
curve: FluffyThemes.animationCurve,
|
2023-01-03 18:00:56 +01:00
|
|
|
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(
|
2023-03-02 10:57:52 +01:00
|
|
|
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,
|
|
|
|
),
|
|
|
|
),
|
2023-01-03 18:00:56 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|