mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-09 21:49:31 +01:00
67 lines
1.8 KiB
Dart
67 lines
1.8 KiB
Dart
|
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(
|
||
|
color: Theme.of(context).primaryColor,
|
||
|
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,
|
||
|
)),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|