
import 'package:flutter/material.dart';

class ListItemNavigator extends StatelessWidget {
  const ListItemNavigator({Key? key, required this.icon, required this.text, required this.target, this.onLongPress, this.arrow = true}) : super(key: key);

  final IconData icon;
  final String text;
  final bool arrow;

  final Widget target;

  final GestureLongPressCallback? onLongPress;

  @override
  Widget build(BuildContext context) {
    onTabAction() => Navigator.push(context, MaterialPageRoute(builder: (context) => target));
    onLongPressAction() => onLongPress;

    return ListTile(
      leading: Icon(icon),
      title: Text(text),
      trailing: arrow ? const Icon(Icons.arrow_right) : null,
      onTap: onTabAction,
      onLongPress: onLongPressAction,
    );
  }
}
