mangayomi-mirror/lib/modules/widgets/bottom_select_bar.dart
NBA2K1 c2bae6d17b Extract reusable Select Bar and Button widgets
Previously, the same select bar and button styles were defined in both
`library_screen.dart` and `manga_detail_view.dart`, resulting in repeated code.

This commit extracts the select bar and its buttons into reusable widgets
to reduce duplication and improve readability and maintainability.
2025-07-28 16:29:30 +02:00

66 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:mangayomi/utils/extensions/build_context_extensions.dart';
/// Bar, that appears at the bottom of the screen when long-pressing (selecting)
/// a Manga/Anime/Novel or Chapter/Episode
class BottomSelectBar extends StatelessWidget {
final bool isVisible;
final List<BottomSelectButton> actions;
const BottomSelectBar({
super.key,
required this.isVisible,
required this.actions,
});
@override
Widget build(BuildContext context) {
return AnimatedContainer(
curve: Curves.easeIn,
decoration: BoxDecoration(
color: context.primaryColor.withValues(alpha: 0.2),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
duration: const Duration(milliseconds: 100),
height: isVisible ? 70 : 0,
width: context.width(1),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: actions,
),
);
}
}
/// Button for the BottomSelectBar
class BottomSelectButton extends StatelessWidget {
final Widget icon;
final VoidCallback onPressed;
const BottomSelectButton({
super.key,
required this.icon,
required this.onPressed,
});
@override
Widget build(BuildContext context) {
return Expanded(
child: SizedBox(
height: 70,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
elevation: 0,
backgroundColor: Colors.transparent,
shadowColor: Colors.transparent,
),
onPressed: onPressed,
child: icon,
),
),
);
}
}