import 'package:anyway/pages/new_trip_preferences.dart';
import 'package:anyway/structs/trip.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';


class NewTripOptionsButton extends StatefulWidget {
  final Trip trip;

  const NewTripOptionsButton({super.key, required this.trip});

  @override
  State<NewTripOptionsButton> createState() => _NewTripOptionsButtonState();
}

class _NewTripOptionsButtonState extends State<NewTripOptionsButton> {

  @override
  Widget build(BuildContext context) {
    return ListenableBuilder(
      listenable: widget.trip,
      builder: (BuildContext context, Widget? child) {
        if (widget.trip.landmarks.isEmpty){
          return Container();
        }
        return FloatingActionButton.extended(
          onPressed: () async {
            Navigator.of(context).push(
              MaterialPageRoute(
                builder: (context) => NewTripPreferencesPage(trip: widget.trip)
              )
            );
          },
          icon: const Icon(Icons.add),
          label: const AutoSizeText('Set preferences')
        );
      }
    );
  }
}

